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

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

Issue 1940443002: 📤 Upstream SafeBrowsingApiBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 8 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/SafeBrowsingApiHandler.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..69099461515f633aa5ad15c55e90966f0af6cb1b
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/safe_browsing/SafeBrowsingApiHandler.java
@@ -0,0 +1,53 @@
+// 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 android.support.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Java interface that a SafeBrowsingApiHander must implement when used with
+ * {@code SafeBrowsignApiBridge}
+ */
+public interface SafeBrowsingApiHandler {
+ // Implementors must provide a no-arg constructor to be instantiated via reflection.
+
+ /**
+ * Observer to be notified when the SafeBrowsingApiHandler determines the verdict for a url.
+ */
+ public interface Observer {
+ void onUrlCheckDone(long callbackId, @SafeBrowsingResult int resultStatus, String metadata);
+ }
+
+ // Possible values for resultStatus. Native side has the same definitions.
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ STATUS_INTERNAL_ERROR,
+ STATUS_SUCCESS,
+ STATUS_TIMEOUT
+ })
+ @interface SafeBrowsingResult {}
+ static final int STATUS_INTERNAL_ERROR = -1;
+ static final int STATUS_SUCCESS = 0;
+ static final int STATUS_TIMEOUT = 1;
+
+
+ /**
+ * Verifies that SafeBrowsingApiHandler can operate and initializes if feasible.
+ * Should be called on IO thread.
+ *
+ * @return the handler if it's usable, or null if the API is not supported.
+ */
+ public boolean init(Context context, Observer result);
+
+ /**
+ * Start a URI-lookup to determine if it matches one of the specified threats.
+ * This is called on every URL resource Chrome loads, on the IO thread.
+ */
+ public void startUriLookup(long callbackId, String uri, int[] threatsOfInterest);
+}

Powered by Google App Engine
This is Rietveld 408576698