diff --git a/browser/base/content/browser-fxaccounts.js b/browser/base/content/browser-fxaccounts.js index e197dee23c6..1af53224851 100644 --- a/browser/base/content/browser-fxaccounts.js +++ b/browser/base/content/browser-fxaccounts.js @@ -10,11 +10,6 @@ var gFxAccounts = { _initialized: false, _inCustomizationMode: false, - // _expectingNotifyClose is a hack that helps us determine if the - // migration notification was closed due to being "dismissed" vs closed - // due to one of the migration buttons being clicked. It's ugly and somewhat - // fragile, so bug 1119020 exists to help us do this better. - _expectingNotifyClose: false, get weave() { delete this.weave; @@ -36,7 +31,6 @@ var gFxAccounts = { this.FxAccountsCommon.ONLOGIN_NOTIFICATION, this.FxAccountsCommon.ONVERIFIED_NOTIFICATION, this.FxAccountsCommon.ONLOGOUT_NOTIFICATION, - "weave:notification:removed", this.FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION, ]; }, @@ -107,10 +101,6 @@ var gFxAccounts = { gNavToolbox.addEventListener("customizationstarting", this); gNavToolbox.addEventListener("customizationending", this); - // Request the current Legacy-Sync-to-FxA migration status. We'll be - // notified of fxa-migration:state-changed in response if necessary. - Services.obs.notifyObservers(null, "fxa-migration:state-request", null); - EnsureFxAccountsWebChannel(); this._initialized = true; @@ -140,16 +130,6 @@ var gFxAccounts = { case "fxa-migration:state-changed": this.onMigrationStateChanged(data, subject); break; - case "weave:notification:removed": - // this exists just so we can tell the difference between "box was - // closed due to button press" vs "was closed due to click on [x]" - let notif = subject.wrappedJSObject.object; - if (notif.title == this.SYNC_MIGRATION_NOTIFICATION_TITLE && - !this._expectingNotifyClose) { - // it's an [x] on our notification, so record telemetry. - this.fxaMigrator.recordTelemetry(this.fxaMigrator.TELEMETRY_DECLINED); - } - break; case this.FxAccountsCommon.ONPROFILE_IMAGE_CHANGE_NOTIFICATION: this.updateUI(); break; @@ -176,12 +156,25 @@ var gFxAccounts = { } }, - onMigrationStateChanged: function (newState, email) { - this._migrationInfo = !newState ? null : { - state: newState, - email: email ? email.QueryInterface(Ci.nsISupportsString).data : null, - }; - this.updateUI(); + onMigrationStateChanged: function () { + // Since we nuked most of the migration code, this notification will fire + // once after legacy Sync has been disconnected (and should never fire + // again) + let msg = this.strings.GetStringFromName("autoDisconnectDescription") + let signInLabel = this.strings.GetStringFromName("autoDisconnectSignIn.label"); + let signInAccessKey = this.strings.GetStringFromName("autoDisconnectSignIn.accessKey"); + let learnMoreLink = this.fxaMigrator.learnMoreLink; + let note = new Weave.Notification( + undefined, msg, undefined, Weave.Notifications.PRIORITY_WARNING, [ + new Weave.NotificationButton(signInLabel, signInAccessKey, () => { + this.openPreferences(); + }), + ], learnMoreLink + ); + note.title = this.SYNC_MIGRATION_NOTIFICATION_TITLE; + Weave.Notifications.replaceTitle(note); + // ensure the hamburger menu reflects the newly disconnected state. + this.updateAppMenuItem(); }, handleEvent: function (event) { @@ -215,17 +208,15 @@ var gFxAccounts = { }, updateUI: function () { + // It's possible someone signed in to FxA after seeing our notification + // about "Legacy Sync migration" (which now is actually "Legacy Sync + // auto-disconnect") so kill that notification if it still exists. + Weave.Notifications.removeAll(this.SYNC_MIGRATION_NOTIFICATION_TITLE); this.updateAppMenuItem(); - this.updateMigrationNotification(); }, // Note that updateAppMenuItem() returns a Promise that's only used by tests. updateAppMenuItem: function () { - if (this._migrationInfo) { - this.updateAppMenuItemForMigration(); - return Promise.resolve(); - } - let profileInfoEnabled = false; try { profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled"); @@ -233,12 +224,6 @@ var gFxAccounts = { // Bail out if FxA is disabled. if (!this.weave.fxAccountsEnabled) { - // When migration transitions from needs-verification to the null state, - // fxAccountsEnabled is false because migration has not yet finished. In - // that case, hide the button. We'll get another notification with a null - // state once migration is complete. - this.panelUIFooter.hidden = true; - this.panelUIFooter.removeAttribute("fxastatus"); return Promise.resolve(); } @@ -358,90 +343,6 @@ var gFxAccounts = { }); }, - updateAppMenuItemForMigration: Task.async(function* () { - let status = null; - let label = null; - switch (this._migrationInfo.state) { - case this.fxaMigrator.STATE_USER_FXA: - status = "migrate-signup"; - label = this.strings.formatStringFromName("needUserShort", - [this.panelUILabel.getAttribute("fxabrandname")], 1); - break; - case this.fxaMigrator.STATE_USER_FXA_VERIFIED: - status = "migrate-verify"; - label = this.strings.formatStringFromName("needVerifiedUserShort", - [this._migrationInfo.email], - 1); - break; - } - this.panelUILabel.label = label; - this.panelUIFooter.setAttribute("fxastatus", status); - }), - - updateMigrationNotification: Task.async(function* () { - if (!this._migrationInfo) { - this._expectingNotifyClose = true; - Weave.Notifications.removeAll(this.SYNC_MIGRATION_NOTIFICATION_TITLE); - // because this is called even when there is no such notification, we - // set _expectingNotifyClose back to false as we may yet create a new - // notification (but in general, once we've created a migration - // notification once in a session, we don't create one again) - this._expectingNotifyClose = false; - return; - } - let note = null; - switch (this._migrationInfo.state) { - case this.fxaMigrator.STATE_USER_FXA: { - // There are 2 cases here - no email address means it is an offer on - // the first device (so the user is prompted to create an account). - // If there is an email address it is the "join the party" flow, so the - // user is prompted to sign in with the address they previously used. - let msg, upgradeLabel, upgradeAccessKey, learnMoreLink; - if (this._migrationInfo.email) { - msg = this.strings.formatStringFromName("signInAfterUpgradeOnOtherDevice.description", - [this._migrationInfo.email], - 1); - upgradeLabel = this.strings.GetStringFromName("signInAfterUpgradeOnOtherDevice.label"); - upgradeAccessKey = this.strings.GetStringFromName("signInAfterUpgradeOnOtherDevice.accessKey"); - } else { - msg = this.strings.GetStringFromName("needUserLong"); - upgradeLabel = this.strings.GetStringFromName("upgradeToFxA.label"); - upgradeAccessKey = this.strings.GetStringFromName("upgradeToFxA.accessKey"); - learnMoreLink = this.fxaMigrator.learnMoreLink; - } - note = new Weave.Notification( - undefined, msg, undefined, Weave.Notifications.PRIORITY_WARNING, [ - new Weave.NotificationButton(upgradeLabel, upgradeAccessKey, () => { - this._expectingNotifyClose = true; - this.fxaMigrator.createFxAccount(window); - }), - ], learnMoreLink - ); - break; - } - case this.fxaMigrator.STATE_USER_FXA_VERIFIED: { - let msg = - this.strings.formatStringFromName("needVerifiedUserLong", - [this._migrationInfo.email], 1); - let resendLabel = - this.strings.GetStringFromName("resendVerificationEmail.label"); - let resendAccessKey = - this.strings.GetStringFromName("resendVerificationEmail.accessKey"); - note = new Weave.Notification( - undefined, msg, undefined, Weave.Notifications.PRIORITY_INFO, [ - new Weave.NotificationButton(resendLabel, resendAccessKey, () => { - this._expectingNotifyClose = true; - this.fxaMigrator.resendVerificationMail(); - }), - ] - ); - break; - } - } - note.title = this.SYNC_MIGRATION_NOTIFICATION_TITLE; - Weave.Notifications.replaceTitle(note); - }), - onMenuPanelCommand: function () { switch (this.panelUIFooter.getAttribute("fxastatus")) { @@ -455,12 +356,6 @@ var gFxAccounts = { this.openSignInAgainPage("menupanel"); } break; - case "migrate-signup": - case "migrate-verify": - // The migration flow calls for the menu item to open sync prefs rather - // than requesting migration start immediately. - this.openPreferences(); - break; default: this.openPreferences(); break; diff --git a/browser/components/preferences/in-content/sync.js b/browser/components/preferences/in-content/sync.js index d1b1e465b45..71d487a9e62 100644 --- a/browser/components/preferences/in-content/sync.js +++ b/browser/components/preferences/in-content/sync.js @@ -12,9 +12,6 @@ XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function () { XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts", "resource://gre/modules/FxAccounts.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "fxaMigrator", - "resource://services-sync/FxaMigrator.jsm"); - const PAGE_NO_ACCOUNT = 0; const PAGE_HAS_ACCOUNT = 1; const PAGE_NEEDS_UPDATE = 2; @@ -122,22 +119,17 @@ var gSyncPane = { FxAccountsCommon.ONLOGIN_NOTIFICATION, FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION, ]; - let migrateTopic = "fxa-migration:state-changed"; - // Add the observers now and remove them on unload //XXXzpao This should use Services.obs.* but Weave's Obs does nice handling // of `this`. Fix in a followup. (bug 583347) topics.forEach(function (topic) { Weave.Svc.Obs.add(topic, this.updateWeavePrefs, this); }, this); - // The FxA migration observer is a special case. - Weave.Svc.Obs.add(migrateTopic, this.updateMigrationState, this); window.addEventListener("unload", function() { topics.forEach(function (topic) { Weave.Svc.Obs.remove(topic, this.updateWeavePrefs, this); }, gSyncPane); - Weave.Svc.Obs.remove(migrateTopic, gSyncPane.updateMigrationState, gSyncPane); }, false); XPCOMUtils.defineLazyGetter(this, '_stringBundle', () => { @@ -194,7 +186,6 @@ var gSyncPane = { if (learnMoreLink) { learnMoreLink.parentNode.removeChild(learnMoreLink); } - document.getElementById("sync-migration-buttons-deck").hidden = true; }, _setupEventListeners: function() { @@ -292,20 +283,6 @@ var gSyncPane = { }); setEventListener("tosPP-small-ToS", "click", gSyncPane.openToS); setEventListener("tosPP-small-PP", "click", gSyncPane.openPrivacyPolicy); - setEventListener("sync-migrate-upgrade", "click", function () { - let win = Services.wm.getMostRecentWindow("navigator:browser"); - fxaMigrator.createFxAccount(win); - }); - setEventListener("sync-migrate-unlink", "click", function () { - gSyncPane.startOverMigration(); - }); - setEventListener("sync-migrate-forget", "click", function () { - fxaMigrator.forgetFxAccount(); - }); - setEventListener("sync-migrate-resend", "click", function () { - let win = Services.wm.getMostRecentWindow("navigator:browser"); - fxaMigrator.resendVerificationMail(win); - }); setEventListener("fxaSyncComputerName", "keypress", function (e) { if (e.keyCode == KeyEvent.DOM_VK_RETURN) { document.getElementById("fxaSaveChangeDeviceName").click(); @@ -324,12 +301,6 @@ var gSyncPane = { }, updateWeavePrefs: function () { - // ask the migration module to broadcast its current state (and nothing will - // happen if it's not loaded - which is good, as that means no migration - // is pending/necessary) - we don't want to suck that module in just to - // find there's nothing to do. - Services.obs.notifyObservers(null, "fxa-migration:state-request", null); - let service = Components.classes["@mozilla.org/weave/service;1"] .getService(Components.interfaces.nsISupports) .wrappedJSObject; @@ -448,83 +419,6 @@ var gSyncPane = { } }, - updateMigrationState: function(subject, state) { - this._closeSyncStatusMessageBox(); - let selIndex; - let sb = this._accountsStringBundle; - switch (state) { - case fxaMigrator.STATE_USER_FXA: { - // There are 2 cases here - no email address means it is an offer on - // the first device (so the user is prompted to create an account). - // If there is an email address it is the "join the party" flow, so the - // user is prompted to sign in with the address they previously used. - let email = subject ? subject.QueryInterface(Components.interfaces.nsISupportsString).data : null; - let elt = document.getElementById("syncStatusMessageDescription"); - elt.textContent = email ? - sb.formatStringFromName("signInAfterUpgradeOnOtherDevice.description", - [email], 1) : - sb.GetStringFromName("needUserLong"); - - // The "Learn more" link. - if (!email) { - let learnMoreLink = document.createElement("label"); - learnMoreLink.id = "learnMoreLink"; - learnMoreLink.className = "text-link"; - let { text, href } = fxaMigrator.learnMoreLink; - learnMoreLink.setAttribute("value", text); - learnMoreLink.href = href; - elt.parentNode.insertBefore(learnMoreLink, elt.nextSibling); - } - - // The "upgrade" button. - let button = document.getElementById("sync-migrate-upgrade"); - button.setAttribute("label", - sb.GetStringFromName(email - ? "signInAfterUpgradeOnOtherDevice.label" - : "upgradeToFxA.label")); - button.setAttribute("accesskey", - sb.GetStringFromName(email - ? "signInAfterUpgradeOnOtherDevice.accessKey" - : "upgradeToFxA.accessKey")); - // The "unlink" button - this is only shown for first migration - button = document.getElementById("sync-migrate-unlink"); - if (email) { - button.hidden = true; - } else { - button.setAttribute("label", sb.GetStringFromName("unlinkMigration.label")); - button.setAttribute("accesskey", sb.GetStringFromName("unlinkMigration.accessKey")); - } - selIndex = 0; - break; - } - case fxaMigrator.STATE_USER_FXA_VERIFIED: { - let sb = this._accountsStringBundle; - let email = subject.QueryInterface(Components.interfaces.nsISupportsString).data; - let label = sb.formatStringFromName("needVerifiedUserLong", [email], 1); - let elt = document.getElementById("syncStatusMessageDescription"); - elt.setAttribute("value", label); - // The "resend" button. - let button = document.getElementById("sync-migrate-resend"); - button.setAttribute("label", sb.GetStringFromName("resendVerificationEmail.label")); - button.setAttribute("accesskey", sb.GetStringFromName("resendVerificationEmail.accessKey")); - // The "forget" button. - button = document.getElementById("sync-migrate-forget"); - button.setAttribute("label", sb.GetStringFromName("forgetMigration.label")); - button.setAttribute("accesskey", sb.GetStringFromName("forgetMigration.accessKey")); - selIndex = 1; - break; - } - default: - if (state) { // |null| is expected, but everything else is not. - Cu.reportError("updateMigrationState has unknown state: " + state); - } - document.getElementById("sync-migration").hidden = true; - return; - } - document.getElementById("sync-migration-buttons-deck").selectedIndex = selIndex; - document.getElementById("syncStatusMessage").setAttribute("message-type", "migration"); - }, - // Called whenever one of the sync engine preferences is changed. onPreferenceChanged: function() { let prefElts = document.querySelectorAll("#syncEnginePrefs > preference"); @@ -560,30 +454,6 @@ var gSyncPane = { this.updateWeavePrefs(); }, - // When the "Unlink" button in the migration header is selected we display - // a slightly different message. - startOverMigration: function () { - let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING + - Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL + - Services.prompt.BUTTON_POS_1_DEFAULT; - let sb = this._accountsStringBundle; - let buttonChoice = - Services.prompt.confirmEx(window, - sb.GetStringFromName("unlinkVerificationTitle"), - sb.GetStringFromName("unlinkVerificationDescription"), - flags, - sb.GetStringFromName("unlinkVerificationConfirm"), - null, null, null, {}); - - // If the user selects cancel, just bail - if (buttonChoice == 1) - return; - - fxaMigrator.recordTelemetry(fxaMigrator.TELEMETRY_UNLINKED); - Weave.Service.startOver(); - this.updateWeavePrefs(); - }, - updatePass: function () { if (Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED) gSyncUtils.changePassword(); diff --git a/browser/components/preferences/in-content/sync.xul b/browser/components/preferences/in-content/sync.xul index 8dbfbbe1c84..f269b32d415 100644 --- a/browser/components/preferences/in-content/sync.xul +++ b/browser/components/preferences/in-content/sync.xul @@ -43,18 +43,6 @@ - - - -