mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1016825 - Show legacy-Sync-to-Firefox-Accounts migration notifications in the main browser window. r=markh
This commit is contained in:
parent
7aab8e3a93
commit
83771e4dec
@ -11,6 +11,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "fxaMigrator",
|
||||
|
||||
const PREF_SYNC_START_DOORHANGER = "services.sync.ui.showSyncStartDoorhanger";
|
||||
const DOORHANGER_ACTIVATE_DELAY_MS = 5000;
|
||||
const SYNC_MIGRATION_NOTIFICATION_TITLE = "fxa-migration";
|
||||
|
||||
let gFxAccounts = {
|
||||
|
||||
@ -157,7 +158,7 @@ let gFxAccounts = {
|
||||
setTimeout(() => this.onSyncStart(), DOORHANGER_ACTIVATE_DELAY_MS);
|
||||
} else {
|
||||
this._inCustomizationMode = event.type == "customizationstarting";
|
||||
this.updateUI();
|
||||
this.updateAppMenuItem();
|
||||
}
|
||||
},
|
||||
|
||||
@ -182,8 +183,13 @@ let gFxAccounts = {
|
||||
},
|
||||
|
||||
updateUI: function () {
|
||||
this.updateAppMenuItem();
|
||||
this.updateMigrationNotification();
|
||||
},
|
||||
|
||||
updateAppMenuItem: function () {
|
||||
if (this._migrationInfo) {
|
||||
this.showMigrationUI();
|
||||
this.updateAppMenuItemForMigration();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -241,32 +247,74 @@ let gFxAccounts = {
|
||||
});
|
||||
},
|
||||
|
||||
showMigrationUI: Task.async(function* () {
|
||||
updateAppMenuItemForMigration: Task.async(function* () {
|
||||
let status = null;
|
||||
let label = null;
|
||||
switch (this._migrationInfo.state) {
|
||||
case fxaMigrator.STATE_USER_FXA:
|
||||
status = "migrate-signup";
|
||||
label = this.strings.formatStringFromName("needUser",
|
||||
label = this.strings.formatStringFromName("needUserShort",
|
||||
[this.button.getAttribute("fxabrandname")], 1);
|
||||
break;
|
||||
case fxaMigrator.STATE_USER_FXA_VERIFIED:
|
||||
if (this._migrationInfo.email) {
|
||||
status = "migrate-verify";
|
||||
label = this.strings.formatStringFromName("needVerifiedUser",
|
||||
[this._migrationInfo.email],
|
||||
1);
|
||||
}
|
||||
status = "migrate-verify";
|
||||
label = this.strings.formatStringFromName("needVerifiedUserShort",
|
||||
[this._migrationInfo.email],
|
||||
1);
|
||||
break;
|
||||
}
|
||||
if (label && status) {
|
||||
this.button.label = label;
|
||||
this.button.hidden = false;
|
||||
this.button.setAttribute("fxastatus", status);
|
||||
} else {
|
||||
Cu.reportError("Could not update menu panel button given migration " +
|
||||
"state: " + this._migrationInfo.state);
|
||||
this.button.label = label;
|
||||
this.button.hidden = false;
|
||||
this.button.setAttribute("fxastatus", status);
|
||||
}),
|
||||
|
||||
updateMigrationNotification: Task.async(function* () {
|
||||
if (!this._migrationInfo) {
|
||||
Weave.Notifications.removeAll(SYNC_MIGRATION_NOTIFICATION_TITLE);
|
||||
return;
|
||||
}
|
||||
if (gBrowser.currentURI.spec.split("?")[0] == "about:accounts") {
|
||||
// If the current tab is about:accounts, assume the user just completed a
|
||||
// migration step and don't bother them with a redundant notification.
|
||||
return;
|
||||
}
|
||||
let note = null;
|
||||
switch (this._migrationInfo.state) {
|
||||
case fxaMigrator.STATE_USER_FXA: {
|
||||
let msg = this.strings.GetStringFromName("needUserLong");
|
||||
let upgradeLabel =
|
||||
this.strings.GetStringFromName("upgradeToFxA.label");
|
||||
let upgradeAccessKey =
|
||||
this.strings.GetStringFromName("upgradeToFxA.accessKey");
|
||||
note = new Weave.Notification(
|
||||
undefined, msg, undefined, Weave.Notifications.PRIORITY_WARNING, [
|
||||
new Weave.NotificationButton(upgradeLabel, upgradeAccessKey, () => {
|
||||
fxaMigrator.createFxAccount(window);
|
||||
}),
|
||||
]
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 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, () => {
|
||||
fxaMigrator.resendVerificationMail();
|
||||
}),
|
||||
]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
note.title = SYNC_MIGRATION_NOTIFICATION_TITLE;
|
||||
Weave.Notifications.replaceTitle(note);
|
||||
}),
|
||||
|
||||
onMenuPanelCommand: function (event) {
|
||||
|
@ -13,8 +13,6 @@ let CloudSync = null;
|
||||
|
||||
// gSyncUI handles updating the tools menu and displaying notifications.
|
||||
let gSyncUI = {
|
||||
DEFAULT_EOL_URL: "https://www.mozilla.org/firefox/?utm_source=synceol",
|
||||
|
||||
_obs: ["weave:service:sync:start",
|
||||
"weave:service:quota:remaining",
|
||||
"weave:service:setup-complete",
|
||||
@ -27,7 +25,6 @@ let gSyncUI = {
|
||||
"weave:ui:sync:error",
|
||||
"weave:ui:sync:finish",
|
||||
"weave:ui:clear-error",
|
||||
"weave:eol",
|
||||
],
|
||||
|
||||
_unloaded: false,
|
||||
@ -260,32 +257,6 @@ let gSyncUI = {
|
||||
return brand.get("brandShortName");
|
||||
},
|
||||
|
||||
onEOLNotice: function (data) {
|
||||
let code = data.code;
|
||||
let kind = (code == "hard-eol") ? "error" : "warning";
|
||||
let url = data.url || gSyncUI.DEFAULT_EOL_URL;
|
||||
|
||||
let title = this._stringBundle.GetStringFromName(kind + ".sync.eol.label");
|
||||
let description = this._stringBundle.formatStringFromName(kind + ".sync.eol.description",
|
||||
[this._getAppName()],
|
||||
1);
|
||||
|
||||
let buttons = [];
|
||||
buttons.push(new Weave.NotificationButton(
|
||||
this._stringBundle.GetStringFromName("sync.eol.learnMore.label"),
|
||||
this._stringBundle.GetStringFromName("sync.eol.learnMore.accesskey"),
|
||||
function() {
|
||||
window.openUILinkIn(url, "tab");
|
||||
return true;
|
||||
}
|
||||
));
|
||||
|
||||
let priority = (kind == "error") ? Weave.Notifications.PRIORITY_WARNING :
|
||||
Weave.Notifications.PRIORITY_INFO;
|
||||
let notification = new Weave.Notification(title, description, null, priority, buttons);
|
||||
Weave.Notifications.replaceTitle(notification);
|
||||
},
|
||||
|
||||
openServerStatus: function () {
|
||||
let statusURL = Services.prefs.getCharPref("services.sync.statusURL");
|
||||
window.openUILinkIn(statusURL, "tab");
|
||||
@ -551,9 +522,6 @@ let gSyncUI = {
|
||||
case "weave:ui:clear-error":
|
||||
this.clearError();
|
||||
break;
|
||||
case "weave:eol":
|
||||
this.onEOLNotice(subject);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const STATE_CHANGED_TOPIC = "fxa-migration:state-changed";
|
||||
const NOTIFICATION_TITLE = "fxa-migration";
|
||||
|
||||
let imports = {};
|
||||
Cu.import("resource://services-sync/FxaMigrator.jsm", imports);
|
||||
@ -9,30 +10,42 @@ Cu.import("resource://services-sync/FxaMigrator.jsm", imports);
|
||||
add_task(function* test() {
|
||||
// Fake the state where we need an FxA user.
|
||||
let buttonPromise = promiseButtonMutation();
|
||||
Services.obs.notifyObservers(null, "fxa-migration:state-changed",
|
||||
Services.obs.notifyObservers(null, STATE_CHANGED_TOPIC,
|
||||
fxaMigrator.STATE_USER_FXA);
|
||||
let buttonState = yield buttonPromise;
|
||||
assertButtonState(buttonState, "migrate-signup", true);
|
||||
Assert.ok(Weave.Notifications.notifications.some(n => {
|
||||
return n.title == NOTIFICATION_TITLE;
|
||||
}), "Needs-user notification should be present");
|
||||
|
||||
// Fake the state where we need a verified FxA user.
|
||||
buttonPromise = promiseButtonMutation();
|
||||
let email = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
email.data = "foo@example.com";
|
||||
Services.obs.notifyObservers(email, "fxa-migration:state-changed",
|
||||
Services.obs.notifyObservers(email, STATE_CHANGED_TOPIC,
|
||||
fxaMigrator.STATE_USER_FXA_VERIFIED);
|
||||
buttonState = yield buttonPromise;
|
||||
assertButtonState(buttonState, "migrate-verify", true,
|
||||
"foo@example.com not verified");
|
||||
let note = Weave.Notifications.notifications.find(n => {
|
||||
return n.title == NOTIFICATION_TITLE;
|
||||
});
|
||||
Assert.ok(!!note, "Needs-verification notification should be present");
|
||||
Assert.ok(note.description.contains(email.data),
|
||||
"Needs-verification notification should include email");
|
||||
|
||||
// Fake the state where no migration is needed.
|
||||
buttonPromise = promiseButtonMutation();
|
||||
Services.obs.notifyObservers(null, "fxa-migration:state-changed", null);
|
||||
Services.obs.notifyObservers(null, STATE_CHANGED_TOPIC, null);
|
||||
buttonState = yield buttonPromise;
|
||||
// In this case, the front end has called fxAccounts.getSignedInUser() to
|
||||
// update the button label and status. But since there isn't actually a user,
|
||||
// the button is left with no fxastatus.
|
||||
assertButtonState(buttonState, "", true);
|
||||
Assert.ok(!Weave.Notifications.notifications.some(n => {
|
||||
return n.title == NOTIFICATION_TITLE;
|
||||
}), "Migration notifications should no longer be present");
|
||||
});
|
||||
|
||||
function assertButtonState(buttonState, expectedStatus, expectedVisible,
|
||||
|
@ -1,7 +1,19 @@
|
||||
# LOCALIZATION NOTE (needUser)
|
||||
# %S = Firefox Accounts brand name from syncBrand.dtd
|
||||
needUser = %S required for sync
|
||||
# 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/.
|
||||
|
||||
# LOCALIZATION NOTE (needVerifiedUser)
|
||||
# LOCALIZATION NOTE (needUserShort)
|
||||
# %S = Firefox Accounts brand name from syncBrand.dtd
|
||||
needUserShort = %S required for sync
|
||||
needUserLong = We've rebuilt Sync to make it easier for everyone. Please upgrade to a Firefox Account to continue syncing.
|
||||
|
||||
upgradeToFxA.label = Upgrade
|
||||
upgradeToFxA.accessKey = U
|
||||
|
||||
# LOCALIZATION NOTE (needVerifiedUserShort, needVerifiedUserLong)
|
||||
# %S = Email address of user's Firefox Account
|
||||
needVerifiedUser = %S not verified
|
||||
needVerifiedUserShort = %S not verified
|
||||
needVerifiedUserLong = Please click the verification link in the email sent to %S
|
||||
|
||||
resendVerificationEmail.label = Resend
|
||||
resendVerificationEmail.accessKey = R
|
||||
|
Loading…
Reference in New Issue
Block a user