1 /*
2  * Copyright 2020 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 androidx.annotation.RequiresFeature;
20 import androidx.annotation.UiThread;
21 
22 /**
23  * This interface represents the return result from {@link WebViewCompat#addDocumentStartJavaScript(
24  * android.webkit.WebView, String, java.util.Set)}. Call {@link ScriptHandler#remove()} when the
25  * corresponding JavaScript script should be removed.
26  *
27  * @see WebViewCompat#addDocumentStartJavaScript(android.webkit.WebView, String, java.util.Set)
28  */
29 public interface ScriptHandler {
30     /**
31      * Removes the corresponding script, it will take effect from next page load.
32      */
33     // UI thread not currently enforced, but required
34     @UiThread
35     @RequiresFeature(name = WebViewFeature.DOCUMENT_START_SCRIPT,
36             enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
remove()37     void remove();
38 }
39