1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.webkit;
18 
19 import android.webkit.SafeBrowsingResponse;
20 
21 import androidx.annotation.RequiresFeature;
22 import androidx.annotation.RestrictTo;
23 
24 /**
25  * Compatibility version of {@link SafeBrowsingResponse}.
26  */
27 public abstract class SafeBrowsingResponseCompat {
28     /**
29      * Display the default interstitial.
30      *
31      * <p>
32      * This method should only be called if
33      * {@link WebViewFeature#isFeatureSupported(String)}
34      * returns true for {@link WebViewFeature#SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL}.
35      *
36      * @param allowReporting {@code true} if the interstitial should show a reporting checkbox.
37      */
38     @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL,
39             enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
showInterstitial(boolean allowReporting)40     public abstract void showInterstitial(boolean allowReporting);
41 
42     /**
43      * Act as if the user clicked the "visit this unsafe site" button.
44      *
45      * <p>
46      * This method should only be called if
47      * {@link WebViewFeature#isFeatureSupported(String)}
48      * returns true for {@link WebViewFeature#SAFE_BROWSING_RESPONSE_PROCEED}.
49      *
50      * @param report {@code true} to enable Safe Browsing reporting.
51      */
52     @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_RESPONSE_PROCEED,
53             enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
proceed(boolean report)54     public abstract void proceed(boolean report);
55 
56     /**
57      * Act as if the user clicked the "back to safety" button.
58      *
59      * <p>
60      * This method should only be called if
61      * {@link WebViewFeature#isFeatureSupported(String)}
62      * returns true for {@link WebViewFeature#SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY}.
63      *
64      * @param report {@code true} to enable Safe Browsing reporting.
65      */
66     @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY,
67             enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
backToSafety(boolean report)68     public abstract void backToSafety(boolean report);
69 
70     /**
71      * This class cannot be created by applications.
72      */
73     @RestrictTo(RestrictTo.Scope.LIBRARY)
SafeBrowsingResponseCompat()74     public SafeBrowsingResponseCompat() {
75     }
76 }
77