Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/AwBrowserContext.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwBrowserContext.java b/android_webview/java/src/org/chromium/android_webview/AwBrowserContext.java |
| index 52869fbed940a2565a033312521b613ecc8a1f1d..f960eefca6ec1d4be16f19224daddacd8f5b9da9 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwBrowserContext.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/AwBrowserContext.java |
| @@ -7,6 +7,9 @@ package org.chromium.android_webview; |
| import android.content.Context; |
| import android.content.SharedPreferences; |
| +import org.chromium.base.CommandLine; |
| +import org.chromium.components.safe_browsing.SafeBrowsingApiBridge; |
| +import org.chromium.components.safe_browsing.SafeBrowsingApiHandler; |
| import org.chromium.content.browser.AppWebMessagePortService; |
| import org.chromium.content.browser.ContentViewStatics; |
| @@ -19,6 +22,7 @@ import org.chromium.content.browser.ContentViewStatics; |
| * AwBrowserContext instance, so at this point the class mostly exists for conceptual clarity. |
| */ |
| public class AwBrowserContext { |
| + private static final String TAG = "AwBrowserContext"; |
| private final SharedPreferences mSharedPreferences; |
| private AwGeolocationPermissions mGeolocationPermissions; |
| @@ -30,6 +34,10 @@ public class AwBrowserContext { |
| public AwBrowserContext(SharedPreferences sharedPreferences, Context applicationContext) { |
| mSharedPreferences = sharedPreferences; |
| mApplicationContext = applicationContext; |
| + |
| + if (CommandLine.getInstance().hasSwitch(AwSwitches.WEBVIEW_ENABLE_SAFEBROWSING_SUPPORT)) { |
| + initSafeBrowsingApiHandler(); |
| + } |
| } |
| public AwGeolocationPermissions getGeolocationPermissions() { |
| @@ -73,4 +81,19 @@ public class AwBrowserContext { |
| public void resumeTimers() { |
| ContentViewStatics.setWebKitSharedTimersSuspended(false); |
| } |
| + |
| + @SuppressWarnings("unchecked") |
| + private void initSafeBrowsingApiHandler() { |
|
paulmiller
2017/01/17 21:45:01
Wouldn't you rather use PlatformServiceBridge for
sgurun-gerrit only
2017/01/17 22:59:50
I think it is not super important, we could do it
paulmiller
2017/01/18 00:58:03
Come to think of it, PlatformServiceBridge doesn't
|
| + final String safeBrowsingApiHandler = |
| + "com.android.webview.chromium.AwSafeBrowsingApiHandler"; |
| + |
| + // Try to get a specialized service bridge. |
| + try { |
| + Class<? extends SafeBrowsingApiHandler> cls = |
| + (Class<? extends SafeBrowsingApiHandler>) Class.forName(safeBrowsingApiHandler); |
| + SafeBrowsingApiBridge.setSafeBrowingHandlerType(cls); |
| + } catch (ClassNotFoundException e) { |
| + // This is not an error; it just means this device doesn't have specialized services. |
| + } |
| + } |
| } |