Bug 875812 - Uplift Add-on SDK integration branch to Firefox

2593d0a01b...007eb037f0
This commit is contained in:
Dave Townsend
2013-05-24 09:29:33 -07:00
parent 608f4e0f48
commit 3f9ee6af33
16 changed files with 405 additions and 114 deletions

View File

@@ -11,6 +11,7 @@ const { Cc, Ci } = require('chrome');
const { EventEmitter } = require('../deprecated/events');
const { Trait } = require('../deprecated/traits');
const { when } = require('../system/unload');
const events = require('../system/events');
const { getInnerId, getOuterId, windows, isDocumentLoaded, isBrowser,
getMostRecentBrowserWindow, getMostRecentWindow } = require('../window/utils');
const errors = require('../deprecated/errors');
@@ -68,6 +69,8 @@ function WindowTracker(delegate) {
for each (let window in getWindows())
this._regWindow(window);
windowWatcher.registerNotification(this);
this._onToplevelWindowReady = this._onToplevelWindowReady.bind(this);
events.on('toplevel-window-ready', this._onToplevelWindowReady);
require('../system/unload').ensure(this);
@@ -116,6 +119,7 @@ WindowTracker.prototype = {
unload: function unload() {
windowWatcher.unregisterNotification(this);
events.off('toplevel-window-ready', this._onToplevelWindowReady);
for each (let window in getWindows())
this._unregWindow(window);
},
@@ -128,14 +132,20 @@ WindowTracker.prototype = {
}
}),
_onToplevelWindowReady: function _onToplevelWindowReady({subject}) {
let window = subject;
// ignore private windows if they are not supported
if (ignoreWindow(window))
return;
this._regWindow(window);
},
observe: errors.catchAndLog(function observe(subject, topic, data) {
var window = subject.QueryInterface(Ci.nsIDOMWindow);
// ignore private windows if they are not supported
if (ignoreWindow(window))
return;
if (topic == 'domwindowopened')
this._regWindow(window);
else
if (topic == 'domwindowclosed')
this._unregWindow(window);
})
};