Bug 1096343 - Use a different sync link in dev edition main preferences. r=markh
authorEdouard Oger <eoger@fastmail.com>
Thu, 30 Mar 2017 15:59:09 +0100
changeset 350593 94c77723eead52385404ff82bd4221000bfbe937
parent 350592 1765f0af5161deaedc07361edf8567d5c8a13eff
child 350594 4f579b19145a4c2c13355d206427d88e4cfb68ba
push id39864
push usereoger@mozilla.com
push dateThu, 30 Mar 2017 23:49:35 +0000
treeherderautoland@94c77723eead [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1096343
milestone55.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 1096343 - Use a different sync link in dev edition main preferences. r=markh MozReview-Commit-ID: BPGSVN2EQza
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/main.xul
browser/locales/en-US/chrome/browser/preferences/main.dtd
--- 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.notlogged.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/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.notlogged.label       "Sign in to &syncBrand.shortName.label;…">
+<!ENTITY getStarted.configured.label      "Open &syncBrand.shortName.label; preferences">
 
 <!ENTITY e10sEnabled.label                "Enable multi-process &brandShortName;">