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

Side by Side Diff: mobile/android/base/BrowserApp.java

Issue 5365916275572736: Issue 2351 - Add a custom menu item for whitelisting the current site (Closed)
Patch Set: Address comments, rename location, change item label Created May 6, 2015, 4:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- 1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public 2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 5
6 package org.mozilla.gecko; 6 package org.mozilla.gecko;
7 7
8 import java.io.File; 8 import java.io.File;
9 import java.io.FileNotFoundException; 9 import java.io.FileNotFoundException;
10 import java.lang.reflect.Method; 10 import java.lang.reflect.Method;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 Log.d(LOGTAG, "BrowserApp.onTabChanged: " + tab.getId() + ": " + msg); 246 Log.d(LOGTAG, "BrowserApp.onTabChanged: " + tab.getId() + ": " + msg);
247 switch(msg) { 247 switch(msg) {
248 case LOCATION_CHANGE: 248 case LOCATION_CHANGE:
249 if (Tabs.getInstance().isSelectedTab(tab)) { 249 if (Tabs.getInstance().isSelectedTab(tab)) {
250 maybeCancelFaviconLoad(tab); 250 maybeCancelFaviconLoad(tab);
251 } 251 }
252 // fall through 252 // fall through
253 case SELECTED: 253 case SELECTED:
254 if (Tabs.getInstance().isSelectedTab(tab)) { 254 if (Tabs.getInstance().isSelectedTab(tab)) {
255 updateHomePagerForTab(tab); 255 updateHomePagerForTab(tab);
256 if (mMenu != null)
257 org.adblockplus.browser.BrowserAppUtils.updateBlockAdsMe nuItem(
258 mMenu.findItem(R.id.block_ads));
256 } 259 }
257 break; 260 break;
258 case START: 261 case START:
259 if (Tabs.getInstance().isSelectedTab(tab)) { 262 if (Tabs.getInstance().isSelectedTab(tab)) {
260 invalidateOptionsMenu(); 263 invalidateOptionsMenu();
261 264
262 if (mDynamicToolbar.isEnabled()) { 265 if (mDynamicToolbar.isEnabled()) {
263 mDynamicToolbar.setVisible(true, VisibilityTransition.AN IMATE); 266 mDynamicToolbar.setVisible(true, VisibilityTransition.AN IMATE);
264 } 267 }
265 } 268 }
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 } 2277 }
2275 2278
2276 return null; 2279 return null;
2277 } 2280 }
2278 2281
2279 /** 2282 /**
2280 * Add the provided item to the provided menu, which should be 2283 * Add the provided item to the provided menu, which should be
2281 * the root (mMenu). 2284 * the root (mMenu).
2282 */ 2285 */
2283 private void addAddonMenuItemToMenu(final Menu menu, final MenuItemInfo info ) { 2286 private void addAddonMenuItemToMenu(final Menu menu, final MenuItemInfo info ) {
2287 // Adblock Browser doesn't support add-ons, so the only menu item that
2288 // could be added is the one for whitelisting the current domain added
2289 // by ABP - Adblock Browser has its own item for that.
2290 if (true)
2291 return;
2292
2284 info.added = true; 2293 info.added = true;
2285 2294
2286 final Menu destination; 2295 final Menu destination;
2287 if (info.parent == 0) { 2296 if (info.parent == 0) {
2288 destination = menu; 2297 destination = menu;
2289 } else if (info.parent == GECKO_TOOLS_MENU) { 2298 } else if (info.parent == GECKO_TOOLS_MENU) {
2290 MenuItem tools = menu.findItem(R.id.tools); 2299 MenuItem tools = menu.findItem(R.id.tools);
2291 destination = tools != null ? tools.getSubMenu() : menu; 2300 destination = tools != null ? tools.getSubMenu() : menu;
2292 } else { 2301 } else {
2293 MenuItem parent = menu.findItem(info.parent); 2302 MenuItem parent = menu.findItem(info.parent);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 } 2443 }
2435 } 2444 }
2436 2445
2437 // Action providers are available only ICS+. 2446 // Action providers are available only ICS+.
2438 if (Versions.feature14Plus) { 2447 if (Versions.feature14Plus) {
2439 GeckoMenuItem share = (GeckoMenuItem) mMenu.findItem(R.id.share); 2448 GeckoMenuItem share = (GeckoMenuItem) mMenu.findItem(R.id.share);
2440 GeckoActionProvider provider = GeckoActionProvider.getForType(GeckoA ctionProvider.DEFAULT_MIME_TYPE, this); 2449 GeckoActionProvider provider = GeckoActionProvider.getForType(GeckoA ctionProvider.DEFAULT_MIME_TYPE, this);
2441 share.setActionProvider(provider); 2450 share.setActionProvider(provider);
2442 } 2451 }
2443 2452
2453 org.adblockplus.browser.BrowserAppUtils.updateBlockAdsMenuItem(
2454 mMenu.findItem(R.id.block_ads));
2455
2444 return true; 2456 return true;
2445 } 2457 }
2446 2458
2447 @Override 2459 @Override
2448 public void openOptionsMenu() { 2460 public void openOptionsMenu() {
2449 // Disable menu access (for hardware buttons) when the software menu but ton is inaccessible. 2461 // Disable menu access (for hardware buttons) when the software menu but ton is inaccessible.
2450 if (mBrowserToolbar.isEditing()) { 2462 if (mBrowserToolbar.isEditing()) {
2451 return; 2463 return;
2452 } 2464 }
2453 2465
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 try { 2788 try {
2777 args.put("desktopMode", !item.isChecked()); 2789 args.put("desktopMode", !item.isChecked());
2778 args.put("tabId", selectedTab.getId()); 2790 args.put("tabId", selectedTab.getId());
2779 } catch (JSONException e) { 2791 } catch (JSONException e) {
2780 Log.e(LOGTAG, "error building json arguments"); 2792 Log.e(LOGTAG, "error building json arguments");
2781 } 2793 }
2782 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Desk topMode:Change", args.toString())); 2794 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Desk topMode:Change", args.toString()));
2783 return true; 2795 return true;
2784 } 2796 }
2785 2797
2798 if (itemId == R.id.block_ads) {
2799 org.adblockplus.browser.BrowserAppUtils.updateCurrentTabWhitelisting (item);
2800 return true;
2801 }
2802
2786 if (itemId == R.id.new_tab) { 2803 if (itemId == R.id.new_tab) {
2787 addTab(); 2804 addTab();
2788 return true; 2805 return true;
2789 } 2806 }
2790 2807
2791 if (itemId == R.id.new_private_tab) { 2808 if (itemId == R.id.new_private_tab) {
2792 addPrivateTab(); 2809 addPrivateTab();
2793 return true; 2810 return true;
2794 } 2811 }
2795 2812
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 final SessionInformation previ ousSession) { 3181 final SessionInformation previ ousSession) {
3165 return new BrowserHealthRecorder(context, 3182 return new BrowserHealthRecorder(context,
3166 GeckoSharedPrefs.forApp(context), 3183 GeckoSharedPrefs.forApp(context),
3167 profilePath, 3184 profilePath,
3168 dispatcher, 3185 dispatcher,
3169 osLocale, 3186 osLocale,
3170 appLocale, 3187 appLocale,
3171 previousSession); 3188 previousSession);
3172 } 3189 }
3173 } 3190 }
OLDNEW
« 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