Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: mobile/android/chrome/content/browser.js

Issue 5365916275572736: Issue 2351 - Add a custom menu item for whitelisting the current site (Closed)
Patch Set: Add missing break Created April 27, 2015, 9:47 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mobile/android/base/strings.xml.in ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « mobile/android/base/strings.xml.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld