Bug 1296767 part 12 - Remove Weave.fxAccountsEnabled. r?markh draft
authorEdouard Oger <eoger@fastmail.com>
Thu, 19 Jan 2017 14:53:37 -0500
changeset 467372 6ed20f1bc916c7ab76758088b3d3cef54b4fb415
parent 467371 4e3485eb0d831b3f43a04f955dc082a513b3dfb7
child 467373 9b6c53ddd2cb0dd56f4ce4dbbc070c9d6ce36111
push id43155
push userbmo:eoger@fastmail.com
push dateFri, 27 Jan 2017 18:31:15 +0000
reviewersmarkh
bugs1296767
milestone54.0a1
Bug 1296767 part 12 - Remove Weave.fxAccountsEnabled. r?markh MozReview-Commit-ID: L4dM9xN2ELp
browser/base/content/browser-fxaccounts.js
browser/base/content/browser-syncui.js
services/sync/Weave.js
services/sync/tps/extensions/tps/resource/auth/sync.jsm
services/sync/tps/extensions/tps/resource/tps.jsm
--- a/browser/base/content/browser-fxaccounts.js
+++ b/browser/base/content/browser-fxaccounts.js
@@ -156,21 +156,16 @@ var gFxAccounts = {
 
   // Note that updateUI() returns a Promise that's only used by tests.
   updateUI() {
     let profileInfoEnabled = false;
     try {
       profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled");
     } catch (e) { }
 
-    // Bail out if FxA is disabled.
-    if (!this.weave.fxAccountsEnabled) {
-      return Promise.resolve();
-    }
-
     this.panelUIFooter.hidden = false;
 
     // Make sure the button is disabled in customization mode.
     if (this._inCustomizationMode) {
       this.panelUIStatus.setAttribute("disabled", "true");
       this.panelUILabel.setAttribute("disabled", "true");
       this.panelUIAvatar.setAttribute("disabled", "true");
       this.panelUIIcon.setAttribute("disabled", "true");
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -92,51 +92,32 @@ var gSyncUI = {
 
     this.updateUI();
   },
 
 
   // Returns a promise that resolves with true if Sync needs to be configured,
   // false otherwise.
   _needsSetup() {
-    // If Sync is configured for FxAccounts then we do that promise-dance.
-    if (this.weaveService.fxAccountsEnabled) {
-      return fxAccounts.getSignedInUser().then(user => {
-        // We want to treat "account needs verification" as "needs setup".
-        return !(user && user.verified);
-      });
-    }
-    // We are using legacy sync - check that.
-    let firstSync = "";
-    try {
-      firstSync = Services.prefs.getCharPref("services.sync.firstSync");
-    } catch (e) { }
-
-    return Promise.resolve(Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
-                           firstSync == "notReady");
+    return fxAccounts.getSignedInUser().then(user => {
+      // We want to treat "account needs verification" as "needs setup".
+      return !(user && user.verified);
+    });
   },
 
   // Returns a promise that resolves with true if the user currently signed in
   // to Sync needs to be verified, false otherwise.
   _needsVerification() {
-    // For callers who care about the distinction between "needs setup" and
-    // "needs verification"
-    if (this.weaveService.fxAccountsEnabled) {
-      return fxAccounts.getSignedInUser().then(user => {
-        // If there is no user, they can't be in a "needs verification" state.
-        if (!user) {
-          return false;
-        }
-        return !user.verified;
-      });
-    }
-
-    // Otherwise we are configured for legacy Sync, which has no verification
-    // concept.
-    return Promise.resolve(false);
+    return fxAccounts.getSignedInUser().then(user => {
+      // If there is no user, they can't be in a "needs verification" state.
+      if (!user) {
+        return false;
+      }
+      return !user.verified;
+    });
   },
 
   // Note that we don't show login errors in a notification bar here, but do
   // still need to track a login-failed state so the "Tools" menu updates
   // with the correct state.
   loginFailed() {
     // If Sync isn't already ready, we don't want to force it to initialize
     // by referencing Weave.Status - and it isn't going to be accurate before
--- a/services/sync/Weave.js
+++ b/services/sync/Weave.js
@@ -88,27 +88,16 @@ WeaveService.prototype = {
       Services.obs.removeObserver(onReady, "weave:service:ready");
       deferred.resolve();
     }, "weave:service:ready", false);
     this.ensureLoaded();
     return deferred.promise;
   },
 
   /**
-   * Whether Firefox Accounts is enabled.
-   *
-   * @return bool
-   */
-  // TODO - Remove this getter and all accessors
-  get fxAccountsEnabled() {
-    // Always return true.
-    return true;
-  },
-
-  /**
    * Whether Sync appears to be enabled.
    *
    * This returns true if we have an associated FxA account
    *
    * It does *not* perform a robust check to see if the client is working.
    * For that, you'll want to check Weave.Status.checkSetup().
    */
   get enabled() {
deleted file mode 100644
--- a/services/sync/tps/extensions/tps/resource/auth/sync.jsm
+++ /dev/null
@@ -1,88 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = [
-  "Authentication",
-];
-
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-Cu.import("resource://services-sync/main.js");
-Cu.import("resource://tps/logger.jsm");
-
-
-/**
- * Helper object for deprecated Firefox Sync authentication
- */
-var Authentication = {
-
-  /**
-   * Check if an user has been logged in
-   */
-  get isLoggedIn() {
-    return !!this.getSignedInUser();
-  },
-
-  /**
-   * Wrapper to retrieve the currently signed in user
-   *
-   * @returns Information about the currently signed in user
-   */
-  getSignedInUser: function getSignedInUser() {
-    let user = null;
-
-    if (Weave.Service.isLoggedIn) {
-      user = {
-        email: Weave.Service.identity.account,
-        password: Weave.Service.identity.basicPassword,
-        passphrase: Weave.Service.identity.syncKey
-      };
-    }
-
-    return user;
-  },
-
-  /**
-   * Wrapper to synchronize the login of a user
-   *
-   * @param account
-   *        Account information of the user to login
-   * @param account.username
-   *        The username for the account (utf8)
-   * @param account.password
-   *        The user's password
-   * @param account.passphrase
-   *        The users's passphrase
-   */
-  signIn: function signIn(account) {
-    Logger.AssertTrue(account["username"], "Username has been found");
-    Logger.AssertTrue(account["password"], "Password has been found");
-    Logger.AssertTrue(account["passphrase"], "Passphrase has been found");
-
-    Logger.logInfo("Logging in user: " + account["username"]);
-
-    Weave.Service.identity.account = account["username"];
-    Weave.Service.identity.basicPassword = account["password"];
-    Weave.Service.identity.syncKey = account["passphrase"];
-
-    if (Weave.Status.login !== Weave.LOGIN_SUCCEEDED) {
-      Logger.logInfo("Logging into Weave.");
-      Weave.Service.login();
-      Logger.AssertEqual(Weave.Status.login, Weave.LOGIN_SUCCEEDED,
-                         "Weave logged in");
-
-      // Bug 997279: Temporary workaround until we can ensure that Sync itself
-      // sends this notification for the first login attempt by TPS
-      Weave.Svc.Obs.notify("weave:service:setup-complete");
-    }
-
-    return true;
-  },
-
-  signOut() {
-    Weave.Service.logout();
-  }
-};
--- a/services/sync/tps/extensions/tps/resource/tps.jsm
+++ b/services/sync/tps/extensions/tps/resource/tps.jsm
@@ -124,36 +124,25 @@ var TPS = {
   _usSinceEpoch: 0,
   _requestedQuit: false,
   shouldValidateAddons: false,
   shouldValidateBookmarks: false,
   shouldValidatePasswords: false,
   shouldValidateForms: false,
 
   _init: function TPS__init() {
-    // Check if Firefox Accounts is enabled
-    let service = Cc["@mozilla.org/weave/service;1"]
-                  .getService(Components.interfaces.nsISupports)
-                  .wrappedJSObject;
-    this.fxaccounts_enabled = service.fxAccountsEnabled;
-
     this.delayAutoSync();
 
     OBSERVER_TOPICS.forEach(function(aTopic) {
       Services.obs.addObserver(this, aTopic, true);
     }, this);
 
     // Configure some logging prefs for Sync itself.
     Weave.Svc.Prefs.set("log.appender.dump", "Debug");
-    // Import the appropriate authentication module
-    if (this.fxaccounts_enabled) {
-      Cu.import("resource://tps/auth/fxaccounts.jsm", module);
-    } else {
-      Cu.import("resource://tps/auth/sync.jsm", module);
-    }
+    Cu.import("resource://tps/auth/fxaccounts.jsm", module);
   },
 
   DumpError(msg, exc = null) {
     this._errors++;
     let errInfo;
     if (exc) {
       errInfo = Log.exceptionStr(exc); // includes details and stack-trace.
     } else {
@@ -855,17 +844,16 @@ var TPS = {
       let settings = options || {};
 
       Logger.init(logpath);
       Logger.logInfo("Sync version: " + WEAVE_VERSION);
       Logger.logInfo("Firefox buildid: " + Services.appinfo.appBuildID);
       Logger.logInfo("Firefox version: " + Services.appinfo.version);
       Logger.logInfo("Firefox source revision: " + (AppConstants.SOURCE_REVISION_URL || "unknown"));
       Logger.logInfo("Firefox platform: " + AppConstants.platform);
-      Logger.logInfo("Firefox Accounts enabled: " + this.fxaccounts_enabled);
 
       // do some sync housekeeping
       if (Weave.Service.isLoggedIn) {
         this.DumpError("Sync logged in on startup...profile may be dirty");
         return;
       }
 
       // Wait for Sync service to become ready.
@@ -1131,28 +1119,23 @@ var TPS = {
    * Login on the server
    */
   Login: function Login(force) {
     if (Authentication.isLoggedIn && !force) {
       return;
     }
 
     Logger.logInfo("Setting client credentials and login.");
-    let account = this.fxaccounts_enabled ? this.config.fx_account
-                                          : this.config.sync_account;
-    Authentication.signIn(account);
+    Authentication.signIn(this.config.fx_account);
     this.waitForSetupComplete();
     Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK");
     this.waitForTracking();
-    // If fxaccounts is enabled we get an initial sync at login time - let
-    // that complete.
-    if (this.fxaccounts_enabled) {
-      this._triggeredSync = true;
-      this.waitForSyncFinished();
-    }
+    // We get an initial sync at login time - let that complete.
+    this._triggeredSync = true;
+    this.waitForSyncFinished();
   },
 
   /**
    * Triggers a sync operation
    *
    * @param {String} [wipeAction]
    *        Type of wipe to perform (resetClient, wipeClient, wipeRemote)
    *