Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1964)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwBrowserContext.java

Issue 2635693002: [WebView] initial webview-side implementation of safebrowsing (Closed)
Patch Set: rename lock, add crbug comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/java/DEPS ('k') | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+ }
+ }
}
« no previous file with comments | « android_webview/java/DEPS ('k') | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698