Debian Codegraph @

core/java/android/webkit/JsResult.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 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 import android.annotation.SystemApi;
20 import android.compat.annotation.UnsupportedAppUsage;
21
22 /**
23 * An instance of this class is passed as a parameter in various {@link WebChromeClient} action
24 * notifications. The object is used as a handle onto the underlying JavaScript-originated request,
25 * and provides a means for the client to indicate whether this action should proceed.
26 */
27 public class JsResult {
28 /**
29 * Callback interface, implemented by the WebViewProvider implementation to receive
30 * notifications when the JavaScript result represented by a JsResult instance has
31 * @hide Only for use by WebViewProvider implementations
32 */
33 @SystemApi
34 public interface ResultReceiver {
35 public void onJsResultComplete(JsResult result);
36 }
37 // This is the caller of the prompt and is the object that is waiting.
38 @UnsupportedAppUsage
39 private final ResultReceiver mReceiver;
40 // This is a basic result of a confirm or prompt dialog.
41 private boolean mResult;
42
43 /**
44 * Handle the result if the user cancelled the dialog.
45 */
46 public final void cancel() {
47 mResult = false;
48 wakeUp();
49 }
50
51 /**
52 * Handle a confirmation response from the user.
53 */
54 public final void confirm() {
55 mResult = true;
56 wakeUp();
57 }
58
59 /**
60 * @hide Only for use by WebViewProvider implementations
61 */
62 @SystemApi
63 public JsResult(ResultReceiver receiver) {
64 mReceiver = receiver;
65 }
66
67 /**
68 * @hide Only for use by WebViewProvider implementations
69 */
70 @SystemApi
71 public final boolean getResult() {
72 return mResult;
73 }
74
75 /* Notify the caller that the JsResult has completed */
76 private final void wakeUp() {
77 mReceiver.onJsResultComplete(this);
78 }
79 }