Chromium Code Reviews| 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..0a5f44f9836a2a625fe024c3e7bc5c3e3f751daf |
| --- /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 computes the score for a url. |
|
Nathan Parker
2016/04/29 20:42:04
s/computes the score/determines the verdict
Yaron
2016/05/02 13:25:07
Done.
|
| + */ |
| + 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) |
|
Nathan Parker
2016/04/29 20:42:04
What does Retention and IntDef do?
Yaron
2016/05/02 13:25:07
Retention source indicates that it shouldn't be ke
|
| + @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); |
| +} |