blob: f9400061190b80c16ce8b420407242e24eb62322 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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
17package android.webkit;
18
19import android.graphics.Bitmap;
20import android.os.Message;
21
22public class WebChromeClient {
23
24 /**
25 * Tell the host application the current progress of loading a page.
26 * @param view The WebView that initiated the callback.
27 * @param newProgress Current page loading progress, represented by
28 * an integer between 0 and 100.
29 */
30 public void onProgressChanged(WebView view, int newProgress) {}
31
32 /**
33 * Notify the host application of a change in the document title.
34 * @param view The WebView that initiated the callback.
35 * @param title A String containing the new title of the document.
36 */
37 public void onReceivedTitle(WebView view, String title) {}
38
39 /**
40 * Notify the host application of a new favicon for the current page.
41 * @param view The WebView that initiated the callback.
42 * @param icon A Bitmap containing the favicon for the current page.
43 */
44 public void onReceivedIcon(WebView view, Bitmap icon) {}
45
46 /**
47 * Request the host application to create a new Webview. The host
48 * application should handle placement of the new WebView in the view
49 * system. The default behavior returns null.
50 * @param view The WebView that initiated the callback.
51 * @param dialog True if the new window is meant to be a small dialog
52 * window.
53 * @param userGesture True if the request was initiated by a user gesture
54 * such as clicking a link.
55 * @param resultMsg The message to send when done creating a new WebView.
56 * Set the new WebView through resultMsg.obj which is
57 * WebView.WebViewTransport() and then call
58 * resultMsg.sendToTarget();
59 * @return Similar to javscript dialogs, this method should return true if
60 * the client is going to handle creating a new WebView. Note that
61 * the WebView will halt processing if this method returns true so
62 * make sure to call resultMsg.sendToTarget(). It is undefined
63 * behavior to call resultMsg.sendToTarget() after returning false
64 * from this method.
65 */
66 public boolean onCreateWindow(WebView view, boolean dialog,
67 boolean userGesture, Message resultMsg) {
68 return false;
69 }
70
71 /**
72 * Request display and focus for this WebView. This may happen due to
73 * another WebView opening a link in this WebView and requesting that this
74 * WebView be displayed.
75 * @param view The WebView that needs to be focused.
76 */
77 public void onRequestFocus(WebView view) {}
78
79 /**
80 * Notify the host application to close the given WebView and remove it
81 * from the view system if necessary. At this point, WebCore has stopped
82 * any loading in this window and has removed any cross-scripting ability
83 * in javascript.
84 * @param window The WebView that needs to be closed.
85 */
86 public void onCloseWindow(WebView window) {}
87
88 /**
89 * Tell the client to display a javascript alert dialog. If the client
90 * returns true, WebView will assume that the client will handle the
91 * dialog. If the client returns false, it will continue execution.
92 * @param view The WebView that initiated the callback.
93 * @param url The url of the page requesting the dialog.
94 * @param message Message to be displayed in the window.
95 * @param result A JsResult to confirm that the user hit enter.
96 * @return boolean Whether the client will handle the alert dialog.
97 */
98 public boolean onJsAlert(WebView view, String url, String message,
99 JsResult result) {
100 return false;
101 }
102
103 /**
104 * Tell the client to display a confirm dialog to the user. If the client
105 * returns true, WebView will assume that the client will handle the
106 * confirm dialog and call the appropriate JsResult method. If the
107 * client returns false, a default value of false will be returned to
108 * javascript. The default behavior is to return false.
109 * @param view The WebView that initiated the callback.
110 * @param url The url of the page requesting the dialog.
111 * @param message Message to be displayed in the window.
112 * @param result A JsResult used to send the user's response to
113 * javascript.
114 * @return boolean Whether the client will handle the confirm dialog.
115 */
116 public boolean onJsConfirm(WebView view, String url, String message,
117 JsResult result) {
118 return false;
119 }
120
121 /**
122 * Tell the client to display a prompt dialog to the user. If the client
123 * returns true, WebView will assume that the client will handle the
124 * prompt dialog and call the appropriate JsPromptResult method. If the
125 * client returns false, a default value of false will be returned to to
126 * javascript. The default behavior is to return false.
127 * @param view The WebView that initiated the callback.
128 * @param url The url of the page requesting the dialog.
129 * @param message Message to be displayed in the window.
130 * @param defaultValue The default value displayed in the prompt dialog.
131 * @param result A JsPromptResult used to send the user's reponse to
132 * javascript.
133 * @return boolean Whether the client will handle the prompt dialog.
134 */
135 public boolean onJsPrompt(WebView view, String url, String message,
136 String defaultValue, JsPromptResult result) {
137 return false;
138 }
139
140 /**
141 * Tell the client to display a dialog to confirm navigation away from the
142 * current page. This is the result of the onbeforeunload javascript event.
143 * If the client returns true, WebView will assume that the client will
144 * handle the confirm dialog and call the appropriate JsResult method. If
145 * the client returns false, a default value of true will be returned to
146 * javascript to accept navigation away from the current page. The default
147 * behavior is to return false. Setting the JsResult to true will navigate
148 * away from the current page, false will cancel the navigation.
149 * @param view The WebView that initiated the callback.
150 * @param url The url of the page requesting the dialog.
151 * @param message Message to be displayed in the window.
152 * @param result A JsResult used to send the user's response to
153 * javascript.
154 * @return boolean Whether the client will handle the confirm dialog.
155 */
156 public boolean onJsBeforeUnload(WebView view, String url, String message,
157 JsResult result) {
158 return false;
159 }
160}