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 /** 219285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * Tell the client that the quota has been exceeded for the Web SQL Database 220285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * API for a particular origin and request a new quota. The client must 221285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * respond by invoking the 222285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)} 223285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * method of the supplied {@link WebStorage.QuotaUpdater} instance. The 224285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * minimum value that can be set for the new quota is the current quota. The 225285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * default implementation responds with the current quota, so the quota will 226285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * not be increased. 227285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param url The URL of the page that triggered the notification 228285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param databaseIdentifier The identifier of the database where the quota 229285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * was exceeded. 230285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param quota The quota for the origin, in bytes 231285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param estimatedDatabaseSize The estimated size of the offending 232285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * database, in bytes 233285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param totalQuota The total quota for all origins, in bytes 234285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which 235285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * must be used to inform the WebView of the new quota. 2367df1985e86635af006be3dfa65987d60e290b5deBen Murdoch */ 237285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block // Note that the callback must always be executed at some point to ensure 238285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block // that the sleeping WebCore thread is woken up. 2397df1985e86635af006be3dfa65987d60e290b5deBen Murdoch public void onExceededDatabaseQuota(String url, String databaseIdentifier, 240285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block long quota, long estimatedDatabaseSize, long totalQuota, 241285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block WebStorage.QuotaUpdater quotaUpdater) { 2427df1985e86635af006be3dfa65987d60e290b5deBen Murdoch // This default implementation passes the current quota back to WebCore. 2437df1985e86635af006be3dfa65987d60e290b5deBen Murdoch // WebCore will interpret this that new quota was declined. 244285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block quotaUpdater.updateQuota(quota); 2457df1985e86635af006be3dfa65987d60e290b5deBen Murdoch } 24610e4d2068aa687e30dd4e5fcae6417f66874823bGuang Zhu 24759e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu /** 248c86bec97279c4a5872d78fe371577748ddf43dcfSelim Gurun * Notify the host application that the Application Cache has reached the 249c86bec97279c4a5872d78fe371577748ddf43dcfSelim Gurun * maximum size. The client must respond by invoking the 250285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)} 251285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * method of the supplied {@link WebStorage.QuotaUpdater} instance. The 252285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * minimum value that can be set for the new quota is the current quota. The 253285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * default implementation responds with the current quota, so the quota will 254285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * not be increased. 255285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param requiredStorage The amount of storage required by the Application 256285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * Cache operation that triggered this notification, 257285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * in bytes. 258c86bec97279c4a5872d78fe371577748ddf43dcfSelim Gurun * @param quota the current maximum Application Cache size, in bytes 259285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which 260285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * must be used to inform the WebView of the new quota. 26159e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu */ 262285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block // Note that the callback must always be executed at some point to ensure 263285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block // that the sleeping WebCore thread is woken up. 264285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block public void onReachedMaxAppCacheSize(long requiredStorage, long quota, 26559e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu WebStorage.QuotaUpdater quotaUpdater) { 266285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block quotaUpdater.updateQuota(quota); 26759e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu } 26859e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu 26981e41434b3421a89e3e967e866238719e8468bd5Guang Zhu /** 2707351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Notify the host application that web content from the specified origin 2717351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * is attempting to use the Geolocation API, but no permission state is 2727351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * currently set for that origin. The host application should invoke the 2737351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * specified callback with the desired permission state. See 2747351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * {@link GeolocationPermissions} for details. 2757351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * @param origin The origin of the web content attempting to use the 2767351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Geolocation API. 2777351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * @param callback The callback to use to set the permission state for the 2787351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * origin. 2794faee09c422a70439129e9fb40dd82f03d42c98dSteve Block */ 2804faee09c422a70439129e9fb40dd82f03d42c98dSteve Block public void onGeolocationPermissionsShowPrompt(String origin, 2814faee09c422a70439129e9fb40dd82f03d42c98dSteve Block GeolocationPermissions.Callback callback) {} 2824faee09c422a70439129e9fb40dd82f03d42c98dSteve Block 2834faee09c422a70439129e9fb40dd82f03d42c98dSteve Block /** 2847351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Notify the host application that a request for Geolocation permissions, 2857351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * made with a previous call to 2867351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * {@link #onGeolocationPermissionsShowPrompt(String,GeolocationPermissions.Callback) onGeolocationPermissionsShowPrompt()} 2877351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * has been canceled. Any related UI should therefore be hidden. 2884faee09c422a70439129e9fb40dd82f03d42c98dSteve Block */ 2894faee09c422a70439129e9fb40dd82f03d42c98dSteve Block public void onGeolocationPermissionsHidePrompt() {} 2904faee09c422a70439129e9fb40dd82f03d42c98dSteve Block 2914faee09c422a70439129e9fb40dd82f03d42c98dSteve Block /** 29281e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * Tell the client that a JavaScript execution timeout has occured. And the 29381e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * client may decide whether or not to interrupt the execution. If the 29481e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * client returns true, the JavaScript will be interrupted. If the client 29581e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * returns false, the execution will continue. Note that in the case of 29681e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * continuing execution, the timeout counter will be reset, and the callback 29781e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * will continue to occur if the script does not finish at the next check 29881e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * point. 29981e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * @return boolean Whether the JavaScript execution should be interrupted. 3001bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch * @deprecated This method is no longer supported and will not be invoked. 30181e41434b3421a89e3e967e866238719e8468bd5Guang Zhu */ 3021bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // This method was only called when using the JSC javascript engine. V8 became 3031bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // the default JS engine with Froyo and support for building with JSC was 3041bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // removed in b/5495373. V8 does not have a mechanism for making a callback such 3051bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // as this. 30681e41434b3421a89e3e967e866238719e8468bd5Guang Zhu public boolean onJsTimeout() { 30781e41434b3421a89e3e967e866238719e8468bd5Guang Zhu return true; 30881e41434b3421a89e3e967e866238719e8468bd5Guang Zhu } 3096262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch 3106262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch /** 3117caaeecce1b04e2098dd4f471fdd69ebe28c31b0Ben Murdoch * Report a JavaScript error message to the host application. The ChromeClient 3127caaeecce1b04e2098dd4f471fdd69ebe28c31b0Ben Murdoch * should override this to process the log message as they see fit. 3136262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param message The error message to report. 3146262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param lineNumber The line number of the error. 3156262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param sourceID The name of the source file that caused the error. 3163141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @deprecated Use {@link #onConsoleMessage(ConsoleMessage) onConsoleMessage(ConsoleMessage)} 3173141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * instead. 3186262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch */ 3193141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch @Deprecated 3203141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch public void onConsoleMessage(String message, int lineNumber, String sourceID) { } 3213141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch 3223141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch /** 3233141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * Report a JavaScript console message to the host application. The ChromeClient 3243141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * should override this to process the log message as they see fit. 3253141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @param consoleMessage Object containing details of the console message. 3263141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @return true if the message is handled by the client. 3273141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch */ 3283141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch public boolean onConsoleMessage(ConsoleMessage consoleMessage) { 3293141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch // Call the old version of this function for backwards compatability. 3303141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(), 3313141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch consoleMessage.sourceId()); 3323141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch return false; 3333141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch } 334bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu 335bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu /** 336f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * When not playing, video elements are represented by a 'poster' image. The 337f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * image to use can be specified by the poster attribute of the video tag in 338f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * HTML. If the attribute is absent, then a default poster will be used. This 339f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * method allows the ChromeClient to provide that default image. 340bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu * 341f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * @return Bitmap The image to use as a default poster, or null if no such image is 342f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * available. 343bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu */ 344bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu public Bitmap getDefaultVideoPoster() { 345bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu return null; 346bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu } 347bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu 348bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu /** 349f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * When the user starts to playback a video element, it may take time for enough 350f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * data to be buffered before the first frames can be rendered. While this buffering 351f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * is taking place, the ChromeClient can use this function to provide a View to be 352f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * displayed. For example, the ChromeClient could show a spinner animation. 353bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu * 354f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * @return View The View to be displayed whilst the video is loading. 355bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu */ 356bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu public View getVideoLoadingProgressView() { 357bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu return null; 358bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu } 359194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke 360194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke /** Obtains a list of all visited history items, used for link coloring 361194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke */ 362194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke public void getVisitedHistory(ValueCallback<String[]> callback) { 363194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke } 364194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke 36570ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins /** 36670ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * Tell the client to open a file chooser. 36770ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * @param uploadFile A ValueCallback to set the URI of the file to upload. 3684ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * onReceiveValue must be called to wake up the thread.a 3694ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * @param acceptType The value of the 'accept' attribute of the input tag 3704ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * associated with this file picker. 371be716920e70541c9b334c9389d335f1aa1ed7124Ben Murdoch * @param capture The value of the 'capture' attribute of the input tag 372be716920e70541c9b334c9389d335f1aa1ed7124Ben Murdoch * associated with this file picker. 37370ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * @hide 37470ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins */ 375be716920e70541c9b334c9389d335f1aa1ed7124Ben Murdoch public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) { 37670ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins uploadFile.onReceiveValue(null); 37770ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins } 378924af70019f1cc82d850a0c29c2606a2f4faf5cfCary Clark 379924af70019f1cc82d850a0c29c2606a2f4faf5cfCary Clark /** 38057914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * Tell the client that the page being viewed has an autofillable 38157914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * form and the user would like to set a profile up. 38257914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * @param msg A Message to send once the user has successfully 38357914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * set up a profile and to inform the WebTextView it should 38457914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * now autofill using that new profile. 38557914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * @hide 38657914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch */ 38757914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch public void setupAutoFill(Message msg) { } 38857914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch 3899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 390