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: Created April 25, 2015, 9:45 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 "Feedback:MaybeLater", 552 "Feedback:MaybeLater",
553 "Feedback:OpenPlayStore", 553 "Feedback:OpenPlayStore",
554 "Menu:Add", 554 "Menu:Add",
555 "Menu:Remove", 555 "Menu:Remove",
556 "Reader:ListStatusRequest", 556 "Reader:ListStatusRequest",
557 "Reader:Removed", 557 "Reader:Removed",
558 "Reader:Share", 558 "Reader:Share",
559 "Settings:Show", 559 "Settings:Show",
560 "Telemetry:Gather", 560 "Telemetry:Gather",
561 "Updater:Launch", 561 "Updater:Launch",
562 "BrowserToolbar:Visibility"); 562 "BrowserToolbar:Visibility",
563 "BlockAds:Update");
563 564
564 Distribution distribution = Distribution.init(this); 565 Distribution distribution = Distribution.init(this);
565 566
566 // Init suggested sites engine in BrowserDB. 567 // Init suggested sites engine in BrowserDB.
567 final SuggestedSites suggestedSites = new SuggestedSites(appContext, dis tribution); 568 final SuggestedSites suggestedSites = new SuggestedSites(appContext, dis tribution);
568 BrowserDB.setSuggestedSites(suggestedSites); 569 BrowserDB.setSuggestedSites(suggestedSites);
569 570
570 JavaAddonManager.getInstance().init(appContext); 571 JavaAddonManager.getInstance().init(appContext);
571 mSharedPreferencesHelper = new SharedPreferencesHelper(appContext); 572 mSharedPreferencesHelper = new SharedPreferencesHelper(appContext);
572 mOrderedBroadcastHelper = new OrderedBroadcastHelper(appContext); 573 mOrderedBroadcastHelper = new OrderedBroadcastHelper(appContext);
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 "Feedback:MaybeLater", 991 "Feedback:MaybeLater",
991 "Feedback:OpenPlayStore", 992 "Feedback:OpenPlayStore",
992 "Menu:Add", 993 "Menu:Add",
993 "Menu:Remove", 994 "Menu:Remove",
994 "Reader:ListStatusRequest", 995 "Reader:ListStatusRequest",
995 "Reader:Removed", 996 "Reader:Removed",
996 "Reader:Share", 997 "Reader:Share",
997 "Settings:Show", 998 "Settings:Show",
998 "Telemetry:Gather", 999 "Telemetry:Gather",
999 "Updater:Launch", 1000 "Updater:Launch",
1000 "BrowserToolbar:Visibility"); 1001 "BrowserToolbar:Visibility",
1002 "BlockAds:Update");
1001 1003
1002 if (AppConstants.MOZ_ANDROID_BEAM) { 1004 if (AppConstants.MOZ_ANDROID_BEAM) {
1003 NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this); 1005 NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
1004 if (nfc != null) { 1006 if (nfc != null) {
1005 // null this out even though the docs say it's not needed, 1007 // null this out even though the docs say it's not needed,
1006 // because the source code looks like it will only do this 1008 // because the source code looks like it will only do this
1007 // automatically on API 14+ 1009 // automatically on API 14+
1008 nfc.setNdefPushMessageCallback(null, this); 1010 nfc.setNdefPushMessageCallback(null, this);
1009 } 1011 }
1010 } 1012 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 BrowserDB.getCount(getContentResolver(), "thumbnails")); 1388 BrowserDB.getCount(getContentResolver(), "thumbnails"));
1387 Telemetry.HistogramAdd("FENNEC_READING_LIST_COUNT", 1389 Telemetry.HistogramAdd("FENNEC_READING_LIST_COUNT",
1388 BrowserDB.getCount(getContentResolver(), "readinglist")); 1390 BrowserDB.getCount(getContentResolver(), "readinglist"));
1389 Telemetry.HistogramAdd("BROWSER_IS_USER_DEFAULT", (isDefaultBrowser( ) ? 1 : 0)); 1391 Telemetry.HistogramAdd("BROWSER_IS_USER_DEFAULT", (isDefaultBrowser( ) ? 1 : 0));
1390 } else if ("Updater:Launch".equals(event)) { 1392 } else if ("Updater:Launch".equals(event)) {
1391 handleUpdaterLaunch(); 1393 handleUpdaterLaunch();
1392 1394
1393 } else if ("BrowserToolbar:Visibility".equals(event)) { 1395 } else if ("BrowserToolbar:Visibility".equals(event)) {
1394 setBrowserToolbarVisible(message.getBoolean("visible")); 1396 setBrowserToolbarVisible(message.getBoolean("visible"));
1395 1397
1398 } else if ("BlockAds:Update".equals(event)) {
1399 final Menu menu = mMenu;
1400 final boolean enabled = message.getBoolean("canBlockAds");
1401 final boolean checked = message.getBoolean("blockAds");
1402 ThreadUtils.postToUiThread(new Runnable() {
1403 @Override
1404 public void run() {
1405 if (menu == null)
1406 return;
1407 final MenuItem blockAdsItem = menu.findItem(R.id.block_a ds);
1408 blockAdsItem.setEnabled(enabled);
1409 blockAdsItem.setChecked(checked);
1410 }
1411 });
1412
1413
1396 } else { 1414 } else {
1397 super.handleMessage(event, message, callback); 1415 super.handleMessage(event, message, callback);
1398 } 1416 }
1399 } 1417 }
1400 1418
1401 /** 1419 /**
1402 * Use a dummy Intent to do a default browser check. 1420 * Use a dummy Intent to do a default browser check.
1403 * 1421 *
1404 * @return true if this package is the default browser on this device, false otherwise. 1422 * @return true if this package is the default browser on this device, false otherwise.
1405 */ 1423 */
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 try { 2794 try {
2777 args.put("desktopMode", !item.isChecked()); 2795 args.put("desktopMode", !item.isChecked());
2778 args.put("tabId", selectedTab.getId()); 2796 args.put("tabId", selectedTab.getId());
2779 } catch (JSONException e) { 2797 } catch (JSONException e) {
2780 Log.e(LOGTAG, "error building json arguments"); 2798 Log.e(LOGTAG, "error building json arguments");
2781 } 2799 }
2782 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Desk topMode:Change", args.toString())); 2800 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Desk topMode:Change", args.toString()));
2783 return true; 2801 return true;
2784 } 2802 }
2785 2803
2804 if (itemId == R.id.block_ads) {
2805 Tab selectedTab = Tabs.getInstance().getSelectedTab();
2806 if (selectedTab == null)
2807 return true;
2808 JSONObject args = new JSONObject();
2809 try {
2810 args.put("blockAds", !item.isChecked());
2811 args.put("url", selectedTab.getURL());
2812 } catch (JSONException e) {
2813 Log.e(LOGTAG, "error building json arguments");
2814 }
2815 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Bloc kAds:Change", args.toString()));
2816 return true;
2817 }
2818
2786 if (itemId == R.id.new_tab) { 2819 if (itemId == R.id.new_tab) {
2787 addTab(); 2820 addTab();
2788 return true; 2821 return true;
2789 } 2822 }
2790 2823
2791 if (itemId == R.id.new_private_tab) { 2824 if (itemId == R.id.new_private_tab) {
2792 addPrivateTab(); 2825 addPrivateTab();
2793 return true; 2826 return true;
2794 } 2827 }
2795 2828
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 final SessionInformation previ ousSession) { 3197 final SessionInformation previ ousSession) {
3165 return new BrowserHealthRecorder(context, 3198 return new BrowserHealthRecorder(context,
3166 GeckoSharedPrefs.forApp(context), 3199 GeckoSharedPrefs.forApp(context),
3167 profilePath, 3200 profilePath,
3168 dispatcher, 3201 dispatcher,
3169 osLocale, 3202 osLocale,
3170 appLocale, 3203 appLocale,
3171 previousSession); 3204 previousSession);
3172 } 3205 }
3173 } 3206 }
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