Bug 1374717 - show alternative message when firefox already the default browser;r=flod,mossop
authorgasolin <gasolin@gmail.com>
Thu, 06 Jul 2017 16:14:59 +0800
changeset 369178 f4aacb756baca571a95f64462fb03be8371386eb
parent 369177 ecfa13e750242a2026016538469ed3d2e0b636a2
child 369179 356bbf472e754bd735265ea24bfa355a777e5197
push id32192
push userkwierso@gmail.com
push dateTue, 18 Jul 2017 00:01:01 +0000
treeherdermozilla-central@efc0b1525edb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflod, mossop
bugs1374717
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1374717 - show alternative message when firefox already the default browser;r=flod,mossop the call-to-action button will disabled when user click the button, to prevent open settings panel several times the call-to-action button will be replaced to alternative text when Firefox is already the default browser MozReview-Commit-ID: LFeTuDnQEFA
browser/extensions/onboarding/content/onboarding-tour-agent.js
browser/extensions/onboarding/content/onboarding.css
browser/extensions/onboarding/content/onboarding.js
browser/extensions/onboarding/locales/en-US/onboarding.properties
--- a/browser/extensions/onboarding/content/onboarding-tour-agent.js
+++ b/browser/extensions/onboarding/content/onboarding-tour-agent.js
@@ -10,18 +10,29 @@ document.getElementById("onboarding-over
                         .addEventListener("click", evt => {
   switch (evt.target.id) {
     case "onboarding-tour-addons-button":
       Mozilla.UITour.showHighlight("addons");
       break;
     case "onboarding-tour-customize-button":
       Mozilla.UITour.showHighlight("customize");
       break;
-   case "onboarding-tour-default-browser-button":
-      Mozilla.UITour.setConfiguration("defaultBrowser");
+    case "onboarding-tour-default-browser-button":
+      Mozilla.UITour.getConfiguration("appinfo", (config) => {
+        let isDefaultBrowser = config.defaultBrowser;
+        let btn = document.getElementById("onboarding-tour-default-browser-button");
+        let msg = document.getElementById("onboarding-tour-is-default-browser-msg");
+        if (isDefaultBrowser) {
+          btn.classList.add("onboarding-hidden");
+          msg.classList.remove("onboarding-hidden");
+        } else {
+          btn.disabled = true;
+          Mozilla.UITour.setConfiguration("defaultBrowser");
+        }
+      });
       break;
     case "onboarding-tour-private-browsing-button":
       Mozilla.UITour.showHighlight("privateWindow");
       break;
     case "onboarding-tour-search-button":
       Mozilla.UITour.openSearchPanel(() => {});
       break;
     case "onboarding-tour-sync-button":
@@ -29,14 +40,15 @@ document.getElementById("onboarding-over
       if (emailInput.checkValidity()) {
         Mozilla.UITour.showFirefoxAccounts(null, emailInput.value);
       }
       break;
     case "onboarding-overlay":
     case "onboarding-overlay-close-btn":
       // Dismiss any highlights if a user tries to close the dialog.
       Mozilla.UITour.hideHighlight();
+      break;
   }
   // Dismiss any highlights if a user tries to change to other tours.
   if (evt.target.classList.contains("onboarding-tour-item")) {
     Mozilla.UITour.hideHighlight();
   }
 });
--- a/browser/extensions/onboarding/content/onboarding.css
+++ b/browser/extensions/onboarding/content/onboarding.css
@@ -28,17 +28,18 @@
   height: 29px;
   position: absolute;
   cursor: pointer;
   top: 30px;
   offset-inline-start: 30px;
   background: url("img/overlay-icon.svg") no-repeat;
 }
 
-#onboarding-overlay-dialog {
+#onboarding-overlay-dialog,
+.onboarding-hidden {
   display: none;
 }
 
 #onboarding-overlay-close-btn,
 #onboarding-notification-close-btn {
   position: absolute;
   top: 15px;
   offset-inline-end: 15px;
@@ -144,16 +145,26 @@
   padding-inline-start: 29px;
 }
 
 #onboarding-tour-list > li.onboarding-active,
 #onboarding-tour-list > li:hover {
   color: #0A84FF;
 }
 
+/* Default browser tour */
+#onboarding-tour-is-default-browser-msg {
+  font-size: 16px;
+  line-height: 21px;
+  float: inline-end;
+  margin-inline-end: 26px;
+  margin-top: -32px;
+  text-align: center;
+}
+
 /* Sync tour */
 #onboarding-tour-sync-page form {
   text-align: center;
 }
 
 #onboarding-tour-sync-page form > h3 {
   text-align: center;
   margin: 0;
@@ -256,23 +267,23 @@
   border: none;
   border-radius: 0;
   color: #fff;
   float: inline-end;
   margin-inline-end: 26px;
   margin-top: -32px;
 }
 
-.onboarding-tour-action-button:hover:not([disabled="true"]) ,
+.onboarding-tour-action-button:hover:not([disabled]) ,
 #onboarding-notification-action-btn:hover {
   background: #0060df;
   cursor: pointer;
 }
 
