From b75f702283a9d543e1296215992841b11fee3265 Mon Sep 17 00:00:00 2001 From: Fedor Date: Mon, 20 May 2019 09:00:37 +0300 Subject: [PATCH] [Centaury] Remove Firefox Accounts --- application/basilisk/app/profile/basilisk.js | 42 - application/basilisk/app/profile/centaury.js | 42 - .../content/aboutaccounts/aboutaccounts.css | 24 - .../content/aboutaccounts/aboutaccounts.js | 543 --------- .../content/aboutaccounts/aboutaccounts.xhtml | 112 -- .../base/content/aboutaccounts/images/fox.png | Bin 1951 -> 0 bytes .../images/graphic_sync_intro.png | Bin 6441 -> 0 bytes .../images/graphic_sync_intro@2x.png | Bin 12852 -> 0 bytes .../base/content/aboutaccounts/main.css | 166 --- .../base/content/aboutaccounts/normalize.css | 402 ------- .../base/content/browser-fxaccounts.js | 314 ----- .../basilisk/base/content/browser-menubar.inc | 27 +- .../basilisk/base/content/browser-sets.inc | 4 - .../basilisk/base/content/browser-syncui.js | 563 --------- application/basilisk/base/content/browser.js | 12 - application/basilisk/base/content/browser.xul | 53 - .../basilisk/base/content/global-scripts.inc | 2 - .../basilisk/base/content/nsContextMenu.js | 5 - .../content/sync/aboutSyncTabs-bindings.xml | 46 - .../base/content/sync/aboutSyncTabs.css | 11 - .../base/content/sync/aboutSyncTabs.js | 350 ------ .../base/content/sync/aboutSyncTabs.xul | 68 -- .../basilisk/base/content/sync/addDevice.js | 157 --- .../basilisk/base/content/sync/addDevice.xul | 129 -- .../basilisk/base/content/sync/customize.css | 28 - .../basilisk/base/content/sync/customize.js | 25 - .../basilisk/base/content/sync/customize.xul | 62 - .../base/content/sync/genericChange.js | 233 ---- .../base/content/sync/genericChange.xul | 123 -- .../basilisk/base/content/sync/key.xhtml | 54 - .../basilisk/base/content/sync/quota.js | 247 ---- .../basilisk/base/content/sync/quota.xul | 65 - .../basilisk/base/content/sync/setup.js | 1060 ----------------- .../basilisk/base/content/sync/setup.xul | 490 -------- .../basilisk/base/content/sync/utils.js | 231 ---- .../basilisk/base/content/web-panels.xul | 1 - application/basilisk/base/jar.mn | 29 - .../components/about/AboutRedirector.cpp | 4 - .../basilisk/components/build/nsModule.cpp | 1 - .../customizableui/CustomizableUI.jsm | 1 - .../customizableui/CustomizableWidgets.jsm | 138 --- .../customizableui/content/panelUI.inc.xul | 110 -- .../components/customizableui/moz.build | 5 +- application/basilisk/components/moz.build | 1 - .../components/places/PlacesUIUtils.jsm | 6 +- .../basilisk/components/places/moz.build | 2 +- .../components/preferences/in-content/jar.mn | 4 +- .../preferences/in-content/preferences.js | 2 + .../preferences/in-content/preferences.xul | 8 + .../components/preferences/in-content/sync.js | 32 +- .../components/syncedtabs/EventEmitter.jsm | 45 - .../syncedtabs/SyncedTabsDeckComponent.js | 169 --- .../syncedtabs/SyncedTabsDeckStore.js | 60 - .../syncedtabs/SyncedTabsDeckView.js | 116 -- .../syncedtabs/SyncedTabsListStore.js | 235 ---- .../components/syncedtabs/TabListComponent.js | 138 --- .../components/syncedtabs/TabListView.js | 568 --------- .../basilisk/components/syncedtabs/jar.mn | 7 - .../basilisk/components/syncedtabs/moz.build | 17 - .../basilisk/components/syncedtabs/sidebar.js | 30 - .../components/syncedtabs/sidebar.xhtml | 114 -- .../basilisk/components/syncedtabs/util.js | 23 - .../basilisk/installer/allowed-dupes.mn | 2 - .../basilisk/installer/package-manifest.in | 2 - .../en-US/chrome/browser/aboutAccounts.dtd | 16 - .../locales/en-US/chrome/browser/browser.dtd | 25 - application/basilisk/locales/jar.mn | 1 - application/basilisk/modules/AboutHome.jsm | 2 - application/basilisk/themes/linux/jar.mn | 1 - .../themes/linux/syncedtabs/sidebar.css | 69 -- application/basilisk/themes/osx/jar.mn | 1 - .../themes/osx/syncedtabs/sidebar.css | 154 --- .../shared/customizableui/panelUI.inc.css | 276 +---- .../themes/shared/syncedtabs/sidebar.inc.css | 234 ---- application/basilisk/themes/windows/jar.mn | 1 - .../themes/windows/syncedtabs/sidebar.css | 132 -- 76 files changed, 38 insertions(+), 8434 deletions(-) delete mode 100644 application/basilisk/base/content/aboutaccounts/aboutaccounts.css delete mode 100644 application/basilisk/base/content/aboutaccounts/aboutaccounts.js delete mode 100644 application/basilisk/base/content/aboutaccounts/aboutaccounts.xhtml delete mode 100644 application/basilisk/base/content/aboutaccounts/images/fox.png delete mode 100644 application/basilisk/base/content/aboutaccounts/images/graphic_sync_intro.png delete mode 100644 application/basilisk/base/content/aboutaccounts/images/graphic_sync_intro@2x.png delete mode 100644 application/basilisk/base/content/aboutaccounts/main.css delete mode 100644 application/basilisk/base/content/aboutaccounts/normalize.css delete mode 100644 application/basilisk/base/content/browser-fxaccounts.js delete mode 100644 application/basilisk/base/content/browser-syncui.js delete mode 100644 application/basilisk/base/content/sync/aboutSyncTabs-bindings.xml delete mode 100644 application/basilisk/base/content/sync/aboutSyncTabs.css delete mode 100644 application/basilisk/base/content/sync/aboutSyncTabs.js delete mode 100644 application/basilisk/base/content/sync/aboutSyncTabs.xul delete mode 100644 application/basilisk/base/content/sync/addDevice.js delete mode 100644 application/basilisk/base/content/sync/addDevice.xul delete mode 100644 application/basilisk/base/content/sync/customize.css delete mode 100644 application/basilisk/base/content/sync/customize.js delete mode 100644 application/basilisk/base/content/sync/customize.xul delete mode 100644 application/basilisk/base/content/sync/genericChange.js delete mode 100644 application/basilisk/base/content/sync/genericChange.xul delete mode 100644 application/basilisk/base/content/sync/key.xhtml delete mode 100644 application/basilisk/base/content/sync/quota.js delete mode 100644 application/basilisk/base/content/sync/quota.xul delete mode 100644 application/basilisk/base/content/sync/setup.js delete mode 100644 application/basilisk/base/content/sync/setup.xul delete mode 100644 application/basilisk/base/content/sync/utils.js delete mode 100644 application/basilisk/components/syncedtabs/EventEmitter.jsm delete mode 100644 application/basilisk/components/syncedtabs/SyncedTabsDeckComponent.js delete mode 100644 application/basilisk/components/syncedtabs/SyncedTabsDeckStore.js delete mode 100644 application/basilisk/components/syncedtabs/SyncedTabsDeckView.js delete mode 100644 application/basilisk/components/syncedtabs/SyncedTabsListStore.js delete mode 100644 application/basilisk/components/syncedtabs/TabListComponent.js delete mode 100644 application/basilisk/components/syncedtabs/TabListView.js delete mode 100644 application/basilisk/components/syncedtabs/jar.mn delete mode 100644 application/basilisk/components/syncedtabs/moz.build delete mode 100644 application/basilisk/components/syncedtabs/sidebar.js delete mode 100644 application/basilisk/components/syncedtabs/sidebar.xhtml delete mode 100644 application/basilisk/components/syncedtabs/util.js delete mode 100644 application/basilisk/locales/en-US/chrome/browser/aboutAccounts.dtd delete mode 100644 application/basilisk/themes/linux/syncedtabs/sidebar.css delete mode 100644 application/basilisk/themes/osx/syncedtabs/sidebar.css delete mode 100644 application/basilisk/themes/shared/syncedtabs/sidebar.inc.css delete mode 100644 application/basilisk/themes/windows/syncedtabs/sidebar.css diff --git a/application/basilisk/app/profile/basilisk.js b/application/basilisk/app/profile/basilisk.js index 5db1caa6a..33ae5c975 100644 --- a/application/basilisk/app/profile/basilisk.js +++ b/application/basilisk/app/profile/basilisk.js @@ -1170,53 +1170,11 @@ pref("browser.uiCustomization.debug", false); // CustomizableUI state of the browser's user interface pref("browser.uiCustomization.state", ""); -// The remote content URL shown for FxA signup. Must use HTTPS. -pref("identity.fxaccounts.remote.signup.uri", "https://accounts.firefox.com/signup?service=sync&context=fx_desktop_v3"); - -// The URL where remote content that forces re-authentication for Firefox Accounts -// should be fetched. Must use HTTPS. -pref("identity.fxaccounts.remote.force_auth.uri", "https://accounts.firefox.com/force_auth?service=sync&context=fx_desktop_v3"); - -// The remote content URL shown for signin in. Must use HTTPS. -pref("identity.fxaccounts.remote.signin.uri", "https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v3"); - -// The remote content URL where FxAccountsWebChannel messages originate. -pref("identity.fxaccounts.remote.webchannel.uri", "https://accounts.firefox.com/"); - -// The value of the context query parameter passed in some fxa requests when config -// discovery is enabled. -pref("identity.fxaccounts.contextParam", "fx_desktop_v3"); - -// The URL we take the user to when they opt to "manage" their Firefox Account. -// Note that this will always need to be in the same TLD as the -// "identity.fxaccounts.remote.signup.uri" pref. -pref("identity.fxaccounts.settings.uri", "https://accounts.firefox.com/settings?service=sync&context=fx_desktop_v3"); - -// The remote URL of the FxA Profile Server -pref("identity.fxaccounts.remote.profile.uri", "https://profile.accounts.firefox.com/v1"); - -// The remote URL of the FxA OAuth Server -pref("identity.fxaccounts.remote.oauth.uri", "https://oauth.accounts.firefox.com/v1"); - -// Whether we display profile images in the UI or not. -pref("identity.fxaccounts.profile_image.enabled", true); - -// Token server used by the FxA Sync identity. -pref("identity.sync.tokenserver.uri", "https://token.services.mozilla.com/1.0/sync/1.5"); - // URLs for promo links to mobile browsers. Note that consumers are expected to // append a value for utm_campaign. pref("identity.mobilepromo.android", "https://www.mozilla.org/firefox/android/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign="); pref("identity.mobilepromo.ios", "https://www.mozilla.org/firefox/ios/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign="); -// Migrate any existing Firefox Account data from the default profile to the -// Developer Edition profile. -#ifdef MOZ_DEV_EDITION -pref("identity.fxaccounts.migrateToDevEdition", true); -#else -pref("identity.fxaccounts.migrateToDevEdition", false); -#endif - // On GTK, we now default to showing the menubar only when alt is pressed: #ifdef MOZ_WIDGET_GTK pref("ui.key.menuAccessKeyFocuses", true); diff --git a/application/basilisk/app/profile/centaury.js b/application/basilisk/app/profile/centaury.js index 178dadd49..f965d7a55 100644 --- a/application/basilisk/app/profile/centaury.js +++ b/application/basilisk/app/profile/centaury.js @@ -1164,53 +1164,11 @@ pref("browser.uiCustomization.debug", false); // CustomizableUI state of the browser's user interface pref("browser.uiCustomization.state", ""); -// The remote content URL shown for FxA signup. Must use HTTPS. -pref("identity.fxaccounts.remote.signup.uri", "https://accounts.firefox.com/signup?service=sync&context=fx_desktop_v3"); - -// The URL where remote content that forces re-authentication for Firefox Accounts -// should be fetched. Must use HTTPS. -pref("identity.fxaccounts.remote.force_auth.uri", "https://accounts.firefox.com/force_auth?service=sync&context=fx_desktop_v3"); - -// The remote content URL shown for signin in. Must use HTTPS. -pref("identity.fxaccounts.remote.signin.uri", "https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v3"); - -// The remote content URL where FxAccountsWebChannel messages originate. -pref("identity.fxaccounts.remote.webchannel.uri", "https://accounts.firefox.com/"); - -// The value of the context query parameter passed in some fxa requests when config -// discovery is enabled. -pref("identity.fxaccounts.contextParam", "fx_desktop_v3"); - -// The URL we take the user to when they opt to "manage" their Firefox Account. -// Note that this will always need to be in the same TLD as the -// "identity.fxaccounts.remote.signup.uri" pref. -pref("identity.fxaccounts.settings.uri", "https://accounts.firefox.com/settings?service=sync&context=fx_desktop_v3"); - -// The remote URL of the FxA Profile Server -pref("identity.fxaccounts.remote.profile.uri", "https://profile.accounts.firefox.com/v1"); - -// The remote URL of the FxA OAuth Server -pref("identity.fxaccounts.remote.oauth.uri", "https://oauth.accounts.firefox.com/v1"); - -// Whether we display profile images in the UI or not. -pref("identity.fxaccounts.profile_image.enabled", true); - -// Token server used by the FxA Sync identity. -pref("identity.sync.tokenserver.uri", "https://token.services.mozilla.com/1.0/sync/1.5"); - // URLs for promo links to mobile browsers. Note that consumers are expected to // append a value for utm_campaign. pref("identity.mobilepromo.android", "https://www.mozilla.org/firefox/android/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign="); pref("identity.mobilepromo.ios", "https://www.mozilla.org/firefox/ios/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign="); -// Migrate any existing Firefox Account data from the default profile to the -// Developer Edition profile. -#ifdef MOZ_DEV_EDITION -pref("identity.fxaccounts.migrateToDevEdition", true); -#else -pref("identity.fxaccounts.migrateToDevEdition", false); -#endif - // On GTK, we now default to showing the menubar only when alt is pressed: #ifdef MOZ_WIDGET_GTK pref("ui.key.menuAccessKeyFocuses", true); diff --git a/application/basilisk/base/content/aboutaccounts/aboutaccounts.css b/application/basilisk/base/content/aboutaccounts/aboutaccounts.css deleted file mode 100644 index a2c5cb8f0..000000000 --- a/application/basilisk/base/content/aboutaccounts/aboutaccounts.css +++ /dev/null @@ -1,24 +0,0 @@ -html, body { - height: 100%; -} - -#remote { - width: 100%; - height: 100%; - border: 0; - display: none; -} - -#networkError, #manage, #intro, #stage, #configError { - display: none; -} - -#oldsync { - background: none; - border: 0; - color: #0095dd; -} - -#oldsync:focus { - outline: 1px dotted #0095dd; -} diff --git a/application/basilisk/base/content/aboutaccounts/aboutaccounts.js b/application/basilisk/base/content/aboutaccounts/aboutaccounts.js deleted file mode 100644 index a05c1ea75..000000000 --- a/application/basilisk/base/content/aboutaccounts/aboutaccounts.js +++ /dev/null @@ -1,543 +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"; - -var {classes: Cc, interfaces: Ci, utils: Cu} = Components; - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/FxAccounts.jsm"); - -var fxAccountsCommon = {}; -Cu.import("resource://gre/modules/FxAccountsCommon.js", fxAccountsCommon); - -// for master-password utilities -Cu.import("resource://services-sync/util.js"); - -const PREF_LAST_FXA_USER = "identity.fxaccounts.lastSignedInUserHash"; -const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync-setup.ui.showCustomizationDialog"; - -const ACTION_URL_PARAM = "action"; - -const OBSERVER_TOPICS = [ - fxAccountsCommon.ONVERIFIED_NOTIFICATION, - fxAccountsCommon.ONLOGOUT_NOTIFICATION, -]; - -function log(msg) { - // dump("FXA: " + msg + "\n"); -} - -function error(msg) { - console.log("Firefox Account Error: " + msg + "\n"); -} - -function getPreviousAccountNameHash() { - try { - return Services.prefs.getComplexValue(PREF_LAST_FXA_USER, Ci.nsISupportsString).data; - } catch (_) { - return ""; - } -} - -function setPreviousAccountNameHash(acctName) { - let string = Cc["@mozilla.org/supports-string;1"] - .createInstance(Ci.nsISupportsString); - string.data = sha256(acctName); - Services.prefs.setComplexValue(PREF_LAST_FXA_USER, Ci.nsISupportsString, string); -} - -function needRelinkWarning(acctName) { - let prevAcctHash = getPreviousAccountNameHash(); - return prevAcctHash && prevAcctHash != sha256(acctName); -} - -// Given a string, returns the SHA265 hash in base64 -function sha256(str) { - let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] - .createInstance(Ci.nsIScriptableUnicodeConverter); - converter.charset = "UTF-8"; - // Data is an array of bytes. - let data = converter.convertToByteArray(str, {}); - let hasher = Cc["@mozilla.org/security/hash;1"] - .createInstance(Ci.nsICryptoHash); - hasher.init(hasher.SHA256); - hasher.update(data, data.length); - - return hasher.finish(true); -} - -function promptForRelink(acctName) { - let sb = Services.strings.createBundle("chrome://browser/locale/syncSetup.properties"); - let continueLabel = sb.GetStringFromName("continue.label"); - let title = sb.GetStringFromName("relinkVerify.title"); - let description = sb.formatStringFromName("relinkVerify.description", - [acctName], 1); - let body = sb.GetStringFromName("relinkVerify.heading") + - "\n\n" + description; - let ps = Services.prompt; - let buttonFlags = (ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING) + - (ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL) + - ps.BUTTON_POS_1_DEFAULT; - let pressed = Services.prompt.confirmEx(window, title, body, buttonFlags, - continueLabel, null, null, null, - {}); - return pressed == 0; // 0 is the "continue" button -} - -// If the last fxa account used for sync isn't this account, we display -// a modal dialog checking they really really want to do this... -// (This is sync-specific, so ideally would be in sync's identity module, -// but it's a little more seamless to do here, and sync is currently the -// only fxa consumer, so... -function shouldAllowRelink(acctName) { - return !needRelinkWarning(acctName) || promptForRelink(acctName); -} - -function updateDisplayedEmail(user) { - let emailDiv = document.getElementById("email"); - if (emailDiv && user) { - emailDiv.textContent = user.email; - } -} - -var wrapper = { - iframe: null, - - init: function (url, urlParams) { - // If a master-password is enabled, we want to encourage the user to - // unlock it. Things still work if not, but the user will probably need - // to re-auth next startup (in which case we will get here again and - // re-prompt) - Utils.ensureMPUnlocked(); - - let iframe = document.getElementById("remote"); - this.iframe = iframe; - this.iframe.QueryInterface(Ci.nsIFrameLoaderOwner); - let docShell = this.iframe.frameLoader.docShell; - docShell.QueryInterface(Ci.nsIWebProgress); - docShell.addProgressListener(this.iframeListener, Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT); - iframe.addEventListener("load", this); - - // Ideally we'd just merge urlParams with new URL(url).searchParams, but our - // URLSearchParams implementation doesn't support iteration (bug 1085284). - let urlParamStr = urlParams.toString(); - if (urlParamStr) { - url += (url.includes("?") ? "&" : "?") + urlParamStr; - } - this.url = url; - // Set the iframe's location with loadURI/LOAD_FLAGS_REPLACE_HISTORY to - // avoid having a new history entry being added. REPLACE_HISTORY is used - // to replace the current entry, which is `about:blank`. - let webNav = iframe.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation); - webNav.loadURI(url, Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY, null, null, null); - }, - - retry: function () { - let webNav = this.iframe.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation); - webNav.loadURI(this.url, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null); - }, - - iframeListener: { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, - Ci.nsISupportsWeakReference, - Ci.nsISupports]), - - onStateChange: function(aWebProgress, aRequest, aState, aStatus) { - let failure = false; - - // Captive portals sometimes redirect users - if ((aState & Ci.nsIWebProgressListener.STATE_REDIRECTING)) { - failure = true; - } else if ((aState & Ci.nsIWebProgressListener.STATE_STOP)) { - if (aRequest instanceof Ci.nsIHttpChannel) { - try { - failure = aRequest.responseStatus != 200; - } catch (e) { - failure = aStatus != Components.results.NS_OK; - } - } - } - - // Calling cancel() will raise some OnStateChange notifications by itself, - // so avoid doing that more than once - if (failure && aStatus != Components.results.NS_BINDING_ABORTED) { - aRequest.cancel(Components.results.NS_BINDING_ABORTED); - setErrorPage("networkError"); - } - }, - - onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) { - if (aRequest && aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) { - aRequest.cancel(Components.results.NS_BINDING_ABORTED); - setErrorPage("networkError"); - } - }, - - onProgressChange: function() {}, - onStatusChange: function() {}, - onSecurityChange: function() {}, - }, - - handleEvent: function (evt) { - switch (evt.type) { - case "load": - this.iframe.contentWindow.addEventListener("FirefoxAccountsCommand", this); - this.iframe.removeEventListener("load", this); - break; - case "FirefoxAccountsCommand": - this.handleRemoteCommand(evt); - break; - } - }, - - /** - * onLogin handler receives user credentials from the jelly after a - * sucessful login and stores it in the fxaccounts service - * - * @param accountData the user's account data and credentials - */ - onLogin: function (accountData) { - log("Received: 'login'. Data:" + JSON.stringify(accountData)); - - if (accountData.customizeSync) { - Services.prefs.setBoolPref(PREF_SYNC_SHOW_CUSTOMIZATION, true); - } - delete accountData.customizeSync; - // sessionTokenContext is erroneously sent by the content server. - // https://github.com/mozilla/fxa-content-server/issues/2766 - // To avoid having the FxA storage manager not knowing what to do with - // it we delete it here. - delete accountData.sessionTokenContext; - - // We need to confirm a relink - see shouldAllowRelink for more - let newAccountEmail = accountData.email; - // The hosted code may have already checked for the relink situation - // by sending the can_link_account command. If it did, then - // it will indicate we don't need to ask twice. - if (!accountData.verifiedCanLinkAccount && !shouldAllowRelink(newAccountEmail)) { - // we need to tell the page we successfully received the message, but - // then bail without telling fxAccounts - this.injectData("message", { status: "login" }); - // after a successful login we return to preferences - openPrefs(); - return; - } - delete accountData.verifiedCanLinkAccount; - - // Remember who it was so we can log out next time. - setPreviousAccountNameHash(newAccountEmail); - - // A sync-specific hack - we want to ensure sync has been initialized - // before we set the signed-in user. - let xps = Cc["@mozilla.org/weave/service;1"] - .getService(Ci.nsISupports) - .wrappedJSObject; - xps.whenLoaded().then(() => { - updateDisplayedEmail(accountData); - return fxAccounts.setSignedInUser(accountData); - }).then(() => { - // If the user data is verified, we want it to immediately look like - // they are signed in without waiting for messages to bounce around. - if (accountData.verified) { - openPrefs(); - } - this.injectData("message", { status: "login" }); - // until we sort out a better UX, just leave the jelly page in place. - // If the account email is not yet verified, it will tell the user to - // go check their email, but then it will *not* change state after - // the verification completes (the browser will begin syncing, but - // won't notify the user). If the email has already been verified, - // the jelly will say "Welcome! You are successfully signed in as - // EMAIL", but it won't then say "syncing started". - }, (err) => this.injectData("message", { status: "error", error: err }) - ); - }, - - onCanLinkAccount: function(accountData) { - // We need to confirm a relink - see shouldAllowRelink for more - let ok = shouldAllowRelink(accountData.email); - this.injectData("message", { status: "can_link_account", data: { ok: ok } }); - }, - - /** - * onSignOut handler erases the current user's session from the fxaccounts service - */ - onSignOut: function () { - log("Received: 'sign_out'."); - - fxAccounts.signOut().then( - () => this.injectData("message", { status: "sign_out" }), - (err) => this.injectData("message", { status: "error", error: err }) - ); - }, - - handleRemoteCommand: function (evt) { - log('command: ' + evt.detail.command); - let data = evt.detail.data; - - switch (evt.detail.command) { - case "login": - this.onLogin(data); - break; - case "can_link_account": - this.onCanLinkAccount(data); - break; - case "sign_out": - this.onSignOut(data); - break; - default: - log("Unexpected remote command received: " + evt.detail.command + ". Ignoring command."); - break; - } - }, - - injectData: function (type, content) { - return fxAccounts.promiseAccountsSignUpURI().then(authUrl => { - let data = { - type: type, - content: content - }; - this.iframe.contentWindow.postMessage(data, authUrl); - }) - .catch(e => { - console.log("Failed to inject data", e); - setErrorPage("configError"); - }); - }, -}; - - -// Button onclick handlers -function handleOldSync() { - let chromeWin = window - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .rootTreeItem - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindow) - .QueryInterface(Ci.nsIDOMChromeWindow); - let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "old-sync"; - chromeWin.switchToTabHavingURI(url, true); -} - -function getStarted() { - show("remote"); -} - -function retry() { - show("remote"); - wrapper.retry(); -} - -function openPrefs() { - // Bug 1199303 calls for this tab to always be replaced with Preferences - // rather than it opening in a different tab. - window.location = "about:preferences#sync"; -} - -function init() { - fxAccounts.getSignedInUser().then(user => { - // tests in particular might cause the window to start closing before - // getSignedInUser has returned. - if (window.closed) { - return Promise.resolve(); - } - - updateDisplayedEmail(user); - - // Ideally we'd use new URL(document.URL).searchParams, but for about: URIs, - // searchParams is empty. - let urlParams = new URLSearchParams(document.URL.split("?")[1] || ""); - let action = urlParams.get(ACTION_URL_PARAM); - urlParams.delete(ACTION_URL_PARAM); - - switch (action) { - case "signin": - if (user) { - // asking to sign-in when already signed in just shows manage. - show("stage", "manage"); - } else { - return fxAccounts.promiseAccountsSignInURI().then(url => { - show("remote"); - wrapper.init(url, urlParams); - }); - } - break; - case "signup": - if (user) { - // asking to sign-up when already signed in just shows manage. - show("stage", "manage"); - } else { - return fxAccounts.promiseAccountsSignUpURI().then(url => { - show("remote"); - wrapper.init(url, urlParams); - }); - } - break; - case "reauth": - // ideally we would only show this when we know the user is in a - // "must reauthenticate" state - but we don't. - // As the email address will be included in the URL returned from - // promiseAccountsForceSigninURI, just always show it. - return fxAccounts.promiseAccountsForceSigninURI().then(url => { - show("remote"); - wrapper.init(url, urlParams); - }); - default: - // No action specified. - if (user) { - show("stage", "manage"); - } else { - // Attempt a migration if enabled or show the introductory page - // otherwise. - return migrateToDevEdition(urlParams).then(migrated => { - if (!migrated) { - show("stage", "intro"); - // load the remote frame in the background - return fxAccounts.promiseAccountsSignUpURI().then(uri => - wrapper.init(uri, urlParams)); - } - return Promise.resolve(); - }); - } - break; - } - return Promise.resolve(); - }).catch(err => { - console.log("Configuration or sign in error", err); - setErrorPage("configError"); - }); -} - -function setErrorPage(errorType) { - show("stage", errorType); -} - -// Causes the "top-level" element with |id| to be shown - all other top-level -// elements are hidden. Optionally, ensures that only 1 "second-level" element -// inside the top-level one is shown. -function show(id, childId) { - // top-level items are either
or