Back out 5f81902ee93e (bug 1164942) for leaking pktUIMessaging from browser_UITour_pocket.js on Windows

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2015-05-17 14:21:57 -07:00
Родитель f253d2ed23
Коммит 28b4d45685
5 изменённых файлов: 32 добавлений и 30 удалений

Просмотреть файл

@ -55,29 +55,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"resource:///modules/Pocket.jsm");
// Can't use XPCOMUtils for these because the scripts try to define the variables
// on window, and so the defineProperty inside defineLazyGetter fails.
Object.defineProperty(window, "pktApi", {
get: function() {
// Avoid this getter running again:
delete window.pktApi;
Services.scriptloader.loadSubScript("chrome://browser/content/pocket/pktApi.js", window);
return window.pktApi;
},
configurable: true,
enumerable: true
});
Object.defineProperty(window, "pktUI", {
get: function() {
// Avoid this getter running again:
delete window.pktUI;
Services.scriptloader.loadSubScript("chrome://browser/content/pocket/main.js", window);
return window.pktUI;
},
configurable: true,
enumerable: true
});
const nsIWebNavigation = Ci.nsIWebNavigation;
var gLastBrowserCharset = null;
@ -4194,6 +4171,7 @@ var XULBrowserWindow = {
BookmarkingUI.onLocationChange();
SocialUI.updateState(location);
UITour.onLocationChange(location);
Pocket.onLocationChange(browser, aLocationURI);
}
// Utility functions for disabling find

Просмотреть файл

@ -1307,4 +1307,7 @@
# starting with an empty iframe here in browser.xul from a Ts standpoint.
</deck>
<script type="application/javascript" src="chrome://browser/content/pocket/pktApi.js"/>
<script type="application/javascript" src="chrome://browser/content/pocket/main.js"/>
</window>

Просмотреть файл

@ -1106,13 +1106,8 @@ if (Services.prefs.getBoolPref("browser.pocket.enabled")) {
viewId: "PanelUI-pocketView",
label: label,
tooltiptext: tooltiptext,
// Use forwarding functions here to avoid loading Pocket.jsm on startup:
onViewShowing: function() {
return Pocket.onPanelViewShowing.apply(this, arguments);
},
onViewHiding: function() {
return Pocket.onPanelViewHiding.apply(this, arguments);
},
onViewShowing: Pocket.onPanelViewShowing,
onViewHiding: Pocket.onPanelViewHiding,
// If the user has the "classic" Pocket add-on installed, use that instead
// and destroy the widget.

Просмотреть файл

@ -6,6 +6,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ScrollbarSampler",
"resource:///modules/ScrollbarSampler.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"resource:///modules/Pocket.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",

Просмотреть файл

@ -66,6 +66,30 @@ let Pocket = {
window.pktUI.pocketPanelDidHide(event);
},
// Called on tab/urlbar/location changes and after customization. Update
// anything that is tab specific.
onLocationChange(browser, locationURI) {
if (!locationURI) {
return;
}
let widget = CustomizableUI.getWidget("pocket-button");
for (let instance of widget.instances) {
let node = instance.node;
if (!node ||
node.ownerDocument != browser.ownerDocument) {
continue;
}
if (node) {
let win = browser.ownerDocument.defaultView;
node.disabled = win.pktApi.isUserLoggedIn() &&
!locationURI.schemeIs("http") &&
!locationURI.schemeIs("https") &&
!(locationURI.schemeIs("about") &&
locationURI.spec.toLowerCase().startsWith("about:reader?url="));
}
}
},
_urlToSave: null,
_titleToSave: null,
savePage(browser, url, title) {