WebChromeClient.java revision 7351adf76a97b07bb2d777c56e78752cb7834bb0
19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/* 29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project 39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License. 69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at 79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and 149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License. 159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.webkit; 189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 197ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenbergerimport android.content.pm.ActivityInfo; 209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.graphics.Bitmap; 2170ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scrogginsimport android.net.Uri; 229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.Message; 236fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescuimport android.view.View; 249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class WebChromeClient { 269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the host application the current progress of loading a page. 299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param newProgress Current page loading progress, represented by 319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * an integer between 0 and 100. 329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onProgressChanged(WebView view, int newProgress) {} 349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Notify the host application of a change in the document title. 379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param title A String containing the new title of the document. 399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onReceivedTitle(WebView view, String title) {} 419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Notify the host application of a new favicon for the current page. 449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param icon A Bitmap containing the favicon for the current page. 469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onReceivedIcon(WebView view, Bitmap icon) {} 489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 502ba1262b420ef5b9abebcd818c46774b8517f244Patrick Scott * Notify the host application of the url for an apple-touch-icon. 512ba1262b420ef5b9abebcd818c46774b8517f244Patrick Scott * @param view The WebView that initiated the callback. 522ba1262b420ef5b9abebcd818c46774b8517f244Patrick Scott * @param url The icon url. 53d58ccff769e40a6c52e9f6e30e4016590e05ba9aPatrick Scott * @param precomposed True if the url is for a precomposed touch icon. 542ba1262b420ef5b9abebcd818c46774b8517f244Patrick Scott */ 55d58ccff769e40a6c52e9f6e30e4016590e05ba9aPatrick Scott public void onReceivedTouchIconUrl(WebView view, String url, 56d58ccff769e40a6c52e9f6e30e4016590e05ba9aPatrick Scott boolean precomposed) {} 572ba1262b420ef5b9abebcd818c46774b8517f244Patrick Scott 582ba1262b420ef5b9abebcd818c46774b8517f244Patrick Scott /** 593c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * A callback interface used by the host application to notify 603c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * the current page that its custom view has been dismissed. 613c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu */ 623c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu public interface CustomViewCallback { 633c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu /** 643c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * Invoked when the host application dismisses the 653c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * custom view. 663c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu */ 673c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu public void onCustomViewHidden(); 683c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu } 693c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu 703c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu /** 716fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * Notify the host application that the current page would 726fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * like to show a custom View. 736fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * @param view is the View object to be shown. 743c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * @param callback is the callback to be invoked if and when the view 753c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * is dismissed. 766fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu */ 773c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu public void onShowCustomView(View view, CustomViewCallback callback) {}; 786fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu 796fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu /** 806fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * Notify the host application that the current page would 817ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * like to show a custom View in a particular orientation. 827ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * @param view is the View object to be shown. 837ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * @param requestedOrientation An orientation constant as used in 847ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}. 857ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * @param callback is the callback to be invoked if and when the view 867ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * is dismissed. 877ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger */ 887ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger public void onShowCustomView(View view, int requestedOrientation, 897ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger CustomViewCallback callback) {}; 907ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger 917ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger /** 927ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * Notify the host application that the current page would 936fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * like to hide its custom view. 946fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu */ 956fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu public void onHideCustomView() {} 966fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu 976fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu /** 9889e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * Request the host application to create a new window. If the host 9989e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * application chooses to honor this request, it should return true from 10089e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * this method, create a new WebView to host the window, insert it into the 10189e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * View system and send the supplied resultMsg message to its target with 10289e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * the new WebView as an argument. If the host application chooses not to 10389e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * honor the request, it should return false from this method. The default 10489e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * implementation of this method does nothing and hence returns false. 10589e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param view The WebView from which the request for a new window 10689e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * originated. 10789e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param isDialog True if the new window should be a dialog, rather than 10889e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * a full-size window. 10989e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param isUserGesture True if the request was initiated by a user gesture, 11089e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * such as the user clicking a link. 11189e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param resultMsg The message to send when once a new WebView has been 11289e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * created. resultMsg.obj is a 113b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * {@link WebView.WebViewTransport} object. This should be 114b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * used to transport the new WebView, by calling 115b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * {@link WebView.WebViewTransport#setWebView(WebView) 116b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * WebView.WebViewTransport.setWebView(WebView)}. 11789e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @return This method should return true if the host application will 11889e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * create a new window, in which case resultMsg should be sent to 11989e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * its target. Otherwise, this method should return false. Returning 12089e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * false from this method but also sending resultMsg will result in 12189e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * undefined behavior. 1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 12389e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block public boolean onCreateWindow(WebView view, boolean isDialog, 12489e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block boolean isUserGesture, Message resultMsg) { 1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Request display and focus for this WebView. This may happen due to 1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * another WebView opening a link in this WebView and requesting that this 1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WebView be displayed. 1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that needs to be focused. 1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onRequestFocus(WebView view) {} 1359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Notify the host application to close the given WebView and remove it 1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * from the view system if necessary. At this point, WebCore has stopped 1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * any loading in this window and has removed any cross-scripting ability 1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * in javascript. 1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param window The WebView that needs to be closed. 1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onCloseWindow(WebView window) {} 1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a javascript alert dialog. If the client 1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * returns true, WebView will assume that the client will handle the 1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * dialog. If the client returns false, it will continue execution. 1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsResult to confirm that the user hit enter. 1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the alert dialog. 1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsAlert(WebView view, String url, String message, 1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project JsResult result) { 1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a confirm dialog to the user. If the client 1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * returns true, WebView will assume that the client will handle the 1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * confirm dialog and call the appropriate JsResult method. If the 1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * client returns false, a default value of false will be returned to 1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. The default behavior is to return false. 1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsResult used to send the user's response to 1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. 1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the confirm dialog. 1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsConfirm(WebView view, String url, String message, 1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project JsResult result) { 1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a prompt dialog to the user. If the client 1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * returns true, WebView will assume that the client will handle the 1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * prompt dialog and call the appropriate JsPromptResult method. If the 1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * client returns false, a default value of false will be returned to to 1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. The default behavior is to return false. 1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param defaultValue The default value displayed in the prompt dialog. 1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsPromptResult used to send the user's reponse to 1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. 1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the prompt dialog. 1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsPrompt(WebView view, String url, String message, 1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project String defaultValue, JsPromptResult result) { 1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a dialog to confirm navigation away from the 1999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * current page. This is the result of the onbeforeunload javascript event. 2009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * If the client returns true, WebView will assume that the client will 2019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * handle the confirm dialog and call the appropriate JsResult method. If 2029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the client returns false, a default value of true will be returned to 2039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript to accept navigation away from the current page. The default 2049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * behavior is to return false. Setting the JsResult to true will navigate 2059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * away from the current page, false will cancel the navigation. 2069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 2079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsResult used to send the user's response to 2109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. 2119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the confirm dialog. 2129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 2139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsBeforeUnload(WebView view, String url, String message, 2149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project JsResult result) { 2159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 2169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2177df1985e86635af006be3dfa65987d60e290b5deBen Murdoch 2187df1985e86635af006be3dfa65987d60e290b5deBen Murdoch /** 2197df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * Tell the client that the database quota for the origin has been exceeded. 2207df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * @param url The URL that triggered the notification 2217df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * @param databaseIdentifier The identifier of the database that caused the 2227df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * quota overflow. 2237df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * @param currentQuota The current quota for the origin. 224d497d87650dd79f7d6a4751d79598d68ceb4b789Ben Murdoch * @param estimatedSize The estimated size of the database. 22559e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * @param totalUsedQuota is the sum of all origins' quota. 2267df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * @param quotaUpdater A callback to inform the WebCore thread that a new 2277df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * quota is available. This callback must always be executed at some 2287df1985e86635af006be3dfa65987d60e290b5deBen Murdoch * point to ensure that the sleeping WebCore thread is woken up. 2297df1985e86635af006be3dfa65987d60e290b5deBen Murdoch */ 2307df1985e86635af006be3dfa65987d60e290b5deBen Murdoch public void onExceededDatabaseQuota(String url, String databaseIdentifier, 231d497d87650dd79f7d6a4751d79598d68ceb4b789Ben Murdoch long currentQuota, long estimatedSize, long totalUsedQuota, 23259e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu WebStorage.QuotaUpdater quotaUpdater) { 2337df1985e86635af006be3dfa65987d60e290b5deBen Murdoch // This default implementation passes the current quota back to WebCore. 2347df1985e86635af006be3dfa65987d60e290b5deBen Murdoch // WebCore will interpret this that new quota was declined. 2357df1985e86635af006be3dfa65987d60e290b5deBen Murdoch quotaUpdater.updateQuota(currentQuota); 2367df1985e86635af006be3dfa65987d60e290b5deBen Murdoch } 23710e4d2068aa687e30dd4e5fcae6417f66874823bGuang Zhu 23859e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu /** 23959e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * Tell the client that the Application Cache has exceeded its max size. 24059e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * @param spaceNeeded is the amount of disk space that would be needed 24159e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * in order for the last appcache operation to succeed. 24259e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * @param totalUsedQuota is the sum of all origins' quota. 24359e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * @param quotaUpdater A callback to inform the WebCore thread that a new 24459e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * app cache size is available. This callback must always be executed at 24559e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu * some point to ensure that the sleeping WebCore thread is woken up. 24659e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu */ 24759e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota, 24859e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu WebStorage.QuotaUpdater quotaUpdater) { 24959e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu quotaUpdater.updateQuota(0); 25059e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu } 25159e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu 25281e41434b3421a89e3e967e866238719e8468bd5Guang Zhu /** 2537351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Notify the host application that web content from the specified origin 2547351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * is attempting to use the Geolocation API, but no permission state is 2557351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * currently set for that origin. The host application should invoke the 2567351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * specified callback with the desired permission state. See 2577351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * {@link GeolocationPermissions} for details. 2587351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * @param origin The origin of the web content attempting to use the 2597351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Geolocation API. 2607351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * @param callback The callback to use to set the permission state for the 2617351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * origin. 2624faee09c422a70439129e9fb40dd82f03d42c98dSteve Block */ 2634faee09c422a70439129e9fb40dd82f03d42c98dSteve Block public void onGeolocationPermissionsShowPrompt(String origin, 2644faee09c422a70439129e9fb40dd82f03d42c98dSteve Block GeolocationPermissions.Callback callback) {} 2654faee09c422a70439129e9fb40dd82f03d42c98dSteve Block 2664faee09c422a70439129e9fb40dd82f03d42c98dSteve Block /** 2677351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Notify the host application that a request for Geolocation permissions, 2687351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * made with a previous call to 2697351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * {@link #onGeolocationPermissionsShowPrompt(String,GeolocationPermissions.Callback) onGeolocationPermissionsShowPrompt()} 2707351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * has been canceled. Any related UI should therefore be hidden. 2714faee09c422a70439129e9fb40dd82f03d42c98dSteve Block */ 2724faee09c422a70439129e9fb40dd82f03d42c98dSteve Block public void onGeolocationPermissionsHidePrompt() {} 2734faee09c422a70439129e9fb40dd82f03d42c98dSteve Block 2744faee09c422a70439129e9fb40dd82f03d42c98dSteve Block /** 27581e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * Tell the client that a JavaScript execution timeout has occured. And the 27681e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * client may decide whether or not to interrupt the execution. If the 27781e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * client returns true, the JavaScript will be interrupted. If the client 27881e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * returns false, the execution will continue. Note that in the case of 27981e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * continuing execution, the timeout counter will be reset, and the callback 28081e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * will continue to occur if the script does not finish at the next check 28181e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * point. 28281e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * @return boolean Whether the JavaScript execution should be interrupted. 28381e41434b3421a89e3e967e866238719e8468bd5Guang Zhu */ 28481e41434b3421a89e3e967e866238719e8468bd5Guang Zhu public boolean onJsTimeout() { 28581e41434b3421a89e3e967e866238719e8468bd5Guang Zhu return true; 28681e41434b3421a89e3e967e866238719e8468bd5Guang Zhu } 2876262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch 2886262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch /** 2897caaeecce1b04e2098dd4f471fdd69ebe28c31b0Ben Murdoch * Report a JavaScript error message to the host application. The ChromeClient 2907caaeecce1b04e2098dd4f471fdd69ebe28c31b0Ben Murdoch * should override this to process the log message as they see fit. 2916262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param message The error message to report. 2926262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param lineNumber The line number of the error. 2936262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param sourceID The name of the source file that caused the error. 2943141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @deprecated Use {@link #onConsoleMessage(ConsoleMessage) onConsoleMessage(ConsoleMessage)} 2953141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * instead. 2966262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch */ 2973141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch @Deprecated 2983141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch public void onConsoleMessage(String message, int lineNumber, String sourceID) { } 2993141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch 3003141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch /** 3013141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * Report a JavaScript console message to the host application. The ChromeClient 3023141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * should override this to process the log message as they see fit. 3033141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @param consoleMessage Object containing details of the console message. 3043141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @return true if the message is handled by the client. 3053141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch */ 3063141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch public boolean onConsoleMessage(ConsoleMessage consoleMessage) { 3073141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch // Call the old version of this function for backwards compatability. 3083141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(), 3093141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch consoleMessage.sourceId()); 3103141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch return false; 3113141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch } 312bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu 313bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu /** 314f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * When not playing, video elements are represented by a 'poster' image. The 315f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * image to use can be specified by the poster attribute of the video tag in 316f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * HTML. If the attribute is absent, then a default poster will be used. This 317f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * method allows the ChromeClient to provide that default image. 318bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu * 319f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * @return Bitmap The image to use as a default poster, or null if no such image is 320f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * available. 321bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu */ 322bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu public Bitmap getDefaultVideoPoster() { 323bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu return null; 324bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu } 325bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu 326bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu /** 327f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * When the user starts to playback a video element, it may take time for enough 328f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * data to be buffered before the first frames can be rendered. While this buffering 329f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * is taking place, the ChromeClient can use this function to provide a View to be 330f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * displayed. For example, the ChromeClient could show a spinner animation. 331bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu * 332f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * @return View The View to be displayed whilst the video is loading. 333bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu */ 334bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu public View getVideoLoadingProgressView() { 335bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu return null; 336bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu } 337194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke 338194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke /** Obtains a list of all visited history items, used for link coloring 339194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke */ 340194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke public void getVisitedHistory(ValueCallback<String[]> callback) { 341194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke } 342194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke 34370ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins /** 34470ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * Tell the client to open a file chooser. 34570ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * @param uploadFile A ValueCallback to set the URI of the file to upload. 3464ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * onReceiveValue must be called to wake up the thread.a 3474ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * @param acceptType The value of the 'accept' attribute of the input tag 3484ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * associated with this file picker. 34970ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * @hide 35070ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins */ 3514ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType) { 35270ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins uploadFile.onReceiveValue(null); 35370ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins } 354924af70019f1cc82d850a0c29c2606a2f4faf5cfCary Clark 355924af70019f1cc82d850a0c29c2606a2f4faf5cfCary Clark /** 3566312de2a9a2cf7304d91b7f78c3dff2db59b918cBen Murdoch * Tell the client that the page being viewed is web app capable, 3576312de2a9a2cf7304d91b7f78c3dff2db59b918cBen Murdoch * i.e. has specified the fullscreen-web-app-capable meta tag. 3586312de2a9a2cf7304d91b7f78c3dff2db59b918cBen Murdoch * @hide 3596312de2a9a2cf7304d91b7f78c3dff2db59b918cBen Murdoch */ 3606312de2a9a2cf7304d91b7f78c3dff2db59b918cBen Murdoch public void setInstallableWebApp() { } 3616312de2a9a2cf7304d91b7f78c3dff2db59b918cBen Murdoch 36257914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch /** 36357914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * Tell the client that the page being viewed has an autofillable 36457914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * form and the user would like to set a profile up. 36557914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * @param msg A Message to send once the user has successfully 36657914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * set up a profile and to inform the WebTextView it should 36757914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * now autofill using that new profile. 36857914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * @hide 36957914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch */ 37057914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch public void setupAutoFill(Message msg) { } 37157914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch 3729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 373