Bug 1160578 - Disable the Pocket button for logged-in users on internal Firefox pages. r=dolske

This commit is contained in:
Jared Wein 2015-05-05 19:25:07 -04:00
parent 2800f31644
commit 13bb25fb11
2 changed files with 27 additions and 1 deletions

View File

@ -52,7 +52,8 @@ XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
"nsIDNSService");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"resource:///modules/Pocket.jsm");
const nsIWebNavigation = Ci.nsIWebNavigation;
@ -4162,6 +4163,7 @@ var XULBrowserWindow = {
BookmarkingUI.onLocationChange();
SocialUI.updateState(location);
UITour.onLocationChange(location);
Pocket.onLocationChange(browser, aLocationURI);
}
// Utility functions for disabling find

View File

@ -132,4 +132,28 @@ let Pocket = {
let window = event.target.ownerDocument.defaultView;
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="));
}
}
},
};