Bug 1096343 - Use a different sync link in dev edition main preferences. r?jaws draft
authorEdouard Oger <eoger@fastmail.com>
Thu, 30 Mar 2017 15:59:09 +0100
changeset 554711 d07c4b1ef138241454975ecf0a164f26e852da04
parent 554710 7a3f514cf8490d271ee373a1d2999e4ea4dee2d7
child 622417 cbc478e51a925e46c02ced4612b70ff094c36d03
push id52027
push userbmo:eoger@fastmail.com
push dateSat, 01 Apr 2017 18:13:05 +0000
reviewersjaws
bugs1096343
milestone55.0a1
Bug 1096343 - Use a different sync link in dev edition main preferences. r?jaws MozReview-Commit-ID: BPGSVN2EQza
browser/components/preferences/in-content-old/main.js
browser/components/preferences/in-content-old/main.xul
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/main.xul
browser/locales/en-US/chrome/browser/preferences-old/main.dtd
browser/locales/en-US/chrome/browser/preferences/main.dtd
--- a/browser/components/preferences/in-content-old/main.js
+++ b/browser/components/preferences/in-content-old/main.js
@@ -13,16 +13,21 @@ Components.utils.import("resource:///mod
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 
 if (AppConstants.E10S_TESTING_ONLY) {
   XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
                                     "resource://gre/modules/UpdateUtils.jsm");
 }
 
+if (AppConstants.MOZ_DEV_EDITION) {
+  XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts",
+                                    "resource://gre/modules/FxAccounts.jsm");
+}
+
 var gMainPane = {
   /**
    * Initialization of this.
    */
   init() {
     function setEventListener(aId, aEventType, aCallback) {
       document.getElementById(aId)
               .addEventListener(aEventType, aCallback.bind(gMainPane));
@@ -108,16 +113,20 @@ var gMainPane = {
       let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
 
       setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
       let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
       setEventListener("getStarted", "click", gMainPane.onGetStarted);
 
       OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
                                                () => separateProfileModeCheckbox.checked = true);
+
+      fxAccounts.getSignedInUser().then(data => {
+        document.getElementById("getStarted").selectedIndex = data ? 1 : 0;
+      });
     }
 
     // Notify observers that the UI is now ready
     Components.classes["@mozilla.org/observer-service;1"]
               .getService(Components.interfaces.nsIObserverService)
               .notifyObservers(window, "main-pane-loaded", null);
   },
 
@@ -205,20 +214,27 @@ var gMainPane = {
 
   onGetStarted(aEvent) {
     if (AppConstants.MOZ_DEV_EDITION) {
       const Cc = Components.classes, Ci = Components.interfaces;
       let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
                   .getService(Ci.nsIWindowMediator);
       let win = wm.getMostRecentWindow("navigator:browser");
 
-      if (win) {
-        let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
-        win.gBrowser.selectedTab = accountsTab;
-      }
+      fxAccounts.getSignedInUser().then(data => {
+        if (win) {
+          if (data) {
+            // We have a user, open Sync preferences in the same tab
+            win.openUILinkIn("about:preferences#sync", "current");
+            return;
+          }
+          let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
+          win.gBrowser.selectedTab = accountsTab;
+        }
+      });
     }
   },
 
   // HOME PAGE
 
   /*
    * Preferences:
    *
--- a/browser/components/preferences/in-content-old/main.xul
+++ b/browser/components/preferences/in-content-old/main.xul
@@ -125,17 +125,20 @@
   <caption><label>&startup.label;</label></caption>
 
 #ifdef MOZ_DEV_EDITION
   <vbox id="separateProfileBox">
     <checkbox id="separateProfileMode"
               label="&separateProfileMode.label;"/>
     <hbox align="center" class="indent">
       <label id="useFirefoxSync">&useFirefoxSync.label;</label>
-      <label id="getStarted" class="text-link">&getStarted.label;</label>
+      <deck id="getStarted">
+        <label class="text-link">&getStarted.notloggedin.label;</label>
+        <label class="text-link">&getStarted.configured.label;</label>
+      </deck>
     </hbox>
   </vbox>
 #endif
 
 #ifdef E10S_TESTING_ONLY
   <checkbox id="e10sAutoStart"
             label="&e10sEnabled.label;"/>
 #endif
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -13,19 +13,25 @@ Components.utils.import("resource:///mod
 
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 
 if (AppConstants.E10S_TESTING_ONLY) {
   XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
                                     "resource://gre/modules/UpdateUtils.jsm");
 }
+
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
                                   "resource://gre/modules/PlacesUtils.jsm");
 
+if (AppConstants.MOZ_DEV_EDITION) {
+  XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts",
+                                    "resource://gre/modules/FxAccounts.jsm");
+}
+
 const ENGINE_FLAVOR = "text/x-moz-search-engine";
 
 var gEngineView = null;
 
 var gMainPane = {
   /**
    * Initialize autocomplete to ensure prefs are in sync.
    */
@@ -180,16 +186,21 @@ var gMainPane = {
       let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
 
       setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
       let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
       setEventListener("getStarted", "click", gMainPane.onGetStarted);
 
       OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
                                                () => separateProfileModeCheckbox.checked = true);
+
+      fxAccounts.getSignedInUser().then(data => {
+        document.getElementById("getStarted").selectedIndex = data ? 1 : 0;
+      })
+      .catch(Cu.reportError);
     }
 
     // Notify observers that the UI is now ready
     Components.classes["@mozilla.org/observer-service;1"]
               .getService(Components.interfaces.nsIObserverService)
               .notifyObservers(window, "main-pane-loaded", null);
   },
 
