Bug 1575955: Hide "Sign in to Sync" button when Sync is disabled. r=jaws
authorlesley <lnorton@mozilla.com>
Tue, 27 Aug 2019 17:48:03 +0000
changeset 554020 9be49e3e9e296114be312d811d4f487951f81e0b
parent 554019 dd2e31e2f8338efa493a66821a2be11090048b3a
child 554021 b7d1b3ab0fb53cfed87544b46538241dae4eb181
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1575955
milestone70.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 1575955: Hide "Sign in to Sync" button when Sync is disabled. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D43508
browser/components/aboutlogins/AboutLoginsParent.jsm
browser/components/aboutlogins/content/aboutLogins.html
browser/components/aboutlogins/content/components/fxaccounts-button.js
browser/components/aboutlogins/tests/chrome/chrome.ini
--- a/browser/components/aboutlogins/AboutLoginsParent.jsm
+++ b/browser/components/aboutlogins/AboutLoginsParent.jsm
@@ -45,16 +45,22 @@ XPCOMUtils.defineLazyGetter(this, "log",
   return LoginHelper.createLogger("AboutLoginsParent");
 });
 XPCOMUtils.defineLazyPreferenceGetter(
   this,
   "BREACH_ALERTS_ENABLED",
   "signon.management.page.breach-alerts.enabled",
   false
 );
+XPCOMUtils.defineLazyPreferenceGetter(
+  this,
+  "FXA_ENABLED",
+  "identity.fxaccounts.enabled",
+  false
+);
 
 const ABOUT_LOGINS_ORIGIN = "about:logins";
 const MASTER_PASSWORD_NOTIFICATION_ID = "master-password-login-required";
 const PASSWORD_SYNC_NOTIFICATION_ID = "enable-password-sync";
 
 const HIDE_MOBILE_FOOTER_PREF = "signon.management.page.hideMobileFooter";
 
 // about:logins will always use the privileged content process,
@@ -282,19 +288,21 @@ var AboutLoginsParent = {
         this._subscribers.add(message.target);
 
         let messageManager = message.target.messageManager;
 
         const logins = await this.getAllLogins();
         try {
           messageManager.sendAsyncMessage("AboutLogins:AllLogins", logins);
 
-          let syncState = this.getSyncState();
-          messageManager.sendAsyncMessage("AboutLogins:SyncState", syncState);
-          this.updatePasswordSyncNotificationState();
+          if (FXA_ENABLED) {
+            let syncState = this.getSyncState();
+            messageManager.sendAsyncMessage("AboutLogins:SyncState", syncState);
+            this.updatePasswordSyncNotificationState();
+          }
 
           // App store badges sourced from https://developer.apple.com/app-store/marketing/guidelines/#section-badges.
           // This array mirrors the file names from the App store directory (./content/third-party/app-store)
           const appStoreLocales = [
             "az",
             "ar",
             "bg",
             "cs",
--- a/browser/components/aboutlogins/content/aboutLogins.html
+++ b/browser/components/aboutlogins/content/aboutLogins.html
@@ -26,17 +26,17 @@
     <link rel="stylesheet" href="chrome://browser/content/aboutlogins/aboutLogins.css">
     <link rel="stylesheet" href="chrome://browser/content/aboutlogins/common.css">
     <link rel="icon" href="chrome://browser/content/aboutlogins/icons/favicon.svg">
   </head>
   <body>
     <header>
       <img id="branding-logo" src="chrome://branding/content/aboutlogins.svg" alt=""/>
       <login-filter></login-filter>
-      <fxaccounts-button></fxaccounts-button>
+      <fxaccounts-button hidden></fxaccounts-button>
       <menu-button></menu-button>
     </header>
     <login-list></login-list>
     <login-item></login-item>
     <login-intro></login-intro>
     <confirmation-dialog hidden></confirmation-dialog>
 
     <template id="confirmation-dialog-template">
--- a/browser/components/aboutlogins/content/components/fxaccounts-button.js
+++ b/browser/components/aboutlogins/content/components/fxaccounts-button.js
@@ -2,17 +2,16 @@
  * 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/. */
 
 export default class FxAccountsButton extends HTMLElement {
   connectedCallback() {
     if (this.shadowRoot) {
       return;
     }
-
     let template = document.querySelector("#fxaccounts-button-template");
     let shadowRoot = this.attachShadow({ mode: "open" });
     document.l10n.connectRoot(shadowRoot);
     shadowRoot.appendChild(template.content.cloneNode(true));
 
     this._avatarButton = shadowRoot.querySelector(".fxaccounts-avatar-button");
     this._extraText = shadowRoot.querySelector(".fxaccounts-extra-text");
     this._enableButton = shadowRoot.querySelector(".fxaccounts-enable-button");
@@ -60,16 +59,17 @@ export default class FxAccountsButton ex
    *                   loggedIn: {Boolean} FxAccount authentication
    *                             status.
    *                   email: {String} Email address used with FxAccount. Must
    *                          be empty if `loggedIn` is false.
    *                   avatarURL: {String} URL of account avatar. Must
    *                              be empty if `loggedIn` is false.
    */
   updateState(state) {
+    this.hidden = false;
     this._loggedIn = state.loggedIn;
     this._email = state.email;
     this._avatarURL = state.avatarURL;
 
     this.render();
   }
 }
 customElements.define("fxaccounts-button", FxAccountsButton);
--- a/browser/components/aboutlogins/tests/chrome/chrome.ini
+++ b/browser/components/aboutlogins/tests/chrome/chrome.ini
@@ -1,10 +1,12 @@
 [DEFAULT]
 scheme = https
+prefs =
+   identity.fxaccounts.enabled=true
 support-files =
    aboutlogins_common.js
 
 [test_confirm_delete_dialog.html]
 [test_fxaccounts_button.html]
 [test_login_filter.html]
 [test_login_item.html]
 [test_login_list.html]