Bug 1380963 - Display different welcome messages for update or new users on the overlay tour icon.r=mossop, Gasolin, flod draft
authorRex Lee <rexboy@mozilla.com>
Mon, 17 Jul 2017 15:51:43 +0800
changeset 610360 1f2b62a5f03e8e7f22c3406cfac691dd0cb7c08f
parent 610359 d685c31022df71e0575fed0d32555d7ea04f2967
child 637850 d88eefa16de09e2c447ff4877b2ed94b607cea5c
push id68880
push userbmo:rexboy@mozilla.com
push dateTue, 18 Jul 2017 08:38:39 +0000
reviewersmossop, Gasolin, flod
bugs1380963
milestone56.0a1
Bug 1380963 - Display different welcome messages for update or new users on the overlay tour icon.r=mossop, Gasolin, flod MozReview-Commit-ID: A8DxVkSz9dX
browser/extensions/onboarding/content/onboarding.js
browser/extensions/onboarding/locales/en-US/onboarding.properties
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -231,18 +231,19 @@ class Onboarding {
     this.init(contentWindow);
   }
 
   async init(contentWindow) {
     this._window = contentWindow;
     this._tourItems = [];
     this._tourPages = [];
     this._tours = [];
+    this._tourType = Services.prefs.getStringPref("browser.onboarding.tour-type", "update");
 
-    let tourIds = this._getTourIDList(Services.prefs.getStringPref("browser.onboarding.tour-type", "update"));
+    let tourIds = this._getTourIDList();
     tourIds.forEach(tourId => {
       if (onboardingTourset[tourId]) {
         this._tours.push(onboardingTourset[tourId]);
       }
     });
 
     if (this._tours.length === 0) {
       return;
@@ -291,18 +292,18 @@ class Onboarding {
 
     this._loadJS(TOUR_AGENT_JS_URI);
 
     this._initPrefObserver();
     // Doing tour notification takes some effort. Let's do it on idle.
     this._window.requestIdleCallback(() => this._initNotification());
   }
 
-  _getTourIDList(tourType) {
-    let tours = Services.prefs.getStringPref(`browser.onboarding.${tourType}tour`, "");
+  _getTourIDList() {
+    let tours = Services.prefs.getStringPref(`browser.onboarding.${this._tourType}tour`, "");
     return tours.split(",").filter(tourId => tourId !== "").map(tourId => tourId.trim());
   }
 
   _initNotification() {
     let doc = this._window.document;
     if (doc.hidden) {
       // When the preloaded-browser feature is on,
       // it would preload an hidden about:newtab in the background.
@@ -645,17 +646,20 @@ class Onboarding {
         <div id="onboarding-notification-body">
           <h6 id="onboarding-notification-tour-title"></h6>
           <span id="onboarding-notification-tour-message"></span>
         </div>
         <button id="onboarding-notification-action-btn"></button>
       </section>
       <button id="onboarding-notification-close-btn"></button>
     `;
-    let toolTip = this._bundle.formatStringFromName("onboarding.notification-icon-tool-tip", [BRAND_SHORT_NAME], 1);
+    let toolTip = this._bundle.formatStringFromName(
+      this._tourType == "new" ? "onboarding.notification-icon-tool-tip"
+                              : "onboarding.notification-icon-tooltip-updated",
+      [BRAND_SHORT_NAME], 1);
     div.querySelector("#onboarding-notification-icon").setAttribute("data-tooltip", toolTip);
     return div;
   }
 
   hide() {
     this.setToursCompleted(this._tours.map(tour => tour.id));
     this.sendMessageToChrome("set-prefs", [
       {
@@ -691,17 +695,21 @@ class Onboarding {
        this._bundle.GetStringFromName("onboarding.hidden-checkbox-label-text");
     div.querySelector("#onboarding-header").textContent =
        this._bundle.formatStringFromName("onboarding.overlay-title", [BRAND_SHORT_NAME], 1);
     return div;
   }
 
   _renderOverlayIcon() {
     let img = this._window.document.createElement("div");
-    let tooltip = this._bundle.formatStringFromName("onboarding.overlay-icon-tooltip", [BRAND_SHORT_NAME], 1);
+    let tooltip = this._bundle.formatStringFromName(
+      this._tourType == "new" ? "onboarding.overlay-icon-tooltip"
+                              : "onboarding.overlay-icon-tooltip-updated",
+      [BRAND_SHORT_NAME], 1);
+
     img.setAttribute("aria-label", tooltip);
     img.id = "onboarding-overlay-icon";
     return img;
   }
 
   _loadTours(tours) {
     let itemsFrag = this._window.document.createDocumentFragment();
     let pagesFrag = this._window.document.createDocumentFragment();
--- a/browser/extensions/onboarding/locales/en-US/onboarding.properties
+++ b/browser/extensions/onboarding/locales/en-US/onboarding.properties
@@ -5,16 +5,19 @@
 onboarding.overlay-title=Getting started with %S
 onboarding.hidden-checkbox-label-text=Mark all as complete, and hide the tour
 #LOCALIZATION NOTE(onboarding.button.learnMore): this string is used as a button label, displayed near the message, and shared across all the onboarding notifications.
 onboarding.button.learnMore=Learn More
 # LOCALIZATION NOTE(onboarding.notification-icon-tool-tip): This string will be used to show the tooltip alongside the notification icon in the notification bar. %S is brandShortName.
 onboarding.notification-icon-tool-tip=New to %S?
 # LOCALIZATION NOTE(onboarding.overlay-icon-tooltip): This string will be used to show the tooltip alongside the notification icon in the overlay tour. %S is brandShortName.
 onboarding.overlay-icon-tooltip=New to %S? Let’s get started.
+# LOCALIZATION NOTE(onboarding.overlay-icon-tooltip-updated): %S is brandShortName.
+onboarding.overlay-icon-tooltip-updated=%S is all new. See what you can do!
+onboarding.notification-icon-tooltip-updated=See what’s new!
 
 onboarding.tour-search2=Search
 onboarding.tour-search.title2=Find it faster.
 # LOCALIZATION NOTE (onboarding.tour-search.description2): If Amazon is not part
 # of the default searchplugins for your locale, you can replace it with another
 # ecommerce website (if you're shipping one), but not with a general purpose
 # search engine (Google, Bing, Yandex, etc.). Alternatively, only reference
 # Wikipedia and drop Amazon from the text.