@@ -277,20 +288,27 @@ var gMainPane = {
 
   onGetStarted(aEvent) {
     if (AppConstants.MOZ_DEV_EDITION) {
       const Cc = Components.classes, Ci = Components.interfaces;
       let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
                   .getService(Ci.nsIWindowMediator);
       let win = wm.getMostRecentWindow("navigator:browser");
 
-      if (win) {
-        let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
-        win.gBrowser.selectedTab = accountsTab;
-      }
+      fxAccounts.getSignedInUser().then(data => {
+        if (win) {
+          if (data) {
+            // We have a user, open Sync preferences in the same tab
+            win.openUILinkIn("about:preferences#sync", "current");
+            return;
+          }
+          let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
+          win.gBrowser.selectedTab = accountsTab;
+        }
+      });
     }
   },
 
   // HOME PAGE
 
   /*
    * Preferences:
    *
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -197,17 +197,20 @@
   <caption><label>&startup.label;</label></caption>
 
 #ifdef MOZ_DEV_EDITION
   <vbox id="separateProfileBox">
     <checkbox id="separateProfileMode"
               label="&separateProfileMode.label;"/>
     <hbox align="center" class="indent">
       <label id="useFirefoxSync">&useFirefoxSync.label;</label>
-      <label id="getStarted" class="text-link">&getStarted.label;</label>
+      <deck id="getStarted">
+        <label class="text-link">&getStarted.notloggedin.label;</label>
+        <label class="text-link">&getStarted.configured.label;</label>
+      </deck>
     </hbox>
   </vbox>
 #endif
 
 #ifdef E10S_TESTING_ONLY
   <checkbox id="e10sAutoStart"
             label="&e10sEnabled.label;"/>
 #endif
--- a/browser/locales/en-US/chrome/browser/preferences-old/main.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences-old/main.dtd
@@ -35,11 +35,12 @@
 <!ENTITY alwaysCheckDefault2.accesskey    "y">
 <!ENTITY setAsMyDefaultBrowser2.label     "Make Default">
 <!ENTITY setAsMyDefaultBrowser2.accesskey "D">
 <!ENTITY isDefault.label                  "&brandShortName; is currently your default browser">
 <!ENTITY isNotDefault.label               "&brandShortName; is not your default browser">
 
 <!ENTITY separateProfileMode.label        "Allow &brandShortName; and Firefox to run at the same time">
 <!ENTITY useFirefoxSync.label             "Tip: This uses separate profiles. Use Sync to share data between them.">
-<!ENTITY getStarted.label                 "Start using Sync…">
+<!ENTITY getStarted.notloggedin.label     "Sign in to &syncBrand.shortName.label;…">
+<!ENTITY getStarted.configured.label      "Open &syncBrand.shortName.label; preferences">
 
 <!ENTITY e10sEnabled.label                "Enable multi-process &brandShortName;">
--- a/browser/locales/en-US/chrome/browser/preferences/main.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/main.dtd
@@ -35,11 +35,12 @@
 <!ENTITY alwaysCheckDefault2.accesskey    "y">
 <!ENTITY setAsMyDefaultBrowser2.label     "Make Default">
 <!ENTITY setAsMyDefaultBrowser2.accesskey "D">
 <!ENTITY isDefault.label                  "&brandShortName; is currently your default browser">
 <!ENTITY isNotDefault.label               "&brandShortName; is not your default browser">
 
 <!ENTITY separateProfileMode.label        "Allow &brandShortName; and Firefox to run at the same time">
 <!ENTITY useFirefoxSync.label             "Tip: This uses separate profiles. Use Sync to share data between them.">
-<!ENTITY getStarted.label                 "Start using Sync…">
+<!ENTITY getStarted.notloggedin.label     "Sign in to &syncBrand.shortName.label;…">
+<!ENTITY getStarted.configured.label      "Open &syncBrand.shortName.label; preferences">
 
 <!ENTITY e10sEnabled.label                "Enable multi-process &brandShortName;">