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

Unified Diff: mobile/android/base/BrowserApp.java

Issue 5365916275572736: Issue 2351 - Add a custom menu item for whitelisting the current site (Closed)
Patch Set: Created April 25, 2015, 9:45 p.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 | « adblockplus/Api.jsm ('k') | mobile/android/base/locales/en-US/android_strings.dtd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mobile/android/base/BrowserApp.java
===================================================================
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -559,7 +559,8 @@
"Settings:Show",
"Telemetry:Gather",
"Updater:Launch",
- "BrowserToolbar:Visibility");
+ "BrowserToolbar:Visibility",
+ "BlockAds:Update");
Distribution distribution = Distribution.init(this);
@@ -997,7 +998,8 @@
"Settings:Show",
"Telemetry:Gather",
"Updater:Launch",
- "BrowserToolbar:Visibility");
+ "BrowserToolbar:Visibility",
+ "BlockAds:Update");
if (AppConstants.MOZ_ANDROID_BEAM) {
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
@@ -1393,6 +1395,22 @@
} else if ("BrowserToolbar:Visibility".equals(event)) {
setBrowserToolbarVisible(message.getBoolean("visible"));
+ } else if ("BlockAds:Update".equals(event)) {
+ final Menu menu = mMenu;
+ final boolean enabled = message.getBoolean("canBlockAds");
+ final boolean checked = message.getBoolean("blockAds");
+ ThreadUtils.postToUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (menu == null)
+ return;
+ final MenuItem blockAdsItem = menu.findItem(R.id.block_ads);
+ blockAdsItem.setEnabled(enabled);
+ blockAdsItem.setChecked(checked);
+ }
+ });
+
+
} else {
super.handleMessage(event, message, callback);
}
@@ -2783,6 +2801,21 @@
return true;
}
+ if (itemId == R.id.block_ads) {
+ Tab selectedTab = Tabs.getInstance().getSelectedTab();
+ if (selectedTab == null)
+ return true;
+ JSONObject args = new JSONObject();
+ try {
+ args.put("blockAds", !item.isChecked());
+ args.put("url", selectedTab.getURL());
+ } catch (JSONException e) {
+ Log.e(LOGTAG, "error building json arguments");
+ }
+ GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("BlockAds:Change", args.toString()));
+ return true;
+ }
+
if (itemId == R.id.new_tab) {
addTab();
return true;
« no previous file with comments | « adblockplus/Api.jsm ('k') | mobile/android/base/locales/en-US/android_strings.dtd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld