Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1753646c authored by Nate Fischer's avatar Nate Fischer Committed by Android (Google) Code Review
Browse files

Merge "Add SafeBrowsingResponse abstract class"

parents c00c64c9 2f7af06e
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -48591,6 +48591,10 @@ package android.webkit {
    method public abstract int rendererPriorityAtExit();
  }
  public abstract class SafeBrowsingResponse {
    ctor public SafeBrowsingResponse();
  }
  public class ServiceWorkerClient {
    ctor public ServiceWorkerClient();
    method public android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebResourceRequest);
@@ -49128,7 +49132,7 @@ package android.webkit {
    method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
    method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
    method public boolean onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail);
    method public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.ValueCallback<java.lang.Integer>);
    method public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
    method public void onScaleChanged(android.webkit.WebView, float, float);
    method public deprecated void onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message);
    method public void onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent);
@@ -49153,9 +49157,6 @@ package android.webkit {
    field public static final int ERROR_UNSAFE_RESOURCE = -16; // 0xfffffff0
    field public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3; // 0xfffffffd
    field public static final int ERROR_UNSUPPORTED_SCHEME = -10; // 0xfffffff6
    field public static final int SAFE_BROWSING_ACTION_BACK_TO_SAFETY = 2; // 0x2
    field public static final int SAFE_BROWSING_ACTION_PROCEED = 1; // 0x1
    field public static final int SAFE_BROWSING_ACTION_SHOW_INTERSTITIAL = 0; // 0x0
    field public static final int SAFE_BROWSING_THREAT_MALWARE = 1; // 0x1
    field public static final int SAFE_BROWSING_THREAT_PHISHING = 2; // 0x2
    field public static final int SAFE_BROWSING_THREAT_UNKNOWN = 0; // 0x0
+5 −4
Original line number Diff line number Diff line
@@ -52202,6 +52202,10 @@ package android.webkit {
    method public abstract int rendererPriorityAtExit();
  }
  public abstract class SafeBrowsingResponse {
    ctor public SafeBrowsingResponse();
  }
  public class ServiceWorkerClient {
    ctor public ServiceWorkerClient();
    method public android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebResourceRequest);
@@ -52810,7 +52814,7 @@ package android.webkit {
    method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
    method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
    method public boolean onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail);
    method public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.ValueCallback<java.lang.Integer>);
    method public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
    method public void onScaleChanged(android.webkit.WebView, float, float);
    method public deprecated void onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message);
    method public void onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent);
@@ -52835,9 +52839,6 @@ package android.webkit {
    field public static final int ERROR_UNSAFE_RESOURCE = -16; // 0xfffffff0
    field public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3; // 0xfffffffd
    field public static final int ERROR_UNSUPPORTED_SCHEME = -10; // 0xfffffff6
    field public static final int SAFE_BROWSING_ACTION_BACK_TO_SAFETY = 2; // 0x2
    field public static final int SAFE_BROWSING_ACTION_PROCEED = 1; // 0x1
    field public static final int SAFE_BROWSING_ACTION_SHOW_INTERSTITIAL = 0; // 0x0
    field public static final int SAFE_BROWSING_THREAT_MALWARE = 1; // 0x1
    field public static final int SAFE_BROWSING_THREAT_PHISHING = 2; // 0x2
    field public static final int SAFE_BROWSING_THREAT_UNKNOWN = 0; // 0x0
+5 −4
Original line number Diff line number Diff line
@@ -49019,6 +49019,10 @@ package android.webkit {
    method public abstract int rendererPriorityAtExit();
  }
  public abstract class SafeBrowsingResponse {
    ctor public SafeBrowsingResponse();
  }
  public class ServiceWorkerClient {
    ctor public ServiceWorkerClient();
    method public android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebResourceRequest);
@@ -49556,7 +49560,7 @@ package android.webkit {
    method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
    method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
    method public boolean onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail);
    method public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.ValueCallback<java.lang.Integer>);
    method public void onSafeBrowsingHit(android.webkit.WebView, android.webkit.WebResourceRequest, int, android.webkit.SafeBrowsingResponse);
    method public void onScaleChanged(android.webkit.WebView, float, float);
    method public deprecated void onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message);
    method public void onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent);
@@ -49581,9 +49585,6 @@ package android.webkit {
    field public static final int ERROR_UNSAFE_RESOURCE = -16; // 0xfffffff0
    field public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3; // 0xfffffffd
    field public static final int ERROR_UNSUPPORTED_SCHEME = -10; // 0xfffffff6
    field public static final int SAFE_BROWSING_ACTION_BACK_TO_SAFETY = 2; // 0x2
    field public static final int SAFE_BROWSING_ACTION_PROCEED = 1; // 0x1
    field public static final int SAFE_BROWSING_ACTION_SHOW_INTERSTITIAL = 0; // 0x0
    field public static final int SAFE_BROWSING_THREAT_MALWARE = 1; // 0x1
    field public static final int SAFE_BROWSING_THREAT_PHISHING = 2; // 0x2
    field public static final int SAFE_BROWSING_THREAT_UNKNOWN = 0; // 0x0
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.webkit;

/**
 * Used to indicate an action to take when hitting a malicious URL. Instances of this class are
 * created by the WebView and passed to {@link WebViewClient#onSafebrowsingHit}. The host
 * application must call {@link #showInterstitial}, {@link #proceed}, or {@link #backToSafety} to
 * set the WebView's response to the Safe Browsing hit.
 */
public abstract class SafeBrowsingResponse {

    /**
     * Display the default interstitial.
     *
     * @param allowReporting True if the interstitial should show a reporting checkbox.
     */
    abstract void showInterstitial(boolean allowReporting);

    /**
     * Act as if the user clicked "visit this unsafe site."
     *
     * @param report True to enable Safe Browsing reporting.
     */
    abstract void proceed(boolean report);

    /**
     * Act as if the user clicked "back to safety."
     *
     * @param report True to enable Safe Browsing reporting.
     */
    abstract void backToSafety(boolean report);
}
+5 −13
Original line number Diff line number Diff line
@@ -246,13 +246,6 @@ public class WebViewClient {
    /** The resource was blocked because it contains unwanted software */
    public static final int SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE = 3;

    /** Display the default interstitial */
    public static final int SAFE_BROWSING_ACTION_SHOW_INTERSTITIAL = 0;
    /** Act as if the user clicked "visit this unsafe site" */
    public static final int SAFE_BROWSING_ACTION_PROCEED = 1;
    /** Act as if the user clicked "Back to safety" */
    public static final int SAFE_BROWSING_ACTION_BACK_TO_SAFETY = 2;

    /**
     * Report an error to the host application. These errors are unrecoverable
     * (i.e. the main resource is unavailable). The errorCode parameter
@@ -517,20 +510,19 @@ public class WebViewClient {
     * Notify the host application that a loading URL has been flagged by Safe Browsing.
     *
     * The application must invoke the callback to indicate the preferred response. The default
     * behavior is to show an interstitial to the user (SAFE_BROWSING_ACTION_SHOW_INTERSTITIAL).
     * behavior is to show an interstitial to the user, with the reporting checkbox visible.
     *
     * If the application needs to show its own custom interstitial UI, the callback can be invoked
     * asynchronously with SAFE_BROWSING_ACTION_BACK_TO_SAFETY or SAFE_BROWSING_ACTION_PROCEED,
     * depending on user response.
     * asynchronously with backToSafety() or proceed(), depending on user response.
     *
     * @param view The WebView that hit the malicious resource.
     * @param request Object containing the details of the request.
     * @param threatType The reason the resource was caught by Safe Browsing, corresponding to a
     *                   SAFE_BROWSING_THREAT_* value.
     * @param callback Applications must invoke this callback with one of SAFE_BROWSING_ACTION_*.
     * @param callback Applications must invoke one of the callback methods.
     */
    public void onSafeBrowsingHit(WebView view, WebResourceRequest request, int threatType,
            ValueCallback<Integer> callback) {
        callback.onReceiveValue(SAFE_BROWSING_ACTION_SHOW_INTERSTITIAL);
            SafeBrowsingResponse callback) {
        callback.showInterstitial(/* allowReporting */ true);
    }
}