blob: 768dc9f70ff69e1df90f6a2459e02b6c9dd5c3e3 [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
Ignacio Solla451e3382014-11-10 10:35:54 +000019import android.annotation.SystemApi;
Selim Gurun48f6c452014-07-18 16:23:46 -070020import android.content.Intent;
Derek Sollenberger7ab3d672011-06-01 14:45:05 -040021import android.content.pm.ActivityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.graphics.Bitmap;
Leon Scroggins70ca3c22009-10-02 15:58:55 -040023import android.net.Uri;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.os.Message;
Andrei Popescu6fa29582009-06-19 14:54:09 +010025import android.view.View;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026
27public class WebChromeClient {
28
29 /**
30 * Tell the host application the current progress of loading a page.
31 * @param view The WebView that initiated the callback.
32 * @param newProgress Current page loading progress, represented by
33 * an integer between 0 and 100.
34 */
35 public void onProgressChanged(WebView view, int newProgress) {}
36
37 /**
38 * Notify the host application of a change in the document title.
39 * @param view The WebView that initiated the callback.
40 * @param title A String containing the new title of the document.
41 */
42 public void onReceivedTitle(WebView view, String title) {}
43
44 /**
45 * Notify the host application of a new favicon for the current page.
46 * @param view The WebView that initiated the callback.
47 * @param icon A Bitmap containing the favicon for the current page.
48 */
49 public void onReceivedIcon(WebView view, Bitmap icon) {}
50
51 /**
Patrick Scott2ba12622009-08-04 13:20:05 -040052 * Notify the host application of the url for an apple-touch-icon.
53 * @param view The WebView that initiated the callback.
54 * @param url The icon url.
Patrick Scottd58ccff2009-09-18 16:29:00 -040055 * @param precomposed True if the url is for a precomposed touch icon.
Patrick Scott2ba12622009-08-04 13:20:05 -040056 */
Patrick Scottd58ccff2009-09-18 16:29:00 -040057 public void onReceivedTouchIconUrl(WebView view, String url,
58 boolean precomposed) {}
Patrick Scott2ba12622009-08-04 13:20:05 -040059
60 /**
Andrei Popescu3c946a1a2009-07-03 08:20:53 +010061 * A callback interface used by the host application to notify
62 * the current page that its custom view has been dismissed.
Andrei Popescu6fa29582009-06-19 14:54:09 +010063 */
Andrei Popescu3c946a1a2009-07-03 08:20:53 +010064 public interface CustomViewCallback {
65 /**
66 * Invoked when the host application dismisses the
67 * custom view.
68 */
69 public void onCustomViewHidden();
70 }
71
72 /**
73 * Notify the host application that the current page would
Kristian Monsen0e0b2da2013-04-10 13:43:43 -070074 * like to show a custom View. This is used for Fullscreen
75 * video playback; see "HTML5 Video support" documentation on
76 * {@link WebView}.
Andrei Popescu3c946a1a2009-07-03 08:20:53 +010077 * @param view is the View object to be shown.
78 * @param callback is the callback to be invoked if and when the view
79 * is dismissed.
Andrei Popescu3c946a1a2009-07-03 08:20:53 +010080 */
81 public void onShowCustomView(View view, CustomViewCallback callback) {};
Andrei Popescu6fa29582009-06-19 14:54:09 +010082
83 /**
84 * Notify the host application that the current page would
Derek Sollenberger7ab3d672011-06-01 14:45:05 -040085 * like to show a custom View in a particular orientation.
86 * @param view is the View object to be shown.
87 * @param requestedOrientation An orientation constant as used in
88 * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}.
89 * @param callback is the callback to be invoked if and when the view
90 * is dismissed.
Kristian Monsen0e0b2da2013-04-10 13:43:43 -070091 * @deprecated This method supports the obsolete plugin mechanism,
92 * and will not be invoked in future
Derek Sollenberger7ab3d672011-06-01 14:45:05 -040093 */
Kristian Monsen0e0b2da2013-04-10 13:43:43 -070094 @Deprecated
Derek Sollenberger7ab3d672011-06-01 14:45:05 -040095 public void onShowCustomView(View view, int requestedOrientation,
96 CustomViewCallback callback) {};
Jonathan Dixon3a5cf382013-07-27 15:37:31 -070097
Derek Sollenberger7ab3d672011-06-01 14:45:05 -040098 /**
99 * Notify the host application that the current page would
Andrei Popescu6fa29582009-06-19 14:54:09 +0100100 * like to hide its custom view.
Andrei Popescu6fa29582009-06-19 14:54:09 +0100101 */
102 public void onHideCustomView() {}
103
104 /**
Steve Block89e00a92011-08-03 15:24:43 +0100105 * Request the host application to create a new window. If the host
106 * application chooses to honor this request, it should return true from
107 * this method, create a new WebView to host the window, insert it into the
108 * View system and send the supplied resultMsg message to its target with
109 * the new WebView as an argument. If the host application chooses not to
110 * honor the request, it should return false from this method. The default
111 * implementation of this method does nothing and hence returns false.
112 * @param view The WebView from which the request for a new window
113 * originated.
114 * @param isDialog True if the new window should be a dialog, rather than
115 * a full-size window.
116 * @param isUserGesture True if the request was initiated by a user gesture,
117 * such as the user clicking a link.
118 * @param resultMsg The message to send when once a new WebView has been
119 * created. resultMsg.obj is a
Steve Blockb22a69f2011-10-17 11:55:37 +0100120 * {@link WebView.WebViewTransport} object. This should be
121 * used to transport the new WebView, by calling
122 * {@link WebView.WebViewTransport#setWebView(WebView)
123 * WebView.WebViewTransport.setWebView(WebView)}.
Steve Block89e00a92011-08-03 15:24:43 +0100124 * @return This method should return true if the host application will
125 * create a new window, in which case resultMsg should be sent to
126 * its target. Otherwise, this method should return false. Returning
127 * false from this method but also sending resultMsg will result in
128 * undefined behavior.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 */
Steve Block89e00a92011-08-03 15:24:43 +0100130 public boolean onCreateWindow(WebView view, boolean isDialog,
131 boolean isUserGesture, Message resultMsg) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 return false;
133 }
134
135 /**
136 * Request display and focus for this WebView. This may happen due to
137 * another WebView opening a link in this WebView and requesting that this
138 * WebView be displayed.
139 * @param view The WebView that needs to be focused.
140 */
141 public void onRequestFocus(WebView view) {}
142
143 /**
144 * Notify the host application to close the given WebView and remove it
145 * from the view system if necessary. At this point, WebCore has stopped
146 * any loading in this window and has removed any cross-scripting ability
147 * in javascript.
148 * @param window The WebView that needs to be closed.
149 */
150 public void onCloseWindow(WebView window) {}
151
152 /**
153 * Tell the client to display a javascript alert dialog. If the client
154 * returns true, WebView will assume that the client will handle the
155 * dialog. If the client returns false, it will continue execution.
156 * @param view The WebView that initiated the callback.
157 * @param url The url of the page requesting the dialog.
158 * @param message Message to be displayed in the window.
159 * @param result A JsResult to confirm that the user hit enter.
160 * @return boolean Whether the client will handle the alert dialog.
161 */
162 public boolean onJsAlert(WebView view, String url, String message,
163 JsResult result) {
164 return false;
165 }
166
167 /**
168 * Tell the client to display a confirm dialog to the user. If the client
169 * returns true, WebView will assume that the client will handle the
170 * confirm dialog and call the appropriate JsResult method. If the
171 * client returns false, a default value of false will be returned to
172 * javascript. The default behavior is to return false.
173 * @param view The WebView that initiated the callback.
174 * @param url The url of the page requesting the dialog.
175 * @param message Message to be displayed in the window.
176 * @param result A JsResult used to send the user's response to
177 * javascript.
178 * @return boolean Whether the client will handle the confirm dialog.
179 */
180 public boolean onJsConfirm(WebView view, String url, String message,
181 JsResult result) {
182 return false;
183 }
184
185 /**
186 * Tell the client to display a prompt dialog to the user. If the client
187 * returns true, WebView will assume that the client will handle the
188 * prompt dialog and call the appropriate JsPromptResult method. If the
189 * client returns false, a default value of false will be returned to to
190 * javascript. The default behavior is to return false.
191 * @param view The WebView that initiated the callback.
192 * @param url The url of the page requesting the dialog.
193 * @param message Message to be displayed in the window.
194 * @param defaultValue The default value displayed in the prompt dialog.
195 * @param result A JsPromptResult used to send the user's reponse to
196 * javascript.
197 * @return boolean Whether the client will handle the prompt dialog.
198 */
199 public boolean onJsPrompt(WebView view, String url, String message,
200 String defaultValue, JsPromptResult result) {
201 return false;
202 }
203
204 /**
205 * Tell the client to display a dialog to confirm navigation away from the
206 * current page. This is the result of the onbeforeunload javascript event.
207 * If the client returns true, WebView will assume that the client will
208 * handle the confirm dialog and call the appropriate JsResult method. If
209 * the client returns false, a default value of true will be returned to
210 * javascript to accept navigation away from the current page. The default
211 * behavior is to return false. Setting the JsResult to true will navigate
212 * away from the current page, false will cancel the navigation.
213 * @param view The WebView that initiated the callback.
214 * @param url The url of the page requesting the dialog.
215 * @param message Message to be displayed in the window.
216 * @param result A JsResult used to send the user's response to
217 * javascript.
218 * @return boolean Whether the client will handle the confirm dialog.
219 */
220 public boolean onJsBeforeUnload(WebView view, String url, String message,
221 JsResult result) {
222 return false;
223 }
Ben Murdoch7df19852009-04-22 13:07:58 +0100224
225 /**
Steve Block285ddfc2012-03-28 12:46:02 +0100226 * Tell the client that the quota has been exceeded for the Web SQL Database
227 * API for a particular origin and request a new quota. The client must
228 * respond by invoking the
229 * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
230 * method of the supplied {@link WebStorage.QuotaUpdater} instance. The
231 * minimum value that can be set for the new quota is the current quota. The
232 * default implementation responds with the current quota, so the quota will
233 * not be increased.
234 * @param url The URL of the page that triggered the notification
235 * @param databaseIdentifier The identifier of the database where the quota
236 * was exceeded.
237 * @param quota The quota for the origin, in bytes
238 * @param estimatedDatabaseSize The estimated size of the offending
239 * database, in bytes
240 * @param totalQuota The total quota for all origins, in bytes
241 * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
242 * must be used to inform the WebView of the new quota.
Jonathan Dixon5545d082013-08-31 22:43:11 -0700243 * @deprecated This method is no longer called; WebView now uses the HTML5 / JavaScript Quota
244 * Management API.
Ben Murdoch7df19852009-04-22 13:07:58 +0100245 */
Jonathan Dixon5545d082013-08-31 22:43:11 -0700246 @Deprecated
Ben Murdoch7df19852009-04-22 13:07:58 +0100247 public void onExceededDatabaseQuota(String url, String databaseIdentifier,
Steve Block285ddfc2012-03-28 12:46:02 +0100248 long quota, long estimatedDatabaseSize, long totalQuota,
249 WebStorage.QuotaUpdater quotaUpdater) {
Ben Murdoch7df19852009-04-22 13:07:58 +0100250 // This default implementation passes the current quota back to WebCore.
251 // WebCore will interpret this that new quota was declined.
Steve Block285ddfc2012-03-28 12:46:02 +0100252 quotaUpdater.updateQuota(quota);
Ben Murdoch7df19852009-04-22 13:07:58 +0100253 }
Guang Zhu10e4d202009-05-11 18:09:51 -0700254
Andrei Popescu59e2ad92009-07-28 13:38:06 +0100255 /**
Selim Gurunc86bec92012-06-28 16:47:19 -0700256 * Notify the host application that the Application Cache has reached the
257 * maximum size. The client must respond by invoking the
Steve Block285ddfc2012-03-28 12:46:02 +0100258 * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
259 * method of the supplied {@link WebStorage.QuotaUpdater} instance. The
260 * minimum value that can be set for the new quota is the current quota. The
261 * default implementation responds with the current quota, so the quota will
262 * not be increased.
263 * @param requiredStorage The amount of storage required by the Application
264 * Cache operation that triggered this notification,
265 * in bytes.
Selim Gurunc86bec92012-06-28 16:47:19 -0700266 * @param quota the current maximum Application Cache size, in bytes
Steve Block285ddfc2012-03-28 12:46:02 +0100267 * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
268 * must be used to inform the WebView of the new quota.
Jonathan Dixon5545d082013-08-31 22:43:11 -0700269 * @deprecated This method is no longer called; WebView now uses the HTML5 / JavaScript Quota
270 * Management API.
Andrei Popescu59e2ad92009-07-28 13:38:06 +0100271 */
Jonathan Dixon5545d082013-08-31 22:43:11 -0700272 @Deprecated
Steve Block285ddfc2012-03-28 12:46:02 +0100273 public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
Andrei Popescu59e2ad92009-07-28 13:38:06 +0100274 WebStorage.QuotaUpdater quotaUpdater) {
Steve Block285ddfc2012-03-28 12:46:02 +0100275 quotaUpdater.updateQuota(quota);
Andrei Popescu59e2ad92009-07-28 13:38:06 +0100276 }
277
Guang Zhu81e41432009-05-08 16:09:55 -0700278 /**
Steve Block7351adf2011-11-30 15:52:32 +0000279 * Notify the host application that web content from the specified origin
280 * is attempting to use the Geolocation API, but no permission state is
281 * currently set for that origin. The host application should invoke the
282 * specified callback with the desired permission state. See
283 * {@link GeolocationPermissions} for details.
284 * @param origin The origin of the web content attempting to use the
285 * Geolocation API.
286 * @param callback The callback to use to set the permission state for the
287 * origin.
Steve Block4faee092009-07-28 18:20:50 +0100288 */
289 public void onGeolocationPermissionsShowPrompt(String origin,
290 GeolocationPermissions.Callback callback) {}
291
292 /**
Steve Block7351adf2011-11-30 15:52:32 +0000293 * Notify the host application that a request for Geolocation permissions,
294 * made with a previous call to
295 * {@link #onGeolocationPermissionsShowPrompt(String,GeolocationPermissions.Callback) onGeolocationPermissionsShowPrompt()}
296 * has been canceled. Any related UI should therefore be hidden.
Steve Block4faee092009-07-28 18:20:50 +0100297 */
298 public void onGeolocationPermissionsHidePrompt() {}
299
300 /**
Tao Bai4c22b542014-04-15 18:04:49 +0000301 * Notify the host application that web content is requesting permission to
302 * access the specified resources and the permission currently isn't granted
Tao Bai2871feb2014-07-16 13:54:15 -0700303 * or denied. The host application must invoke {@link PermissionRequest#grant(String[])}
Tao Bai4c22b542014-04-15 18:04:49 +0000304 * or {@link PermissionRequest#deny()}.
305 *
306 * If this method isn't overridden, the permission is denied.
307 *
308 * @param request the PermissionRequest from current web content.
Tao Bai4c22b542014-04-15 18:04:49 +0000309 */
310 public void onPermissionRequest(PermissionRequest request) {
311 request.deny();
312 }
313
314 /**
315 * Notify the host application that the given permission request
316 * has been canceled. Any related UI should therefore be hidden.
317 *
Tao Baifa1fd2c2014-04-30 13:31:34 -0700318 * @param request the PermissionRequest that needs be canceled.
Tao Bai4c22b542014-04-15 18:04:49 +0000319 */
320 public void onPermissionRequestCanceled(PermissionRequest request) {}
321
322 /**
Guang Zhu81e41432009-05-08 16:09:55 -0700323 * Tell the client that a JavaScript execution timeout has occured. And the
324 * client may decide whether or not to interrupt the execution. If the
325 * client returns true, the JavaScript will be interrupted. If the client
326 * returns false, the execution will continue. Note that in the case of
327 * continuing execution, the timeout counter will be reset, and the callback
328 * will continue to occur if the script does not finish at the next check
329 * point.
330 * @return boolean Whether the JavaScript execution should be interrupted.
Ben Murdoch1bd37b12012-05-28 12:42:39 +0100331 * @deprecated This method is no longer supported and will not be invoked.
Guang Zhu81e41432009-05-08 16:09:55 -0700332 */
Ben Murdoch1bd37b12012-05-28 12:42:39 +0100333 // This method was only called when using the JSC javascript engine. V8 became
334 // the default JS engine with Froyo and support for building with JSC was
335 // removed in b/5495373. V8 does not have a mechanism for making a callback such
336 // as this.
Guang Zhu81e41432009-05-08 16:09:55 -0700337 public boolean onJsTimeout() {
338 return true;
339 }
Ben Murdoch6262ae52009-04-17 13:21:53 +0100340
341 /**
Ben Murdoch7caaeec2009-11-19 18:14:53 +0000342 * Report a JavaScript error message to the host application. The ChromeClient
343 * should override this to process the log message as they see fit.
Ben Murdoch6262ae52009-04-17 13:21:53 +0100344 * @param message The error message to report.
345 * @param lineNumber The line number of the error.
346 * @param sourceID The name of the source file that caused the error.
Ben Murdoch3141e0a2010-01-28 15:06:32 +0000347 * @deprecated Use {@link #onConsoleMessage(ConsoleMessage) onConsoleMessage(ConsoleMessage)}
348 * instead.
Ben Murdoch6262ae52009-04-17 13:21:53 +0100349 */
Ben Murdoch3141e0a2010-01-28 15:06:32 +0000350 @Deprecated
351 public void onConsoleMessage(String message, int lineNumber, String sourceID) { }
352
353 /**
354 * Report a JavaScript console message to the host application. The ChromeClient
355 * should override this to process the log message as they see fit.
356 * @param consoleMessage Object containing details of the console message.
357 * @return true if the message is handled by the client.
358 */
359 public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
360 // Call the old version of this function for backwards compatability.
361 onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(),
362 consoleMessage.sourceId());
363 return false;
364 }
Andrei Popescubf385d72009-09-18 18:59:52 +0100365
366 /**
Ben Murdochf0c443d2009-11-19 16:43:58 +0000367 * When not playing, video elements are represented by a 'poster' image. The
368 * image to use can be specified by the poster attribute of the video tag in
369 * HTML. If the attribute is absent, then a default poster will be used. This
370 * method allows the ChromeClient to provide that default image.
Andrei Popescubf385d72009-09-18 18:59:52 +0100371 *
Ben Murdochf0c443d2009-11-19 16:43:58 +0000372 * @return Bitmap The image to use as a default poster, or null if no such image is
373 * available.
Andrei Popescubf385d72009-09-18 18:59:52 +0100374 */
375 public Bitmap getDefaultVideoPoster() {
376 return null;
377 }
378
379 /**
Ben Murdochf0c443d2009-11-19 16:43:58 +0000380 * When the user starts to playback a video element, it may take time for enough
381 * data to be buffered before the first frames can be rendered. While this buffering
382 * is taking place, the ChromeClient can use this function to provide a View to be
383 * displayed. For example, the ChromeClient could show a spinner animation.
Andrei Popescubf385d72009-09-18 18:59:52 +0100384 *
Ben Murdochf0c443d2009-11-19 16:43:58 +0000385 * @return View The View to be displayed whilst the video is loading.
Andrei Popescubf385d72009-09-18 18:59:52 +0100386 */
387 public View getVideoLoadingProgressView() {
388 return null;
389 }
Leon Clarke194e3452009-09-28 11:42:12 +0100390
391 /** Obtains a list of all visited history items, used for link coloring
Leon Clarke194e3452009-09-28 11:42:12 +0100392 */
393 public void getVisitedHistory(ValueCallback<String[]> callback) {
394 }
395
Leon Scroggins70ca3c22009-10-02 15:58:55 -0400396 /**
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700397 * Tell the client to show a file chooser.
398 *
399 * This is called to handle HTML forms with 'file' input type, in response to the
400 * user pressing the "Select File" button.
401 * To cancel the request, call <code>filePathCallback.onReceiveValue(null)</code> and
402 * return true.
403 *
404 * @param webView The WebView instance that is initiating the request.
405 * @param filePathCallback Invoke this callback to supply the list of paths to files to upload,
406 * or NULL to cancel. Must only be called if the
407 * <code>showFileChooser</code> implementations returns true.
408 * @param fileChooserParams Describes the mode of file chooser to be opened, and options to be
409 * used with it.
410 * @return true if filePathCallback will be invoked, false to use default handling.
411 *
412 * @see FileChooserParams
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700413 */
Selim Gurun48f6c452014-07-18 16:23:46 -0700414 public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700415 FileChooserParams fileChooserParams) {
416 return false;
417 }
418
419 /**
Selim Gurun48f6c452014-07-18 16:23:46 -0700420 * Parameters used in the {@link #onShowFileChooser} method.
421 */
422 public static abstract class FileChooserParams {
423 /** Open single file. Requires that the file exists before allowing the user to pick it. */
Selim Gurun17d1adb2014-08-27 11:22:26 -0700424 public static final int MODE_OPEN = 0;
Selim Gurun48f6c452014-07-18 16:23:46 -0700425 /** Like Open but allows multiple files to be selected. */
Selim Gurun17d1adb2014-08-27 11:22:26 -0700426 public static final int MODE_OPEN_MULTIPLE = 1;
Selim Gurun48f6c452014-07-18 16:23:46 -0700427 /** Like Open but allows a folder to be selected. The implementation should enumerate
Selim Gurun17d1adb2014-08-27 11:22:26 -0700428 all files selected by this operation.
429 This feature is not supported at the moment.
430 @hide */
431 public static final int MODE_OPEN_FOLDER = 2;
Selim Gurun48f6c452014-07-18 16:23:46 -0700432 /** Allows picking a nonexistent file and saving it. */
Selim Gurun17d1adb2014-08-27 11:22:26 -0700433 public static final int MODE_SAVE = 3;
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700434
435 /**
Tao Baie8df27a2014-09-02 14:09:49 -0700436 * Parse the result returned by the file picker activity. This method should be used with
437 * {@link #createIntent}. Refer to {@link #createIntent} for how to use it.
438 *
439 * @param resultCode the integer result code returned by the file picker activity.
440 * @param data the intent returned by the file picker activity.
441 * @return the Uris of selected file(s) or null if the resultCode indicates
442 * activity canceled or any other error.
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700443 */
Tao Baie8df27a2014-09-02 14:09:49 -0700444 public static Uri[] parseResult(int resultCode, Intent data) {
445 return WebViewFactory.getProvider().getStatics().parseFileChooserResult(resultCode, data);
446 }
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700447
448 /**
Selim Gurun48f6c452014-07-18 16:23:46 -0700449 * Returns file chooser mode.
450 */
451 public abstract int getMode();
452
453 /**
Selim Gurun17d1adb2014-08-27 11:22:26 -0700454 * Returns an array of acceptable MIME types. The returned MIME type
455 * could be partial such as audio/*. The array will be empty if no
Selim Gurun48f6c452014-07-18 16:23:46 -0700456 * acceptable types are specified.
457 */
458 public abstract String[] getAcceptTypes();
459
460 /**
461 * Returns preference for a live media captured value (e.g. Camera, Microphone).
462 * True indicates capture is enabled, false disabled.
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700463 *
Selim Gurun48f6c452014-07-18 16:23:46 -0700464 * Use <code>getAcceptTypes</code> to determine suitable capture devices.
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700465 */
Selim Gurun48f6c452014-07-18 16:23:46 -0700466 public abstract boolean isCaptureEnabled();
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700467
468 /**
Selim Gurun48f6c452014-07-18 16:23:46 -0700469 * Returns the title to use for this file selector, or null. If null a default
470 * title should be used.
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700471 */
Selim Gurun48f6c452014-07-18 16:23:46 -0700472 public abstract CharSequence getTitle();
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700473
474 /**
Selim Gurun17d1adb2014-08-27 11:22:26 -0700475 * The file name of a default selection if specified, or null.
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700476 */
Selim Gurun17d1adb2014-08-27 11:22:26 -0700477 public abstract String getFilenameHint();
Tao Baie8df27a2014-09-02 14:09:49 -0700478
479 /**
480 * Creates an intent that would start a file picker for file selection.
481 * The Intent supports choosing files from simple file sources available
482 * on the device. Some advanced sources (for example, live media capture)
483 * may not be supported and applications wishing to support these sources
484 * or more advanced file operations should build their own Intent.
485 *
486 * <pre>
487 * How to use:
488 * 1. Build an intent using {@link #createIntent}
489 * 2. Fire the intent using {@link android.app.Activity#startActivityForResult}.
490 * 3. Check for ActivityNotFoundException and take a user friendly action if thrown.
491 * 4. Listen the result using {@link android.app.Activity#onActivityResult}
492 * 5. Parse the result using {@link #parseResult} only if media capture was not requested.
493 * 6. Send the result using filePathCallback of {@link WebChromeClient#onShowFileChooser}
494 * </pre>
495 *
496 * @return an Intent that supports basic file chooser sources.
497 */
498 public abstract Intent createIntent();
499 }
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700500
501 /**
Leon Scroggins70ca3c22009-10-02 15:58:55 -0400502 * Tell the client to open a file chooser.
503 * @param uploadFile A ValueCallback to set the URI of the file to upload.
Ben Murdoch4ae32f52010-05-18 14:30:39 +0100504 * onReceiveValue must be called to wake up the thread.a
505 * @param acceptType The value of the 'accept' attribute of the input tag
506 * associated with this file picker.
Ben Murdochbe716922012-01-11 10:55:10 +0000507 * @param capture The value of the 'capture' attribute of the input tag
508 * associated with this file picker.
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700509 *
510 * @deprecated Use {@link #showFileChooser} instead.
511 * @hide This method was not published in any SDK version.
Leon Scroggins70ca3c22009-10-02 15:58:55 -0400512 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000513 @SystemApi
Jonathan Dixon3a5cf382013-07-27 15:37:31 -0700514 @Deprecated
Ben Murdochbe716922012-01-11 10:55:10 +0000515 public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) {
Leon Scroggins70ca3c22009-10-02 15:58:55 -0400516 uploadFile.onReceiveValue(null);
517 }
Cary Clark924af702010-06-04 16:37:43 -0400518
519 /**
Ben Murdoch57914382010-11-16 11:50:39 +0000520 * Tell the client that the page being viewed has an autofillable
521 * form and the user would like to set a profile up.
522 * @param msg A Message to send once the user has successfully
523 * set up a profile and to inform the WebTextView it should
524 * now autofill using that new profile.
525 * @hide
526 */
527 public void setupAutoFill(Message msg) { }
528
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800529}