Bug 1220527 - Wait for the first window before showing the upgraded notifications alert. r=MattN

--HG--
extra : commitid : DDBFmrJtj1O
This commit is contained in:
Kit Cambridge 2015-11-02 14:59:52 -08:00
Родитель 3249757e08
Коммит 759a7eadce
1 изменённых файлов: 8 добавлений и 10 удалений

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

@ -647,6 +647,7 @@ BrowserGlue.prototype = {
ExtensionManagement.registerScript("chrome://browser/content/ext-bookmarks.js");
this._flashHangCount = 0;
this._firstWindowReady = new Promise(resolve => this._firstWindowLoaded = resolve);
},
// cleanup (called on application shutdown)
@ -1145,6 +1146,7 @@ BrowserGlue.prototype = {
this._checkForOldBuildUpdates();
this._firstWindowTelemetry(aWindow);
this._firstWindowLoaded();
},
/**
@ -2213,7 +2215,7 @@ BrowserGlue.prototype = {
}
if (currentUIVersion < 32) {
this._notifyNotificationsUpgrade();
this._notifyNotificationsUpgrade().catch(Cu.reportError);
}
// Update the migration version.
@ -2231,10 +2233,11 @@ BrowserGlue.prototype = {
return false;
},
_notifyNotificationsUpgrade: function BG__notifyNotificationsUpgrade() {
_notifyNotificationsUpgrade: Task.async(function* () {
if (!this._hasExistingNotificationPermission()) {
return;
}
yield this._firstWindowReady;
function clickCallback(subject, topic, data) {
if (topic != "alertclickcallback")
return;
@ -2246,14 +2249,9 @@ BrowserGlue.prototype = {
let text = gBrowserBundle.GetStringFromName("webNotifications.upgradeInfo");
let url = Services.urlFormatter.formatURLPref("browser.push.warning.migrationURL");
try {
AlertsService.showAlertNotification(imageURL, title, text,
true, url, clickCallback);
}
catch (e) {
Cu.reportError(e);
}
},
AlertsService.showAlertNotification(imageURL, title, text,
true, url, clickCallback);
}),
// ------------------------------
// public nsIBrowserGlue members