Bug 1562328 - Hook up the enable and options Sync buttons to their respective sites. r=MattN,lina
authorJared Wein <jwein@mozilla.com>
Tue, 30 Jul 2019 22:44:27 +0000
changeset 485428 9f2e60fb1dcd5761c71b91f9050d8f367ebea52b
parent 485427 bdc4220a693057614ba1ab251d88ff5994832848
child 485429 11de4b3dec2b4730c34f90a6f53c7cd9f5c18597
push id36366
push usermalexandru@mozilla.com
push dateWed, 31 Jul 2019 09:48:07 +0000
treeherdermozilla-central@968808feda5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, lina
bugs1562328
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 1562328 - Hook up the enable and options Sync buttons to their respective sites. r=MattN,lina Differential Revision: https://phabricator.services.mozilla.com/D38736
browser/components/BrowserGlue.jsm
browser/components/aboutlogins/AboutLoginsChild.jsm
browser/components/aboutlogins/AboutLoginsParent.jsm
browser/components/aboutlogins/content/components/fxaccounts-button.js
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -131,16 +131,18 @@ let LEGACY_ACTORS = {
         AboutLoginsInit: { wantUntrusted: true },
         AboutLoginsOpenFAQ: { wantUntrusted: true },
         AboutLoginsOpenFeedback: { wantUntrusted: true },
         AboutLoginsOpenMobileAndroid: { wantUntrusted: true },
         AboutLoginsOpenMobileIos: { wantUntrusted: true },
         AboutLoginsOpenPreferences: { wantUntrusted: true },
         AboutLoginsOpenSite: { wantUntrusted: true },
         AboutLoginsRecordTelemetryEvent: { wantUntrusted: true },
+        AboutLoginsSyncEnable: { wantUntrusted: true },
+        AboutLoginsSyncOptions: { wantUntrusted: true },
         AboutLoginsUpdateLogin: { wantUntrusted: true },
       },
       messages: [
         "AboutLogins:AllLogins",
         "AboutLogins:LoginAdded",
         "AboutLogins:LoginModified",
         "AboutLogins:LoginRemoved",
         "AboutLogins:MasterPasswordResponse",
@@ -627,16 +629,18 @@ const listeners = {
     "AboutLogins:MasterPasswordRequest": ["AboutLoginsParent"],
     "AboutLogins:OpenFAQ": ["AboutLoginsParent"],
     "AboutLogins:OpenFeedback": ["AboutLoginsParent"],
     "AboutLogins:OpenPreferences": ["AboutLoginsParent"],
     "AboutLogins:OpenMobileAndroid": ["AboutLoginsParent"],
     "AboutLogins:OpenMobileIos": ["AboutLoginsParent"],
     "AboutLogins:OpenSite": ["AboutLoginsParent"],
     "AboutLogins:Subscribe": ["AboutLoginsParent"],
+    "AboutLogins:SyncEnable": ["AboutLoginsParent"],
+    "AboutLogins:SyncOptions": ["AboutLoginsParent"],
     "AboutLogins:UpdateLogin": ["AboutLoginsParent"],
     "Content:Click": ["ContentClick"],
     ContentSearch: ["ContentSearch"],
     "FormValidation:ShowPopup": ["FormValidationHandler"],
     "FormValidation:HidePopup": ["FormValidationHandler"],
     "PictureInPicture:Request": ["PictureInPicture"],
     "PictureInPicture:Close": ["PictureInPicture"],
     "PictureInPicture:Playing": ["PictureInPicture"],
--- a/browser/components/aboutlogins/AboutLoginsChild.jsm
+++ b/browser/components/aboutlogins/AboutLoginsChild.jsm
@@ -127,16 +127,24 @@ class AboutLoginsChild extends ActorChil
           );
         } catch (ex) {
           Cu.reportError(
             "AboutLoginsChild: error recording telemetry event: " + ex.message
           );
         }
         break;
       }
