diff --git a/extensions/firefox-share/src/modules/panel.js b/extensions/firefox-share/src/modules/panel.js index 84d26dc..8f456f0 100644 --- a/extensions/firefox-share/src/modules/panel.js +++ b/extensions/firefox-share/src/modules/panel.js @@ -104,17 +104,17 @@ sharePanel.prototype = { } }, false); this.loadListener = function (evt) { + self.attachMessageListener(); self.window.setTimeout(function () { self.sizeToContent(); }, 0); }; this.browser.addEventListener("load", this.loadListener, true); - Services.obs.addObserver(this, 'content-document-global-created', false); let webProgress = this.browser.webProgress; this.stateProgressListener = new StateProgressListener(this); webProgress.addProgressListener(this.stateProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW); - + // Extend Services object XPCOMUtils.defineLazyServiceGetter( Services, "bookmarks", @@ -123,29 +123,13 @@ sharePanel.prototype = { ); }, - unload: function () { - Services.obs.removeObserver(this, 'content-document-global-created'); + shutdown: function () { let webProgress = this.browser.webProgress; webProgress.removeProgressListener(this.stateProgressListener); this.stateProgressListener = null; }, - observe: function (aSubject, aTopic, aData) { - if (!aSubject.location.href) { - return; - } - - // is this window a child of OUR XUL window? - let mainWindow = aSubject.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindow); - mainWindow = mainWindow.wrappedJSObject ? mainWindow.wrappedJSObject : mainWindow; - if (mainWindow !== this.panel.ownerDocument.defaultView) { - return; - } - + attachMessageListener: function () { // listen for messages now let self = this; let contentWindow = this.browser.contentWindow; @@ -523,7 +507,7 @@ sharePanel.prototype = { return null; return url; }, - + previews: function () { // Look for FB og:image and then rel="image_src" to use if available // for og:image see: http://developers.facebook.com/docs/share