Bug 965607 - [Australis] Show FxA doorhangers only for the most recent non-popup browser window r=markh

This commit is contained in:
Tim Taubert 2014-01-30 11:15:46 -08:00
parent aacfd2cc8d
commit 06ac26ed21

View File

@ -21,6 +21,7 @@ let gFxAccounts = {
},
get topics() {
// Do all this dance to lazy-load FxAccountsCommon.
delete this.topics;
return this.topics = [
"weave:service:sync:start",
@ -31,6 +32,16 @@ let gFxAccounts = {
];
},
// The set of topics that only the active window should handle.
get activeWindowTopics() {
// Do all this dance to lazy-load FxAccountsCommon.
delete this.activeWindowTopics;
return this.activeWindowTopics = new Set([
"weave:service:sync:start",
FxAccountsCommon.ONVERIFIED_NOTIFICATION
]);
},
get button() {
delete this.button;
return this.button = document.getElementById("PanelUI-fxa-status");
@ -44,8 +55,15 @@ let gFxAccounts = {
Weave.Status.login != Weave.LOGIN_SUCCEEDED;
},
get isActiveWindow() {
let mostRecentNonPopupWindow =
RecentWindow.getMostRecentBrowserWindow({allowPopups: false});
return window == mostRecentNonPopupWindow;
},
init: function () {
if (this._initialized) {
// Bail out if we're already initialized and for pop-up windows.
if (this._initialized || !window.toolbar.visible) {
return;
}
@ -74,6 +92,11 @@ let gFxAccounts = {
},
observe: function (subject, topic) {
// Ignore certain topics if we're not the active window.
if (this.activeWindowTopics.has(topic) && !this.isActiveWindow) {
return;
}
switch (topic) {
case FxAccountsCommon.ONVERIFIED_NOTIFICATION:
Services.prefs.setBoolPref(PREF_SYNC_START_DOORHANGER, true);