-.onboarding-tour-action-button:active:not([disabled="true"]),
+.onboarding-tour-action-button:active:not([disabled]),
 #onboarding-notification-action-btn:active  {
   background: #003EAA;
 }
 
 .onboarding-tour-action-button:disabled {
   opacity: 0.5;
 }
 
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -155,31 +155,34 @@ var onboardingTourset = {
     tourNameId: "onboarding.tour-default-browser",
     getNotificationStrings(bundle) {
       return {
         title: bundle.formatStringFromName("onboarding.notification.onboarding-tour-default-browser.title", [BRAND_SHORT_NAME], 1),
         message: bundle.formatStringFromName("onboarding.notification.onboarding-tour-default-browser.message", [BRAND_SHORT_NAME], 1),
         button: bundle.GetStringFromName("onboarding.button.learnMore"),
       };
     },
-    getPage(win) {
+    getPage(win, bundle) {
       let div = win.document.createElement("div");
       let defaultBrowserButtonId = win.matchMedia("(-moz-os-version: windows-win7)").matches ?
         "onboarding.tour-default-browser.win7.button" : "onboarding.tour-default-browser.button";
+      let isDefaultMessage = bundle.GetStringFromName("onboarding.tour-default-browser.is-default.message");
+      let isDefault2ndMessage = bundle.formatStringFromName("onboarding.tour-default-browser.is-default.2nd-message", [BRAND_SHORT_NAME], 1);
       // eslint-disable-next-line no-unsanitized/property
       div.innerHTML = `
         <section class="onboarding-tour-description">
           <h1 data-l10n-id="onboarding.tour-default-browser.title2"></h1>
           <p data-l10n-id="onboarding.tour-default-browser.description2"></p>
         </section>
         <section class="onboarding-tour-content">
           <img src="resource://onboarding/img/figure_default.svg" />
         </section>
         <aside class="onboarding-tour-button-container">
           <button id="onboarding-tour-default-browser-button" class="onboarding-tour-action-button" data-l10n-id="${defaultBrowserButtonId}"></button>
+          <div id="onboarding-tour-is-default-browser-msg" class="onboarding-hidden">${isDefaultMessage}<br/>${isDefault2ndMessage}</div>
         </aside>
       `;
       return div;
     },
   },
   "sync": {
     id: "onboarding-tour-sync",
     tourNameId: "onboarding.tour-sync2",
--- a/browser/extensions/onboarding/locales/en-US/onboarding.properties
+++ b/browser/extensions/onboarding/locales/en-US/onboarding.properties
@@ -51,16 +51,20 @@ onboarding.tour-default-browser=Default 
 # LOCALIZATION NOTE(onboarding.tour-default-browser.title2): This string will be used in the default browser tour title. %S is brandShortName
 onboarding.tour-default-browser.title2=Make %S your go-to browser.
 # LOCALIZATION NOTE(onboarding.tour-default-browser.description2): This string will be used in the default browser tour description. %1$S is brandShortName
 onboarding.tour-default-browser.description2=Love %1$S? Set it as your default browser. Open a link from another application, and %1$S will be there for you.
 # LOCALIZATION NOTE(onboarding.tour-default-browser.button): Label for a button to open the OS default browser settings where it's not possible to set the default browser directly. (OSX, Linux, Windows 8 and higher)
 onboarding.tour-default-browser.button=Open Default Browser Settings
 # LOCALIZATION NOTE(onboarding.tour-default-browser.win7.button): Label for a button to directly set the default browser (Windows 7). %S is brandShortName
 onboarding.tour-default-browser.win7.button=Make %S Your Default Browser
+# LOCALIZATION NOTE(onboarding.tour-default-browser.is-default.message): Label displayed when Firefox is already set as default browser. followed on a new line by "tour-default-browser.is-default.2nd-message".
+onboarding.tour-default-browser.is-default.message=You’ve got this!
+# LOCALIZATION NOTE(onboarding.tour-default-browser.is-default.2nd-message): Label displayed when Firefox is already set as default browser. %S is brandShortName
+onboarding.tour-default-browser.is-default.2nd-message=%S is already your default browser.
 # LOCALIZATION NOTE(onboarding.notification.onboarding-tour-default-browser.title): This string will be used in the notification message for the default browser tour. %S is brandShortName.
 onboarding.notification.onboarding-tour-default-browser.title=Make %S your go-to browser.
 # LOCALIZATION NOTE(onboarding.notification.onboarding-tour-default-browser.message): %1$S is brandShortName
 onboarding.notification.onboarding-tour-default-browser.message=It doesn’t take much to get the most from %1$S. Just set %1$S as your default browser and put control, customization, and protection on autopilot.
 
 onboarding.tour-sync2=Sync
 onboarding.tour-sync.title2=Pick up where you left off.
 onboarding.tour-sync.description2=Sync makes it easy to access bookmarks, passwords, and even open tabs on all your devices. Sync also gives you control of the types of information you want, and don’t want, to share.