Bug 1367696 - PART I determine the tour type;r=mossop, timdream
MozReview-Commit-ID: KUXPftqZdl1
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1697,16 +1697,18 @@ pref("browser.sessionstore.restore_tabs_
// Enable safebrowsing v4 tables (suffixed by "-proto") update.
pref("urlclassifier.malwareTable", "goog-malware-proto,goog-unwanted-proto,test-malware-simple,test-unwanted-simple");
pref("urlclassifier.phishTable", "goog-phish-proto,test-phish-simple");
pref("browser.suppress_first_window_animation", true);
// Preferences for Photon onboarding system extension
pref("browser.onboarding.enabled", true);
+// Mark this as an upgraded profile so we don't offer the initial new user onboarding tour.
+pref("browser.onboarding.tourset-version", 1);
pref("browser.onboarding.hidden", false);
// On the Activity-Stream page, the snippet's position overlaps with our notification.
// So use `browser.onboarding.notification.finished` to let the AS page know
// if our notification is finished and safe to show their snippet.
pref("browser.onboarding.notification.finished", false);
// Preferences for the Screenshots feature:
// Temporarily disable Screenshots in Beta & Release, so that we can gradually
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1711,17 +1711,17 @@ BrowserGlue.prototype = {
return;
this._openPreferences("sync", { origin: "doorhanger" });
}
AlertsService.showAlertNotification(null, title, body, true, null, clickCallback);
},
// eslint-disable-next-line complexity
_migrateUI: function BG__migrateUI() {
- const UI_VERSION = 48;
+ const UI_VERSION = 49;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
let currentUIVersion;
if (Services.prefs.prefHasUserValue("browser.migration.version")) {
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
} else {
// This is a new profile, nothing to migrate.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -2049,16 +2049,21 @@ BrowserGlue.prototype = {
if (currentUIVersion < 48) {
// Bug 1372954 - the checked value was persisted but the attribute removal wouldn't
// be persisted (Bug 15232). Turns out we can just not persist the value in this case.
// The situation was only happening for a few nightlies in 56, so this migration can
// be removed in version 58.
xulStore.removeValue(BROWSER_DOCURL, "sidebar-box", "checked");
}
+ if (currentUIVersion < 49) {
+ // Annotate that a user haven't seen any onboarding tour
+ Services.prefs.setIntPref("browser.onboarding.seen-tourset-version", 0);
+ }
+
// Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
},
// ------------------------------
// public nsIBrowserGlue members
// ------------------------------
new file mode 100644
--- /dev/null
+++ b/browser/extensions/onboarding/OnboardingTourType.jsm
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+this.EXPORTED_SYMBOLS = ["OnboardingTourType"];
+
+const {utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Services.jsm");
+
+var OnboardingTourType = {
+ /**
+ * Determine the current tour type (new user tour or update user tour).
+ * The function checks 2 criterias
+ * - TOURSET_VERSION: current onboarding tourset version
+ * - PREF_SEEN_TOURSET_VERSION: the user seen tourset version
+ * As the result the function will set the right current tour type in the tour type pref (PREF_TOUR_TYPE) for later use.
+ */
+ check() {
+ const PREF_TOUR_TYPE = "browser.onboarding.tour-type";
+ const PREF_SEEN_TOURSET_VERSION = "browser.onboarding.seen-tourset-version";
+ const TOURSET_VERSION = Services.prefs.getIntPref("browser.onboarding.tourset-version");
+
+ if (!Services.prefs.prefHasUserValue(PREF_SEEN_TOURSET_VERSION)) {
+ // User has never seen an onboarding tour, present the user with the new user tour.
+ Services.prefs.setStringPref(PREF_TOUR_TYPE, "new");
+ } else if (Services.prefs.getIntPref(PREF_SEEN_TOURSET_VERSION) < TOURSET_VERSION) {
+ // show the update user tour when tour set version is larger than the seen tourset version
+ Services.prefs.setStringPref(PREF_TOUR_TYPE, "update");
+ Services.prefs.setBoolPref("browser.onboarding.hidden", false);
+ }
+ Services.prefs.setIntPref(PREF_SEEN_TOURSET_VERSION, TOURSET_VERSION);
+ },
+};
--- a/browser/extensions/onboarding/README.md
+++ b/browser/extensions/onboarding/README.md
@@ -9,8 +9,17 @@ Everytime `about:home` or `about:newtab`
## Landing rules
We would apply some rules:
* Avoid `chrome://` in `onbaording.js` since onboarding is intented to be injected into a normal content process page.
* All styles and ids should be formated as `onboarding-*` to avoid conflict with the origin page.
* All strings in `locales` should be formated as `onboarding.*` for consistency.
+## How to pump tour set version after update tours
+
+The tourset version is used to track the last major tourset change version. The `tourset-version` pref store the major tourset version (ex: `1`) but not the current browser version. When browser update to the next version (ex: 58, 59) the tourset pref is still `1` if we didn't do any major tourset update.
+
+Once the tour set version is updated (ex: `2`), onboarding overlay should show the update tour to the updated user (ex: update from v56 -> v57), even when user have watched the previous tours or preferred to hide the previous tours.
+
+Edit `browser/app/profile/firefox.js` and set `browser.onboarding.tourset-version` as `[tourset version]` (in integer format).
+
+For example if we update the tourset in v60 and decide to show all update users the tour, we set `browser.onboarding.tourset-version` as `3`.
--- a/browser/extensions/onboarding/bootstrap.js
+++ b/browser/extensions/onboarding/bootstrap.js
@@ -1,17 +1,22 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/Preferences.jsm");
+const {utils: Cu} = Components;
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "OnboardingTourType",
+ "resource://onboarding/modules/OnboardingTourType.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
+ "resource://gre/modules/Preferences.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Services.jsm");
const PREF_WHITELIST = [
"browser.onboarding.enabled",
"browser.onboarding.hidden",
"browser.onboarding.notification.finished",
"browser.onboarding.notification.lastPrompted"
];
@@ -43,13 +48,14 @@ function initContentMessageListener() {
});
}
function install(aData, aReason) {}
function uninstall(aData, aReason) {}
function startup(aData, reason) {
+ OnboardingTourType.check();
Services.mm.loadFrameScript("resource://onboarding/onboarding.js", true);
initContentMessageListener();
}
function shutdown(aData, reason) {}
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -188,16 +188,22 @@ class Onboarding {
constructor(contentWindow) {
this.init(contentWindow);
}
async init(contentWindow) {
this._window = contentWindow;
this._tourItems = [];
this._tourPages = [];
+
+ // we only support the new user tour at this moment
+ if (Services.prefs.getStringPref("browser.onboarding.tour-type", "update") !== "new") {
+ return;
+ }
+
// We want to create and append elements after CSS is loaded so
// no flash of style changes and no additional reflow.
await this._loadCSS();
this._bundle = Services.strings.createBundle(BUNDLE_URI);
this._overlayIcon = this._renderOverlayIcon();
this._overlay = this._renderOverlay();
this._window.document.body.appendChild(this._overlayIcon);
--- a/browser/extensions/onboarding/jar.mn
+++ b/browser/extensions/onboarding/jar.mn
@@ -4,8 +4,9 @@
[features/onboarding@mozilla.org] chrome.jar:
% resource onboarding %content/
content/ (content/*)
# Package UITour-lib.js in here rather than under
# /browser/components/uitour to avoid "unreferenced files" error when
# Onboarding extension is not built.
content/lib/UITour-lib.js (/browser/components/uitour/UITour-lib.js)
+ content/modules/ (*.jsm)