Index: mobile/android/chrome/content/browser.js |
=================================================================== |
--- a/mobile/android/chrome/content/browser.js |
+++ b/mobile/android/chrome/content/browser.js |
@@ -363,6 +363,7 @@ |
Services.obs.addObserver(this, "Webapps:Load", false); |
Services.obs.addObserver(this, "Webapps:AutoUninstall", false); |
Services.obs.addObserver(this, "sessionstore-state-purge-complete", false); |
+ Services.obs.addObserver(this, "BlockAds:Change", false); |
function showFullScreenWarning() { |
NativeWindow.toast.show(Strings.browser.GetStringFromName("alertFullScreenToast"), "short"); |
@@ -1762,6 +1763,15 @@ |
Services.strings.flushBundles(); |
break; |
+ case "BlockAds:Change": |
+ let {blockAds, url} = JSON.parse(aData); |
+ let ioService = Cc["@mozilla.org/network/io-service;1"] |
+ .getService(Ci.nsIIOService); |
+ url = ioService.newURI(url, null, null).QueryInterface(Ci.nsIURL); |
+ AdblockPlusApi.whitelistSite(url, !blockAds); |
+ browser.webNavigation.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE); |
+ break; |
+ |
default: |
dump('BrowserApp.observe: unexpected topic "' + aTopic + '"\n'); |
break; |
@@ -1925,6 +1935,11 @@ |
_menuId: 1, |
toolsMenuID: -1, |
add: function() { |
+ // Adblock Browser doesn't support add-ons, so the only menu item that |
+ // could be added is the one for whitelisting the current domain added by |
+ // ABP - Adblock Browser has its own item for that. |
+ return; |
+ |
let options; |
if (arguments.length == 1) { |
options = arguments[0]; |
@@ -4216,6 +4231,13 @@ |
} |
} |
+ let canBlockAds = !AdblockPlusApi.isLocal(fixedURI); |
+ sendMessageToJava({ |
+ type: "BlockAds:Update", |
+ canBlockAds: canBlockAds, |
+ blockAds: canBlockAds && !AdblockPlusApi.isPageWhitelisted(fixedURI) |
+ }); |
+ |
let contentType = contentWin.document.contentType; |
// If fixedURI matches browser.lastURI, we assume this isn't a real location |