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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java

Issue 2622773002: Componentize SafeBrowsingApi{Bridge,Handler} (Closed)
Patch Set: Addressing vakh@'s comments 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
Index: chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java
deleted file mode 100644
index cd4668aef2735b4dd95d332832426bf2d20c43f1..0000000000000000000000000000000000000000
--- a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiBridge.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.safe_browsing;
-
-import android.content.Context;
-
-import org.chromium.base.Log;
-import org.chromium.base.annotations.CalledByNative;
-import org.chromium.base.annotations.JNINamespace;
-
-/**
- * Helper for calling GMSCore Safe Browsing API from native code.
- */
-@JNINamespace("safe_browsing")
-public final class SafeBrowsingApiBridge {
- private static final String TAG = "SafeBrowsingApi";
-
- private static Class<? extends SafeBrowsingApiHandler> sHandler;
-
- private SafeBrowsingApiBridge() {
- // Util class, do not instantiate.
- }
-
- /**
- * Set the class-file for the implementation of SafeBrowsingApiHandler to use when the safe
- * browsing api is invoked.
- */
- public static void setSafeBrowingHandlerType(Class<? extends SafeBrowsingApiHandler> handler) {
- sHandler = handler;
- }
-
- /**
- * Create a SafeBrowsingApiHandler obj and initialize its client, if supported.
- * Should be called on IO thread.
- *
- * @return the handler if it's usable, or null if the API is not supported.
- */
- @CalledByNative
- private static SafeBrowsingApiHandler create(Context context) {
- SafeBrowsingApiHandler handler;
- try {
- handler = sHandler.newInstance();
- } catch (NullPointerException | InstantiationException | IllegalAccessException e) {
- Log.e(TAG, "Failed to init handler: " + e.getMessage());
- return null;
- }
- boolean initSuccesssful = handler.init(context, new SafeBrowsingApiHandler.Observer() {
- @Override
- public void onUrlCheckDone(long callbackId, int resultStatus, String metadata) {
- nativeOnUrlCheckDone(callbackId, resultStatus, metadata);
- }
- });
- return initSuccesssful ? handler : null;
- }
-
- @CalledByNative
- private static void startUriLookup(SafeBrowsingApiHandler handler, long callbackId,
- String uri, int[] threatsOfInterest) {
- handler.startUriLookup(callbackId, uri, threatsOfInterest);
- Log.d(TAG, "Done starting request");
- }
-
- private static native void nativeOnUrlCheckDone(
- long callbackId, int resultStatus, String metadata);
-}
« no previous file with comments | « chrome/android/BUILD.gn ('k') | chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698