summaryrefslogtreecommitdiffstats
path: root/application/basilisk/base/content
diff options
context:
space:
mode:
Diffstat (limited to 'application/basilisk/base/content')
-rw-r--r--application/basilisk/base/content/browser-fxaccounts.js314
-rw-r--r--application/basilisk/base/content/browser-menubar.inc24
-rw-r--r--application/basilisk/base/content/browser-syncui.js545
-rw-r--r--application/basilisk/base/content/browser.js12
-rw-r--r--application/basilisk/base/content/global-scripts.inc1
-rw-r--r--application/basilisk/base/content/nsContextMenu.js5
6 files changed, 1 insertions, 900 deletions
diff --git a/application/basilisk/base/content/browser-fxaccounts.js b/application/basilisk/base/content/browser-fxaccounts.js
deleted file mode 100644
index e1d556bff..000000000
--- a/application/basilisk/base/content/browser-fxaccounts.js
+++ /dev/null
@@ -1,314 +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/. */
-
-var gFxAccounts = {
-
- _initialized: false,
- _inCustomizationMode: false,
- _cachedProfile: null,
-
- get weave() {
- delete this.weave;
- return this.weave = Cc["@mozilla.org/weave/service;1"]
- .getService(Ci.nsISupports)
- .wrappedJSObject;
- },
-
- get topics() {
- // Do all this dance to lazy-load FxAccountsCommon.
- delete this.topics;
- return this.topics = [
- "weave:service:ready",
- "weave:service:login:change",
- "weave:service:setup-complete",
- "weave:service:sync:error",
- "weave:ui:login:error",
- this.FxAccountsCommon.ONLOGIN_NOTIFICATION,
- this.FxAccountsCommon.ONLOGOUT_NOTIFICATION,
- this.FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION,
- ];
- },
-
- get panelUIFooter() {
- delete this.panelUIFooter;
- return this.panelUIFooter = document.getElementById("PanelUI-footer-fxa");
- },
-
- get panelUIStatus() {
- delete this.panelUIStatus;
- return this.panelUIStatus = document.getElementById("PanelUI-fxa-status");
- },
-
- get panelUIAvatar() {
- delete this.panelUIAvatar;
- return this.panelUIAvatar = document.getElementById("PanelUI-fxa-avatar");
- },
-
- get panelUILabel() {
- delete this.panelUILabel;
- return this.panelUILabel = document.getElementById("PanelUI-fxa-label");
- },
-
- get panelUIIcon() {
- delete this.panelUIIcon;
- return this.panelUIIcon = document.getElementById("PanelUI-fxa-icon");
- },
-
- get strings() {
- delete this.strings;
- return this.strings = Services.strings.createBundle(
- "chrome://browser/locale/accounts.properties"
- );
- },
-
- get loginFailed() {
- // Referencing Weave.Service will implicitly initialize sync, and we don't
- // want to force that - so first check if it is ready.
- let service = Cc["@mozilla.org/weave/service;1"]
- .getService(Components.interfaces.nsISupports)
- .wrappedJSObject;
- if (!service.ready) {
- return false;
- }
- // LOGIN_FAILED_LOGIN_REJECTED explicitly means "you must log back in".
- // All other login failures are assumed to be transient and should go
- // away by themselves, so aren't reflected here.
- return Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED;
- },
-
- init: function () {
- // Bail out if we're already initialized and for pop-up windows.
- if (this._initialized || !window.toolbar.visible) {
- return;
- }
-
- for (let topic of this.topics) {
- Services.obs.addObserver(this, topic, false);
- }
-
- gNavToolbox.addEventListener("customizationstarting", this);
- gNavToolbox.addEventListener("customizationending", this);
-
- EnsureFxAccountsWebChannel();
- this._initialized = true;
-
- this.updateUI();
- },
-
- uninit: function () {
- if (!this._initialized) {
- return;
- }
-
- for (let topic of this.topics) {
- Services.obs.removeObserver(this, topic);
- }
-
- this._initialized = false;
- },
-
- observe: function (subject, topic, data) {
- switch (topic) {
- case this.FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION:
- this._cachedProfile = null;
- // Fallthrough intended
- default:
- this.updateUI();
- break;
- }
- },
-
- handleEvent: function (event) {
- this._inCustomizationMode = event.type == "customizationstarting";
- this.updateAppMenuItem();
- },
-
- 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.
- let nb = window.document.getElementById("global-notificationbox");
- let n = nb.getNotificationWithValue(this.SYNC_MIGRATION_NOTIFICATION_TITLE);
- if (n) {
- nb.removeNotification(n, true);
- }
-
- this.updateAppMenuItem();
- },
-
- // Note that updateAppMenuItem() returns a Promise that's only used by tests.
- updateAppMenuItem: function () {
- let profileInfoEnabled = false;
- try {
- profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled");
- } catch (e) { }
-
- 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");
- } else {
- this.panelUIStatus.removeAttribute("disabled");
- this.panelUILabel.removeAttribute("disabled");
- this.panelUIAvatar.removeAttribute("disabled");
- this.panelUIIcon.removeAttribute("disabled");
- }
-
- let defaultLabel = this.panelUIStatus.getAttribute("defaultlabel");
- let errorLabel = this.panelUIStatus.getAttribute("errorlabel");
- let unverifiedLabel = this.panelUIStatus.getAttribute("unverifiedlabel");
- let settingslabel = this.panelUIStatus.getAttribute("settingslabel");
- // The localization string is for the signed in text, but it's the default text as well
- let defaultTooltiptext = this.panelUIStatus.getAttribute("signedinTooltiptext");
-
- let updateWithUserData = (userData) => {
- // Window might have been closed while fetching data.
- if (window.closed) {
- return;
- }
-
- // Reset the button to its original state.
- this.panelUILabel.setAttribute("label", defaultLabel);
- this.panelUIStatus.setAttribute("tooltiptext", defaultTooltiptext);
- this.panelUIFooter.removeAttribute("fxastatus");
- this.panelUIFooter.removeAttribute("fxaprofileimage");
- this.panelUIAvatar.style.removeProperty("list-style-image");
-
- if (Weave.Status.service == Weave.CLIENT_NOT_CONFIGURED) {
- // Leave the default state
- return;
- }
-
- if (this.loginFailed) {
- this.panelUIFooter.setAttribute("fxastatus", "error");
- this.panelUILabel.setAttribute("label", errorLabel);
- } else {
- this.panelUIFooter.setAttribute("fxastatus", "signedin");
- this.panelUILabel.setAttribute("label", settingslabel);
- this.panelUIStatus.setAttribute("tooltiptext", "");
- }
- }
-
- let updateWithProfile = (profile) => {
- if (profileInfoEnabled) {
- if (profile.displayName) {
- this.panelUILabel.setAttribute("label", profile.displayName);
- }
- if (profile.avatar) {
- this.panelUIFooter.setAttribute("fxaprofileimage", "set");
- let bgImage = "url(\"" + profile.avatar + "\")";
- this.panelUIAvatar.style.listStyleImage = bgImage;
-
- let img = new Image();
- img.onerror = () => {
- // Clear the image if it has trouble loading. Since this callback is asynchronous
- // we check to make sure the image is still the same before we clear it.
- if (this.panelUIAvatar.style.listStyleImage === bgImage) {
- this.panelUIFooter.removeAttribute("fxaprofileimage");
- this.panelUIAvatar.style.removeProperty("list-style-image");
- }
- };
- img.src = profile.avatar;
- }
- }
- }
-
- return fxAccounts.getSignedInUser().then(userData => {
- // userData may be null here when the user is not signed-in, but that's expected
- updateWithUserData(userData);
- // unverified users cause us to spew log errors fetching an OAuth token
- // to fetch the profile, so don't even try in that case.
- if (!userData || !userData.verified || !profileInfoEnabled) {
- return null; // don't even try to grab the profile.
- }
- if (this._cachedProfile) {
- return this._cachedProfile;
- }
- return fxAccounts.getSignedInUserProfile().catch(err => {
- // Not fetching the profile is sad but the FxA logs will already have noise.
- return null;
- });
- }).then(profile => {
- if (!profile) {
- return;
- }
- updateWithProfile(profile);
- this._cachedProfile = profile; // Try to avoid fetching the profile on every UI update
- }).catch(error => {
- // This is most likely in tests, were we quickly log users in and out.
- // The most likely scenario is a user logged out, so reflect that.
- // Bug 995134 calls for better errors so we could retry if we were
- // sure this was the failure reason.
- this.FxAccountsCommon.log.error("Error updating FxA account info", error);
- updateWithUserData(null);
- });
- },
-
- onMenuPanelCommand: function () {
-
- switch (this.panelUIFooter.getAttribute("fxastatus")) {
- case "signedin":
- this.openPreferences();
- break;
- case "error":
- if (this.panelUIFooter.getAttribute("unverified")) {
- this.openPreferences();
- } else {
- this.openSignInAgainPage("menupanel");
- }
- break;
- default:
- this.openPreferences();
- break;
- }
-
- PanelUI.hide();
- },
-
- openPreferences: function () {
- openPreferences("paneSync", { urlParams: { entrypoint: "menupanel" } });
- },
-
- openAccountsPage: function (action, urlParams={}) {
- let params = new URLSearchParams();
- if (action) {
- params.set("action", action);
- }
- for (let name in urlParams) {
- if (urlParams[name] !== undefined) {
- params.set(name, urlParams[name]);
- }
- }
- let url = "about:accounts?" + params;
- switchToTabHavingURI(url, true, {
- replaceQueryString: true
- });
- },
-
- openSignInAgainPage: function (entryPoint) {
- this.openAccountsPage("reauth", { entrypoint: entryPoint });
- },
-
- updateTabContextMenu: function (aPopupMenu) {
- // STUB
- },
-
- initPageContextMenu: function (contextMenu) {
- // STUB
- }
-};
-
-XPCOMUtils.defineLazyGetter(gFxAccounts, "FxAccountsCommon", function () {
- return Cu.import("resource://gre/modules/FxAccountsCommon.js", {});
-});
-
-XPCOMUtils.defineLazyModuleGetter(gFxAccounts, "fxaMigrator",
- "resource://services-sync/FxaMigrator.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "EnsureFxAccountsWebChannel",
- "resource://gre/modules/FxAccountsWebChannel.jsm");
diff --git a/application/basilisk/base/content/browser-menubar.inc b/application/basilisk/base/content/browser-menubar.inc
index 5b89875fd..0af0cc1c7 100644
--- a/application/basilisk/base/content/browser-menubar.inc
+++ b/application/basilisk/base/content/browser-menubar.inc
@@ -436,12 +436,7 @@
label="&toolsMenu.label;"
accesskey="&toolsMenu.accesskey;"
onpopupshowing="mirrorShow(this)">
- <menupopup id="menu_ToolsPopup"
-# We have to use setTimeout() here to avoid a flickering menu bar when opening
-# the Tools menu, see bug 970769. This can be removed once we got rid of the
-# event loop spinning in Weave.Status._authManager.
- onpopupshowing="setTimeout(() => gSyncUI.updateUI());"
- >
+ <menupopup id="menu_ToolsPopup">
<menuitem id="menu_openDownloads"
label="&downloads.label;"
accesskey="&downloads.accesskey;"
@@ -452,23 +447,6 @@
accesskey="&addons.accesskey;"
key="key_openAddons"
command="Tools:Addons"/>
-
- <!-- only one of sync-setup, sync-syncnowitem or sync-reauthitem will be showing at once -->
- <menuitem id="sync-setup"
- label="&syncSignIn.label;"
- accesskey="&syncSignIn.accesskey;"
- observes="sync-setup-state"
- oncommand="gSyncUI.openSetup(null, 'menubar')"/>
- <menuitem id="sync-syncnowitem"
- label="&syncSyncNowItem.label;"
- accesskey="&syncSyncNowItem.accesskey;"
- observes="sync-syncnow-state"
- oncommand="gSyncUI.doSync(event);"/>
- <menuitem id="sync-reauthitem"
- label="&syncReAuthItem.label;"
- accesskey="&syncReAuthItem.accesskey;"
- observes="sync-reauth-state"
- oncommand="gSyncUI.openSignInAgainPage('menubar');"/>
<menuseparator id="devToolsSeparator"/>
<menu id="webDeveloperMenu"
label="&webDeveloperMenu.label;"
diff --git a/application/basilisk/base/content/browser-syncui.js b/application/basilisk/base/content/browser-syncui.js
deleted file mode 100644
index b796e663b..000000000
--- a/application/basilisk/base/content/browser-syncui.js
+++ /dev/null
@@ -1,545 +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/. */
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts",
- "resource://gre/modules/FxAccounts.jsm");
-
-const MIN_STATUS_ANIMATION_DURATION = 1600;
-
-// gSyncUI handles updating the tools menu and displaying notifications.
-var gSyncUI = {
- _obs: ["weave:service:sync:start",
- "weave:service:sync:finish",
- "weave:service:sync:error",
- "weave:service:quota:remaining",
- "weave:service:setup-complete",
- "weave:service:login:start",
- "weave:service:login:finish",
- "weave:service:login:error",
- "weave:service:logout:finish",
- "weave:service:start-over",
- "weave:service:start-over:finish",
- "weave:ui:login:error",
- "weave:ui:sync:error",
- "weave:ui:sync:finish",
- "weave:ui:clear-error",
- "weave:engine:sync:finish"
- ],
-
- _unloaded: false,
- // The last sync start time. Used to calculate the leftover animation time
- // once syncing completes (bug 1239042).
- _syncStartTime: 0,
- _syncAnimationTimer: 0,
-
- init: function () {
- Cu.import("resource://services-common/stringbundle.js");
-
- // Proceed to set up the UI if Sync has already started up.
- // Otherwise we'll do it when Sync is firing up.
- if (this.weaveService.ready) {
- this.initUI();
- return;
- }
-
- // Sync isn't ready yet, but we can still update the UI with an initial
- // state - we haven't called initUI() yet, but that's OK - that's more
- // about observers for state changes, and will be called once Sync is
- // ready to start sending notifications.
- this.updateUI();
-
- Services.obs.addObserver(this, "weave:service:ready", true);
- Services.obs.addObserver(this, "quit-application", true);
-
- // Remove the observer if the window is closed before the observer
- // was triggered.
- window.addEventListener("unload", function onUnload() {
- gSyncUI._unloaded = true;
- window.removeEventListener("unload", onUnload, false);
- Services.obs.removeObserver(gSyncUI, "weave:service:ready");
- Services.obs.removeObserver(gSyncUI, "quit-application");
-
- if (Weave.Status.ready) {
- gSyncUI._obs.forEach(function(topic) {
- Services.obs.removeObserver(gSyncUI, topic);
- });
- }
- }, false);
- },
-
- initUI: function SUI_initUI() {
- // If this is a browser window?
- if (gBrowser) {
- this._obs.push("weave:notification:added");
- }
-
- this._obs.forEach(function(topic) {
- Services.obs.addObserver(this, topic, true);
- }, this);
-
- // initial label for the sync buttons.
- let broadcaster = document.getElementById("sync-status");
- broadcaster.setAttribute("label", this._stringBundle.GetStringFromName("syncnow.label"));
-
- this.maybeMoveSyncedTabsButton();
-
- this.updateUI();
- },
-
-
- // Returns a promise that resolves with true if Sync needs to be configured,
- // false otherwise.
- _needsSetup() {
- let firstSync = "";
- try {
- firstSync = Services.prefs.getCharPref("services.sync.firstSync");
- } catch (e) { }
-
- return Promise.resolve(Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
- firstSync == "notReady");
- },
-
- // 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". Only for fxAccounts. XXX: remove this check.
- // Since we are configured for legacy Sync only, which has no verification
- // concept, just return false.
- return Promise.resolve(false);
- },
-
- // 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: function () {
- // 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
- // Sync is ready anyway.
- if (!this.weaveService.ready) {
- this.log.debug("_loginFailed has sync not ready, so returning false");
- return false;
- }
- this.log.debug("_loginFailed has sync state=${sync}",
- { sync: Weave.Status.login});
- return Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED;
- },
-
- // Kick off an update of the UI - does *not* return a promise.
- updateUI() {
- this._promiseUpdateUI().catch(err => {
- this.log.error("updateUI failed", err);
- })
- },
-
- // Updates the UI - returns a promise.
- _promiseUpdateUI() {
- return this._needsSetup().then(needsSetup => {
- if (!gBrowser)
- return Promise.resolve();
-
- let loginFailed = this._loginFailed();
-
- // Start off with a clean slate
- document.getElementById("sync-reauth-state").hidden = true;
- document.getElementById("sync-setup-state").hidden = true;
- document.getElementById("sync-syncnow-state").hidden = true;
-
- if (loginFailed) {
- // unhiding this element makes the menubar show the login failure state.
- document.getElementById("sync-reauth-state").hidden = false;
- } else if (needsSetup) {
- document.getElementById("sync-setup-state").hidden = false;
- } else {
- document.getElementById("sync-syncnow-state").hidden = false;
- }
-
- return this._updateSyncButtonsTooltip();
- });
- },
-
- // Functions called by observers
- onActivityStart() {
- if (!gBrowser)
- return;
-
- this.log.debug("onActivityStart");
-
- clearTimeout(this._syncAnimationTimer);
- this._syncStartTime = Date.now();
-
- let broadcaster = document.getElementById("sync-status");
- broadcaster.setAttribute("syncstatus", "active");
- broadcaster.setAttribute("label", this._stringBundle.GetStringFromName("syncing2.label"));
- broadcaster.setAttribute("disabled", "true");
-
- this.updateUI();
- },
-
- _updateSyncStatus() {
- if (!gBrowser)
- return;
- let broadcaster = document.getElementById("sync-status");
- broadcaster.removeAttribute("syncstatus");
- broadcaster.removeAttribute("disabled");
- broadcaster.setAttribute("label", this._stringBundle.GetStringFromName("syncnow.label"));
- this.updateUI();
- },
-
- onActivityStop() {
- if (!gBrowser)
- return;
- this.log.debug("onActivityStop");
-
- let now = Date.now();
- let syncDuration = now - this._syncStartTime;
-
- if (syncDuration < MIN_STATUS_ANIMATION_DURATION) {
- let animationTime = MIN_STATUS_ANIMATION_DURATION - syncDuration;
- clearTimeout(this._syncAnimationTimer);
- this._syncAnimationTimer = setTimeout(() => this._updateSyncStatus(), animationTime);
- } else {
- this._updateSyncStatus();
- }
- },
-
- onLoginError: function SUI_onLoginError() {
- this.log.debug("onLoginError: login=${login}, sync=${sync}", Weave.Status);
-
- // We don't show any login errors here; browser-fxaccounts shows them in
- // the hamburger menu.
- this.updateUI();
- },
-
- onLogout: function SUI_onLogout() {
- this.updateUI();
- },
-
- onQuotaNotice: function onQuotaNotice(subject, data) {
- let title = this._stringBundle.GetStringFromName("warning.sync.quota.label");
- let description = this._stringBundle.GetStringFromName("warning.sync.quota.description");
- let buttons = [];
- buttons.push(new Weave.NotificationButton(
- this._stringBundle.GetStringFromName("error.sync.viewQuotaButton.label"),
- this._stringBundle.GetStringFromName("error.sync.viewQuotaButton.accesskey"),
- function() { gSyncUI.openQuotaDialog(); return true; }
- ));
-
- let notification = new Weave.Notification(
- title, description, null, Weave.Notifications.PRIORITY_WARNING, buttons);
- Weave.Notifications.replaceTitle(notification);
- },
-
- _getAppName: function () {
- let brand = new StringBundle("chrome://branding/locale/brand.properties");
- return brand.get("brandShortName");
- },
-
- // Commands
- // doSync forces a sync - it *does not* return a promise as it is called
- // via the various UI components.
- doSync() {
- this._needsSetup().then(needsSetup => {
- if (!needsSetup) {
- setTimeout(() => Weave.Service.errorHandler.syncAndReportErrors(), 0);
- }
- Services.obs.notifyObservers(null, "cloudsync:user-sync", null);
- }).catch(err => {
- this.log.error("Failed to force a sync", err);
- });
- },
-
- // Handle clicking the toolbar button - which either opens the Sync setup
- // pages or forces a sync now. Does *not* return a promise as it is called
- // via the UI.
- handleToolbarButton() {
- this._needsSetup().then(needsSetup => {
- if (needsSetup || this._loginFailed()) {
- this.openSetup();
- } else {
- this.doSync();
- }
- }).catch(err => {
- this.log.error("Failed to handle toolbar button command", err);
- });
- },
-
- /**
- * Invoke the Sync setup wizard.
- *
- * @param wizardType
- * Indicates type of wizard to launch:
- * null -- regular set up wizard
- * "pair" -- pair a device first
- * "reset" -- reset sync
- * @param entryPoint
- * Indicates the entrypoint from where this method was called.
- */
-
- openSetup: function SUI_openSetup(wizardType, entryPoint = "syncbutton") {
- let win = Services.wm.getMostRecentWindow("Weave:AccountSetup");
- if (win)
- win.focus();
- else {
- window.openDialog("chrome://browser/content/sync/setup.xul",
- "weaveSetup", "centerscreen,chrome,resizable=no",
- wizardType);
- }
- },
-
- // Open the legacy-sync device pairing UI. Note used for FxA Sync.
- openAddDevice: function () {
- if (!Weave.Utils.ensureMPUnlocked())
- return;
-
- let win = Services.wm.getMostRecentWindow("Sync:AddDevice");
- if (win)
- win.focus();
- else
- window.openDialog("chrome://browser/content/sync/addDevice.xul",
- "syncAddDevice", "centerscreen,chrome,resizable=no");
- },
-
- openPrefs: function (entryPoint) {
- openPreferences("paneSync", { urlParams: { entrypoint: entryPoint } });
- },
-
- openSignInAgainPage: function (entryPoint = "syncbutton") {
- gFxAccounts.openSignInAgainPage(entryPoint);
- },
-
- /* After Sync is initialized we perform a once-only check for the sync
- button being in "customize purgatory" and if so, move it to the panel.
- This is done primarily for profiles created before SyncedTabs landed,
- where the button defaulted to being in that purgatory.
- We use a preference to ensure we only do it once, so people can still
- customize it away and have it stick.
- */
- maybeMoveSyncedTabsButton() {
- const prefName = "browser.migrated-sync-button";
- let migrated = false;
- try {
- migrated = Services.prefs.getBoolPref(prefName);
- } catch (_) {}
- if (migrated) {
- return;
- }
- if (!CustomizableUI.getPlacementOfWidget("sync-button")) {
- CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
- }
- Services.prefs.setBoolPref(prefName, true);
- },
-
- /* Update the tooltip for the sync-status broadcaster (which will update the
- Sync Toolbar button and the Sync spinner in the FxA hamburger area.)
- If Sync is configured, the tooltip is when the last sync occurred,
- otherwise the tooltip reflects the fact that Sync needs to be
- (re-)configured.
- */
- _updateSyncButtonsTooltip: Task.async(function* () {
- if (!gBrowser)
- return;
-
- let email;
- try {
- email = Services.prefs.getCharPref("services.sync.username");
- } catch (ex) {}
-
- let needsSetup = yield this._needsSetup();
- let needsVerification = yield this._needsVerification();
- let loginFailed = this._loginFailed();
- // This is a little messy as the Sync buttons are 1/2 Sync related and
- // 1/2 FxA related - so for some strings we use Sync strings, but for
- // others we reach into gFxAccounts for strings.
- let tooltiptext;
- if (needsVerification) {
- // "needs verification"
- tooltiptext = gFxAccounts.strings.formatStringFromName("verifyDescription", [email], 1);
- } else if (needsSetup) {
- // "needs setup".
- tooltiptext = this._stringBundle.GetStringFromName("signInToSync.description");
- } else if (loginFailed) {
- // "need to reconnect/re-enter your password"
- tooltiptext = gFxAccounts.strings.formatStringFromName("reconnectDescription", [email], 1);
- } else {
- // Sync appears configured - format the "last synced at" time.
- try {
- let lastSync = new Date(Services.prefs.getCharPref("services.sync.lastSync"));
- tooltiptext = this.formatLastSyncDate(lastSync);
- }
- catch (e) {
- // pref doesn't exist (which will be the case until we've seen the
- // first successful sync) or is invalid (which should be impossible!)
- // Just leave tooltiptext as the empty string in these cases, which
- // will cause the tooltip to be removed below.
- }
- }
-
- // We've done all our promise-y work and ready to update the UI - make
- // sure it hasn't been torn down since we started.
- if (!gBrowser)
- return;
-
- let broadcaster = document.getElementById("sync-status");
- if (broadcaster) {
- if (tooltiptext) {
- broadcaster.setAttribute("tooltiptext", tooltiptext);
- } else {
- broadcaster.removeAttribute("tooltiptext");
- }
- }
- }),
-
- formatLastSyncDate: function(date) {
- let dateFormat;
- let sixDaysAgo = (() => {
- let date = new Date();
- date.setDate(date.getDate() - 6);
- date.setHours(0, 0, 0, 0);
- return date;
- })();
- // It may be confusing for the user to see "Last Sync: Monday" when the last sync was a indeed a Monday but 3 weeks ago
- if (date < sixDaysAgo) {
- dateFormat = {month: 'long', day: 'numeric'};
- } else {
- dateFormat = {weekday: 'long', hour: 'numeric', minute: 'numeric'};
- }
- let lastSyncDateString = date.toLocaleDateString(undefined, dateFormat);
- return this._stringBundle.formatStringFromName("lastSync2.label", [lastSyncDateString], 1);
- },
-
- onClientsSynced: function() {
- let broadcaster = document.getElementById("sync-syncnow-state");
- if (broadcaster) {
- if (Weave.Service.clientsEngine.stats.numClients > 1) {
- broadcaster.setAttribute("devices-status", "multi");
- } else {
- broadcaster.setAttribute("devices-status", "single");
- }
- }
- },
-
- onSyncError: function SUI_onSyncError() {
- this.log.debug("onSyncError: login=${login}, sync=${sync}", Weave.Status);
- let title = this._stringBundle.GetStringFromName("error.sync.title");
- let error = Weave.Utils.getErrorString(Weave.Status.sync);
- let description =
- this._stringBundle.formatStringFromName("error.sync.description", [error], 1);
- let priority = Weave.Notifications.PRIORITY_WARNING;
- let buttons = [];
-
- if (Weave.Status.sync == Weave.OVER_QUOTA) {
- description = this._stringBundle.GetStringFromName("error.sync.quota.description");
- buttons.push(new Weave.NotificationButton(
- this._stringBundle.GetStringFromName("error.sync.viewQuotaButton.label"),
- this._stringBundle.GetStringFromName("error.sync.viewQuotaButton.accesskey"),
- function() { gSyncUI.openQuotaDialog(); return true; } )
- );
- // Only show the notification bar on Quota error. the panel will show the rest.
- let notification =
- new Weave.Notification(title, description, null, priority, buttons);
- Weave.Notifications.replaceTitle(notification);
- }
-
- this.updateUI();
- },
-
-
- observe: function SUI_observe(subject, topic, data) {
- this.log.debug("observed", topic);
- if (this._unloaded) {
- Cu.reportError("SyncUI observer called after unload: " + topic);
- return;
- }
-
- // Unwrap, just like Svc.Obs, but without pulling in that dependency.
- if (subject && typeof subject == "object" &&
- ("wrappedJSObject" in subject) &&
- ("observersModuleSubjectWrapper" in subject.wrappedJSObject)) {
- subject = subject.wrappedJSObject.object;
- }
-
- // First handle "activity" only.
- switch (topic) {
- case "weave:service:sync:start":
- this.onActivityStart();
- break;
- case "weave:service:sync:finish":
- case "weave:service:sync:error":
- this.onActivityStop();
- break;
- }
- // Now non-activity state (eg, enabled, errors, etc)
- // Note that sync uses the ":ui:" notifications for errors because sync.
- switch (topic) {
- case "weave:ui:sync:finish":
- // Do nothing.
- break;
- case "weave:ui:sync:error":
- this.onSyncError();
- break;
- case "weave:service:setup-complete":
- case "weave:service:login:finish":
- case "weave:service:login:start":
- case "weave:service:start-over":
- this.updateUI();
- break;
- case "weave:service:quota:remaining":
- this.onQuotaNotice();
- break;
- case "weave:ui:login:error":
- case "weave:service:login:error":
- this.onLoginError();
- break;
- case "weave:service:logout:finish":
- this.onLogout();
- break;
- case "weave:service:start-over:finish":
- this.updateUI();
- break;
- case "weave:service:ready":
- this.initUI();
- break;
- case "weave:notification:added":
- this.initNotifications();
- break;
- case "weave:engine:sync:finish":
- if (data != "clients") {
- return;
- }
- this.onClientsSynced();
- break;
- case "quit-application":
- // Stop the animation timer on shutdown, since we can't update the UI
- // after this.
- clearTimeout(this._syncAnimationTimer);
- break;
- }
- },
-
- QueryInterface: XPCOMUtils.generateQI([
- Ci.nsIObserver,
- Ci.nsISupportsWeakReference
- ])
-};
-
-XPCOMUtils.defineLazyGetter(gSyncUI, "_stringBundle", function() {
- // XXXzpao these strings should probably be moved from /services to /browser... (bug 583381)
- // but for now just make it work
- return Cc["@mozilla.org/intl/stringbundle;1"].
- getService(Ci.nsIStringBundleService).
- createBundle("chrome://weave/locale/services/sync.properties");
-});
-
-XPCOMUtils.defineLazyGetter(gSyncUI, "log", function() {
- return Log.repository.getLogger("browserwindow.syncui");
-});
-
-XPCOMUtils.defineLazyGetter(gSyncUI, "weaveService", function() {
- return Components.classes["@mozilla.org/weave/service;1"]
- .getService(Components.interfaces.nsISupports)
- .wrappedJSObject;
-});
diff --git a/application/basilisk/base/content/browser.js b/application/basilisk/base/content/browser.js
index ddbe11a9d..d22316834 100644
--- a/application/basilisk/base/content/browser.js
+++ b/application/basilisk/base/content/browser.js
@@ -46,7 +46,6 @@ Cu.import("resource://gre/modules/NotificationDB.jsm");
["Task", "resource://gre/modules/Task.jsm"],
["UpdateUtils", "resource://gre/modules/UpdateUtils.jsm"],
["Weave", "resource://services-sync/main.js"],
- ["fxAccounts", "resource://gre/modules/FxAccounts.jsm"],
#ifdef MOZ_DEVTOOLS
// Note: Do not delete! It is used for: base/content/nsContextMenu.js
["gDevTools", "resource://devtools/client/framework/gDevTools.jsm"],
@@ -1305,10 +1304,6 @@ var gBrowserInit = {
FullScreen.init();
PointerLock.init();
- // initialize the sync UI
- gSyncUI.init();
- gFxAccounts.init();
-
if (AppConstants.MOZ_DATA_REPORTING)
gDataNotificationInfoBar.init();
@@ -1445,8 +1440,6 @@ var gBrowserInit = {
FullScreen.uninit();
- gFxAccounts.uninit();
-
Services.obs.removeObserver(gPluginHandler.NPAPIPluginCrashed, "plugin-crashed");
try {
@@ -1606,9 +1599,6 @@ if (AppConstants.platform == "macosx") {
// initialize the private browsing UI
gPrivateBrowsingUI.init();
-
- // initialize the sync UI
- gSyncUI.init();
};
gBrowserInit.nonBrowserWindowShutdown = function() {
@@ -7540,8 +7530,6 @@ var TabContextMenu = {
this.contextTab.addEventListener("TabAttrModified", this, false);
aPopupMenu.addEventListener("popuphiding", this, false);
-
- gFxAccounts.updateTabContextMenu(aPopupMenu);
},
handleEvent(aEvent) {
switch (aEvent.type) {
diff --git a/application/basilisk/base/content/global-scripts.inc b/application/basilisk/base/content/global-scripts.inc
index eef21e15e..6417a1d95 100644
--- a/application/basilisk/base/content/global-scripts.inc
+++ b/application/basilisk/base/content/global-scripts.inc
@@ -27,7 +27,6 @@
<script type="application/javascript" src="chrome://browser/content/browser-safebrowsing.js"/>
#endif
<script type="application/javascript" src="chrome://browser/content/browser-sidebar.js"/>
-<script type="application/javascript" src="chrome://browser/content/browser-syncui.js"/>
<script type="application/javascript" src="chrome://browser/content/browser-tabsintitlebar.js"/>
<script type="application/javascript" src="chrome://browser/content/browser-thumbnails.js"/>
<script type="application/javascript" src="chrome://browser/content/browser-trackingprotection.js"/>
diff --git a/application/basilisk/base/content/nsContextMenu.js b/application/basilisk/base/content/nsContextMenu.js
index 74a2e7a8e..370e5ba60 100644
--- a/application/basilisk/base/content/nsContextMenu.js
+++ b/application/basilisk/base/content/nsContextMenu.js
@@ -112,7 +112,6 @@ nsContextMenu.prototype = {
this.initLeaveDOMFullScreenItems();
this.initClickToPlayItems();
this.initPasswordManagerItems();
- this.initSyncItems();
},
initPageMenuSeparator: function CM_initPageMenuSeparator() {
@@ -522,10 +521,6 @@ nsContextMenu.prototype = {
popup.insertBefore(fragment, insertBeforeElement);
},
- initSyncItems: function() {
- gFxAccounts.initPageContextMenu(this);
- },
-
openPasswordManager: function() {
LoginHelper.openPasswordManager(window, gContextMenuContentData.documentURIObject.host);
},