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..4d711d3f677ed486e09b88627c06d6b688804dad 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,10 @@ package org.chromium.android_webview; |
| import android.content.Context; |
| import android.content.SharedPreferences; |
| +import org.chromium.base.CommandLine; |
| +import org.chromium.base.Log; |
| +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 +23,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 +35,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 +82,20 @@ public class AwBrowserContext { |
| public void resumeTimers() { |
| ContentViewStatics.setWebKitSharedTimersSuspended(false); |
| } |
| + |
| + @SuppressWarnings("unchecked") |
| + private void initSafeBrowsingApiHandler() { |
| + 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) { |
| + Log.w(TAG, "Could not find SafeBrowsingApiHandler"); |
|
sgurun-gerrit only
2017/01/16 15:11:19
no need to log here as we are already logging for
timvolodine
2017/01/16 18:58:57
Done.
|
| + // This is not an error; it just means this device doesn't have specialized services. |
| + } |
| + } |
| } |