diff --git a/modules/contentBridge.js b/modules/contentBridge.js index 3bc01439..6deed73a 100644 --- a/modules/contentBridge.js +++ b/modules/contentBridge.js @@ -50,6 +50,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, @@ -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: diff --git a/modules/window.js b/modules/window.js index b8072154..ae2fc177 100644 --- a/modules/window.js +++ b/modules/window.js @@ -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;