Listen messages from the content process with single listener for the window, instead of separate listeners for each frame.
If we register listeners for each frame, they don't work after the type of related browser is changed between remote and in-process.
This commit is contained in:
parent
64f488575e
commit
4ad032d55c
@ -51,6 +51,14 @@ function ContentBridge(aTab, aTabBrowser)
|
||||
this.init(aTab, aTabBrowser);
|
||||
}
|
||||
|
||||
ContentBridge.install = function CB_installScript(aWindow) {
|
||||
aWindow.messageManager.loadFrameScript(TreeStyleTabConstants.CONTENT_SCRIPT_AUTOHIDE, true);
|
||||
};
|
||||
|
||||
ContentBridge.uninstall = function CB_installScript(aWindow) {
|
||||
aWindow.messageManager.sendAsyncCommand(TreeStyleTabConstants.COMMAND_SHUTDOWN);
|
||||
};
|
||||
|
||||
ContentBridge.prototype = inherit(TreeStyleTabConstants, {
|
||||
mTab : null,
|
||||
mTabBrowser : null,
|
||||
@ -62,16 +70,13 @@ ContentBridge.prototype = inherit(TreeStyleTabConstants, {
|
||||
this.handleMessage = this.handleMessage.bind(this);
|
||||
this.checkPluginAreaExistenceResolvers = {};
|
||||
|
||||
var manager = this.mTab.linkedBrowser.messageManager;
|
||||
// manager.loadFrameScript(this.CONTENT_SCRIPT, true);
|
||||
manager.loadFrameScript(this.CONTENT_SCRIPT_AUTOHIDE, true);
|
||||
var manager = this.mTab.ownerDocument.defaultView.messageManager;
|
||||
manager.addMessageListener(this.MESSAGE_TYPE, this.handleMessage);
|
||||
},
|
||||
destroy : function CB_destroy()
|
||||
{
|
||||
var manager = this.mTab.linkedBrowser.messageManager;
|
||||
var manager = this.mTab.ownerDocument.defaultView.messageManager;
|
||||
manager.removeMessageListener(this.MESSAGE_TYPE, this.handleMessage);
|
||||
this.sendAsyncCommand(this.COMMAND_SHUTDOWN);
|
||||
|
||||
delete this.mTab;
|
||||
delete this.mTabBrowser;
|
||||
@ -97,7 +102,13 @@ ContentBridge.prototype = inherit(TreeStyleTabConstants, {
|
||||
},
|
||||
handleMessage : function CB_handleMessage(aMessage)
|
||||
{
|
||||
// dump(JSON.stringify(aMessage.json)+'\n');
|
||||
// dump('*********************handleMessage*******************\n');
|
||||
// dump('TARGET IS: '+aMessage.target.localName+'\n');
|
||||
// dump(JSON.stringify(aMessage.json)+'\n');
|
||||
|
||||
if (aMessage.target != this.mTab.linkedBrowser)
|
||||
return;
|
||||
|
||||
switch (aMessage.json.command)
|
||||
{
|
||||
case this.COMMAND_REPORT_MOUSEDOWN:
|
||||
|
@ -65,6 +65,7 @@ XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideWindow', 'resource://treestylet
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabThemeManager', 'resource://treestyletab-modules/themeManager.js');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'FullscreenObserver', 'resource://treestyletab-modules/fullscreenObserver.js');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'BrowserUIShowHideObserver', 'resource://treestyletab-modules/browserUIShowHideObserver.js');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'ContentBridge', 'resource://treestyletab-modules/contentBridge.js');
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, 'SessionStore',
|
||||
'@mozilla.org/browser/sessionstore;1', 'nsISessionStore');
|
||||
@ -419,6 +420,8 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
|
||||
this.initUninstallationListener();
|
||||
|
||||
ContentBridge.install(w);
|
||||
|
||||
w.TreeStyleTabWindowHelper.onBeforeBrowserInit();
|
||||
this.initTabBrowser(this.browser);
|
||||
w.TreeStyleTabWindowHelper.onAfterBrowserInit();
|
||||
@ -535,6 +538,8 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
|
||||
w.messageManager.removeMessageListener('SessionStore:restoreTabContentStarted', this);
|
||||
|
||||
ContentBridge.uninstall(w);
|
||||
|
||||
this.fullscreenObserver.destroy();
|
||||
delete this.fullscreenObserver;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user