Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 android.webkit; |
| 18 | |
| 19 | /** |
| 20 | * Used to indicate an action to take when hitting a malicious URL. Instances of this class are |
Nate Fischer | bc1da9e | 2017-07-27 12:33:55 -0700 | [diff] [blame] | 21 | * created by the WebView and passed to {@link android.webkit.WebViewClient#onSafeBrowsingHit}. The |
| 22 | * host application must call {@link #showInterstitial(boolean)}, {@link #proceed(boolean)}, or |
| 23 | * {@link #backToSafety(boolean)} to set the WebView's response to the Safe Browsing hit. |
Nate Fischer | 3898ac1 | 2017-08-09 23:02:36 -0700 | [diff] [blame] | 24 | * |
| 25 | * <p> |
| 26 | * If reporting is enabled, all reports will be sent according to the privacy policy referenced by |
| 27 | * {@link android.webkit.WebView#getSafeBrowsingPrivacyPolicyUrl()}. |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 28 | */ |
| 29 | public abstract class SafeBrowsingResponse { |
| 30 | |
| 31 | /** |
| 32 | * Display the default interstitial. |
| 33 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 34 | * @param allowReporting {@code true} if the interstitial should show a reporting checkbox. |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 35 | */ |
Nate Fischer | 6aabdc4 | 2017-07-12 17:12:16 -0700 | [diff] [blame] | 36 | public abstract void showInterstitial(boolean allowReporting); |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
Nate Fischer | 211d615 | 2018-09-12 17:21:41 -0700 | [diff] [blame] | 39 | * Act as if the user clicked the "visit this unsafe site" button. |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 40 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 41 | * @param report {@code true} to enable Safe Browsing reporting. |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 42 | */ |
Nate Fischer | 6aabdc4 | 2017-07-12 17:12:16 -0700 | [diff] [blame] | 43 | public abstract void proceed(boolean report); |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
Nate Fischer | 211d615 | 2018-09-12 17:21:41 -0700 | [diff] [blame] | 46 | * Act as if the user clicked the "back to safety" button. |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 47 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 48 | * @param report {@code true} to enable Safe Browsing reporting. |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 49 | */ |
Nate Fischer | 6aabdc4 | 2017-07-12 17:12:16 -0700 | [diff] [blame] | 50 | public abstract void backToSafety(boolean report); |
Nate Fischer | 2f7af06 | 2017-07-06 11:32:31 -0700 | [diff] [blame] | 51 | } |