+      case "AboutLoginsSyncEnable": {
+        this.mm.sendAsyncMessage("AboutLogins:SyncEnable");
+        break;
+      }
+      case "AboutLoginsSyncOptions": {
+        this.mm.sendAsyncMessage("AboutLogins:SyncOptions");
+        break;
+      }
       case "AboutLoginsUpdateLogin": {
         this.mm.sendAsyncMessage("AboutLogins:UpdateLogin", {
           login: event.detail,
         });
         break;
       }
     }
   }
--- a/browser/components/aboutlogins/AboutLoginsParent.jsm
+++ b/browser/components/aboutlogins/AboutLoginsParent.jsm
@@ -111,16 +111,26 @@ var AboutLoginsParent = {
         Services.logins.addLogin(LoginHelper.vanillaObjectToLogin(newLogin));
         break;
       }
       case "AboutLogins:DeleteLogin": {
         let login = LoginHelper.vanillaObjectToLogin(message.data.login);
         Services.logins.removeLogin(login);
         break;
       }
+      case "AboutLogins:SyncEnable": {
+        message.target.ownerGlobal.gSync.openFxAEmailFirstPage(
+          "password-manager"
+        );
+        break;
+      }
+      case "AboutLogins:SyncOptions": {
+        message.target.ownerGlobal.gSync.openFxAManagePage("password-manager");
+        break;
+      }
       case "AboutLogins:Import": {
         try {
           MigrationUtils.showMigrationWizard(message.target.ownerGlobal, [
             MigrationUtils.MIGRATION_ENTRYPOINT_PASSWORDS,
           ]);
         } catch (ex) {
           Cu.reportError(ex);
         }
@@ -241,30 +251,32 @@ 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 (!BREACH_ALERTS_ENABLED) {
             return;
           }
 
           const breachesByLoginGUID = await LoginHelper.getBreachesForLogins(
             logins
           );
           messageManager.sendAsyncMessage(
             "AboutLogins:UpdateBreaches",
             breachesByLoginGUID
           );
-          let syncState = this.getSyncState();
-          messageManager.sendAsyncMessage("AboutLogins:SyncState", syncState);
-          this.updatePasswordSyncNotificationState();
         } catch (ex) {
           if (ex.result != Cr.NS_ERROR_NOT_INITIALIZED) {
             throw ex;
           }
 
           // The message manager may be destroyed before the replies can be sent.
           log.debug(
             "AboutLogins:Subscribe: exception when replying with logins",
--- a/browser/components/aboutlogins/content/components/fxaccounts-button.js
+++ b/browser/components/aboutlogins/content/components/fxaccounts-button.js
@@ -15,19 +15,40 @@ export default class FxAccountsButton ex
 
     this._avatarButton = shadowRoot.querySelector(".fxaccounts-avatar-button");
     this._extraText = shadowRoot.querySelector(".fxaccounts-extra-text");
     this._enableButton = shadowRoot.querySelector(".fxaccounts-enable-button");
     this._loggedOutView = shadowRoot.querySelector(".logged-out-view");
     this._loggedInView = shadowRoot.querySelector(".logged-in-view");
     this._emailText = shadowRoot.querySelector(".fxaccount-email");
 
+    this._avatarButton.addEventListener("click", this);
+    this._enableButton.addEventListener("click", this);
+
     this.render();
   }
 
+  handleEvent(event) {
+    if (event.target == this._avatarButton) {
+      document.dispatchEvent(
+        new CustomEvent("AboutLoginsSyncOptions", {
+          bubbles: true,
+        })
+      );
+      return;
+    }
+    if (event.target == this._enableButton) {
+      document.dispatchEvent(
+        new CustomEvent("AboutLoginsSyncEnable", {
+          bubbles: true,
+        })
+      );
+    }
+  }
+
   render() {
     this._loggedOutView.hidden = !!this._loggedIn;
     this._loggedInView.hidden = !this._loggedIn;
     this._emailText.textContent = this._email;
     this._avatarButton.style.setProperty(
       "--avatar-url",
       `url(${this._avatarURL})`
     );