Bug 965544 - Show "now syncing" doorhanger when sync actually starts, once per login r=markh

This commit is contained in:
Tim Taubert 2014-01-29 12:41:07 -08:00
Родитель e1f4ca7ad3
Коммит 2c2176f116
3 изменённых файлов: 32 добавлений и 15 удалений

Просмотреть файл

@ -10,6 +10,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FxAccounts.jsm");
const PREF_LAST_FXA_USER = "identity.fxaccounts.lastSignedInUser";
const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync.ui.showCustomizationDialog";
function log(msg) {
//dump("FXA: " + msg + "\n");
@ -104,7 +105,7 @@ let wrapper = {
log("Received: 'login'. Data:" + JSON.stringify(accountData));
if (accountData.customizeSync) {
Services.prefs.setBoolPref("services.sync.needsCustomization", true);
Services.prefs.setBoolPref(PREF_SYNC_SHOW_CUSTOMIZATION, true);
delete accountData.customizeSync;
}

Просмотреть файл

@ -6,6 +6,8 @@ XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function () {
return Cu.import("resource://gre/modules/FxAccountsCommon.js", {});
});
const PREF_SYNC_START_DOORHANGER = "services.sync.ui.showSyncStartDoorhanger";
let gFxAccounts = {
_initialized: false,
@ -24,7 +26,8 @@ let gFxAccounts = {
return this.topics = [
FxAccountsCommon.ONLOGIN_NOTIFICATION,
FxAccountsCommon.ONVERIFIED_NOTIFICATION,
FxAccountsCommon.ONLOGOUT_NOTIFICATION
FxAccountsCommon.ONLOGOUT_NOTIFICATION,
"weave:service:sync:start"
];
},
@ -33,14 +36,6 @@ let gFxAccounts = {
return this.button = document.getElementById("PanelUI-fxa-status");
},
get syncNeedsCustomization() {
try {
return Services.prefs.getBoolPref("services.sync.needsCustomization");
} catch (e) {
return false;
}
},
init: function () {
if (this._initialized) {
return;
@ -74,9 +69,28 @@ let gFxAccounts = {
},
observe: function (subject, topic) {
if (topic != FxAccountsCommon.ONVERIFIED_NOTIFICATION) {
this.updateUI();
} else if (!this.syncNeedsCustomization) {
switch (topic) {
case FxAccountsCommon.ONVERIFIED_NOTIFICATION:
Services.prefs.setBoolPref(PREF_SYNC_START_DOORHANGER, true);
break;
case "weave:service:sync:start":
this.onSyncStart();
break;
default:
this.updateUI();
break;
}
},
onSyncStart: function () {
let showDoorhanger = false;
try {
showDoorhanger = Services.prefs.getBoolPref(PREF_SYNC_START_DOORHANGER);
} catch (e) { /* The pref might not exist. */ }
if (showDoorhanger) {
Services.prefs.clearUserPref(PREF_SYNC_START_DOORHANGER);
this.showSyncStartedDoorhanger();
}
},

Просмотреть файл

@ -34,6 +34,8 @@ XPCOMUtils.defineLazyGetter(this, 'fxAccountsCommon', function() {
return ob;
});
const PREF_SYNC_SHOW_CUSTOMIZATION = "services.sync.ui.showCustomizationDialog";
function deriveKeyBundle(kB) {
let out = CryptoUtils.hkdf(kB, undefined,
"identity.mozilla.com/picl/v1/oldsync", 2*32);
@ -74,7 +76,7 @@ this.BrowserIDManager.prototype = {
get needsCustomization() {
try {
return Services.prefs.getBoolPref("services.sync.needsCustomization");
return Services.prefs.getBoolPref(PREF_SYNC_SHOW_CUSTOMIZATION);
} catch (e) {
return false;
}
@ -113,7 +115,7 @@ this.BrowserIDManager.prototype = {
win.openDialog(url, "_blank", features, data);
if (data.accepted) {
Services.prefs.clearUserPref("services.sync.needsCustomization");
Services.prefs.clearUserPref(PREF_SYNC_SHOW_CUSTOMIZATION);
} else {
// Log out if the user canceled the dialog.
return fxAccounts.signOut();