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

Unified Diff: mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java

Issue 29543774: Issue 2801 - Create 'Whitelisted websites' screen and add link to 'Ad blocking' screen (Closed)
Patch Set: Created Sept. 13, 2017, 5:01 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
Index: mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java
===================================================================
--- a/mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java
+++ b/mobile/android/thirdparty/org/adblockplus/browser/BrowserAppUtils.java
@@ -31,72 +31,55 @@ public class BrowserAppUtils
private static final String TAG = "AdblockBrowser.BrowserAppUtils";
public static void updateBlockAdsMenuItem(final MenuItem item)
{
final Tab selectedTab = Tabs.getInstance().getSelectedTab();
if (selectedTab == null)
return;
final String url = selectedTab.getURL();
+ item.setEnabled(false);
+ item.setChecked(true);
- AddOnBridge.queryIsLocal(new AdblockPlusApiCallback()
+ if (UrlUtils.isSchemeHttpOrHttps(url))
{
- @Override
- public void onApiRequestSucceeded(NativeJSObject jsObject)
- {
- final boolean local = AddOnBridge.getBooleanFromJsObject(jsObject, "value", true);
- ThreadUtils.postToUiThread(new Runnable()
- {
- @Override
- public void run()
- {
- item.setEnabled(!local);
- }
- });
- }
-
- @Override
- public void onApiRequestFailed(String errorMessage)
+ AddOnBridge.queryIsWebsiteWhitelisted(new AdblockPlusApiCallback()
{
- Log.e(TAG, "queryIsLocal failed: " + errorMessage);
- }
- }, url);
-
- AddOnBridge.queryIsPageWhitelisted(new AdblockPlusApiCallback()
- {
- @Override
- public void onApiRequestSucceeded(NativeJSObject jsObject)
- {
- final boolean whitelisted = AddOnBridge.getBooleanFromJsObject(jsObject, "value", false);
- ThreadUtils.postToUiThread(new Runnable()
+ @Override
+ public void onApiRequestSucceeded(NativeJSObject jsObject)
{
- @Override
- public void run()
+ final boolean whitelisted = AddOnBridge.getBooleanFromJsObject(jsObject, "value", false);
+ ThreadUtils.postToUiThread(new Runnable()
{
- item.setChecked(!whitelisted);
- }
- });
- }
+ @Override
+ public void run()
+ {
+ item.setEnabled(true);
+ item.setChecked(!whitelisted);
+ }
+ });
+ }
- @Override
- public void onApiRequestFailed(String errorMessage)
- {
- Log.e(TAG, "queryIsPageWhitelisted failed: " + errorMessage);
- }
- }, url);
+ @Override
+ public void onApiRequestFailed(String errorMessage)
+ {
+ Log.e(TAG, "queryIsWebsiteWhitelisted failed: " + errorMessage);
+ }
+ }, url);
+ }
}
public static void updateCurrentTabWhitelisting(final MenuItem item)
{
final Tab selectedTab = Tabs.getInstance().getSelectedTab();
if (selectedTab == null)
return;
final String url = selectedTab.getURL();
- AddOnBridge.whitelistSite(new AdblockPlusApiCallback()
+ AddOnBridge.whitelistWebsite(new AdblockPlusApiCallback()
{
@Override
public void onApiRequestSucceeded(NativeJSObject jsObject)
{
ThreadUtils.postToUiThread(new Runnable()
{
@Override
public void run()
@@ -104,17 +87,17 @@ public class BrowserAppUtils
selectedTab.doReload(false);
}
});
}
@Override
public void onApiRequestFailed(String errorMessage)
{
- Log.e(TAG, "whitelistSite failed: " + errorMessage);
+ Log.e(TAG, "whitelistWebsite failed: " + errorMessage);
}
}, url, item.isChecked());
}
public static boolean wasInstalledFromPlayStore(final Context context)
{
final String installer = context.getPackageManager().getInstallerPackageName(context.getPackageName());
return "com.android.vending".equals(installer);

Powered by Google App Engine
This is Rietveld