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 720e0b2daa983a7d9587bb761d5a018b698482e0a1Kristian Monsen * like to show a custom View. This is used for Fullscreen 730e0b2daa983a7d9587bb761d5a018b698482e0a1Kristian Monsen * video playback; see "HTML5 Video support" documentation on 740e0b2daa983a7d9587bb761d5a018b698482e0a1Kristian Monsen * {@link WebView}. 756fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * @param view is the View object to be shown. 763c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * @param callback is the callback to be invoked if and when the view 773c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu * is dismissed. 786fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu */ 793c946a1a9637e85e4256f40b68f3b9d4b9f40c27Andrei Popescu public void onShowCustomView(View view, CustomViewCallback callback) {}; 806fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu 816fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu /** 826fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * Notify the host application that the current page would 837ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * like to show a custom View in a particular orientation. 847ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * @param view is the View object to be shown. 857ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * @param requestedOrientation An orientation constant as used in 867ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}. 877ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * @param callback is the callback to be invoked if and when the view 887ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * is dismissed. 890e0b2daa983a7d9587bb761d5a018b698482e0a1Kristian Monsen * @deprecated This method supports the obsolete plugin mechanism, 900e0b2daa983a7d9587bb761d5a018b698482e0a1Kristian Monsen * and will not be invoked in future 917ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger */ 920e0b2daa983a7d9587bb761d5a018b698482e0a1Kristian Monsen @Deprecated 937ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger public void onShowCustomView(View view, int requestedOrientation, 947ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger CustomViewCallback callback) {}; 957ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger 967ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger /** 977ab3d673ba341db5a44a9c754a25961cfd16f8cdDerek Sollenberger * Notify the host application that the current page would 986fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu * like to hide its custom view. 996fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu */ 1006fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu public void onHideCustomView() {} 1016fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu 1026fa2958059a08390ed2b87b8572f8847ad9999e4Andrei Popescu /** 10389e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * Request the host application to create a new window. If the host 10489e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * application chooses to honor this request, it should return true from 10589e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * this method, create a new WebView to host the window, insert it into the 10689e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * View system and send the supplied resultMsg message to its target with 10789e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * the new WebView as an argument. If the host application chooses not to 10889e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * honor the request, it should return false from this method. The default 10989e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * implementation of this method does nothing and hence returns false. 11089e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param view The WebView from which the request for a new window 11189e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * originated. 11289e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param isDialog True if the new window should be a dialog, rather than 11389e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * a full-size window. 11489e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param isUserGesture True if the request was initiated by a user gesture, 11589e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * such as the user clicking a link. 11689e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @param resultMsg The message to send when once a new WebView has been 11789e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * created. resultMsg.obj is a 118b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * {@link WebView.WebViewTransport} object. This should be 119b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * used to transport the new WebView, by calling 120b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * {@link WebView.WebViewTransport#setWebView(WebView) 121b22a69f2caa4805159027ac06f540da3714d99f0Steve Block * WebView.WebViewTransport.setWebView(WebView)}. 12289e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * @return This method should return true if the host application will 12389e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * create a new window, in which case resultMsg should be sent to 12489e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * its target. Otherwise, this method should return false. Returning 12589e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * false from this method but also sending resultMsg will result in 12689e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block * undefined behavior. 1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 12889e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block public boolean onCreateWindow(WebView view, boolean isDialog, 12989e00a90d5a25f2e6e36684a58d10fbe7db7a284Steve Block boolean isUserGesture, Message resultMsg) { 1309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Request display and focus for this WebView. This may happen due to 1359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * another WebView opening a link in this WebView and requesting that this 1369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WebView be displayed. 1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that needs to be focused. 1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onRequestFocus(WebView view) {} 1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Notify the host application to close the given WebView and remove it 1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * from the view system if necessary. At this point, WebCore has stopped 1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * any loading in this window and has removed any cross-scripting ability 1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * in javascript. 1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param window The WebView that needs to be closed. 1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void onCloseWindow(WebView window) {} 1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a javascript alert dialog. If the client 1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * returns true, WebView will assume that the client will handle the 1539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * dialog. If the client returns false, it will continue execution. 1549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 1559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 1579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsResult to confirm that the user hit enter. 1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the alert dialog. 1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsAlert(WebView view, String url, String message, 1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project JsResult result) { 1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a confirm dialog to the user. If the client 1679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * returns true, WebView will assume that the client will handle the 1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * confirm dialog and call the appropriate JsResult method. If the 1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * client returns false, a default value of false will be returned to 1709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. The default behavior is to return false. 1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsResult used to send the user's response to 1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. 1769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the confirm dialog. 1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsConfirm(WebView view, String url, String message, 1799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project JsResult result) { 1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a prompt dialog to the user. If the client 1859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * returns true, WebView will assume that the client will handle the 1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * prompt dialog and call the appropriate JsPromptResult method. If the 1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * client returns false, a default value of false will be returned to to 1889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. The default behavior is to return false. 1899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 1909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 1919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 1929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param defaultValue The default value displayed in the prompt dialog. 1939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsPromptResult used to send the user's reponse to 1949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. 1959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the prompt dialog. 1969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsPrompt(WebView view, String url, String message, 1989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project String defaultValue, JsPromptResult result) { 1999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 2009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 2039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tell the client to display a dialog to confirm navigation away from the 2049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * current page. This is the result of the onbeforeunload javascript event. 2059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * If the client returns true, WebView will assume that the client will 2069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * handle the confirm dialog and call the appropriate JsResult method. If 2079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the client returns false, a default value of true will be returned to 2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript to accept navigation away from the current page. The default 2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * behavior is to return false. Setting the JsResult to true will navigate 2109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * away from the current page, false will cancel the navigation. 2119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param view The WebView that initiated the callback. 2129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param url The url of the page requesting the dialog. 2139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param message Message to be displayed in the window. 2149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param result A JsResult used to send the user's response to 2159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * javascript. 2169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return boolean Whether the client will handle the confirm dialog. 2179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 2189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean onJsBeforeUnload(WebView view, String url, String message, 2199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project JsResult result) { 2209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 2219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2227df1985e86635af006be3dfa65987d60e290b5deBen Murdoch 2237df1985e86635af006be3dfa65987d60e290b5deBen Murdoch /** 224285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * Tell the client that the quota has been exceeded for the Web SQL Database 225285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * API for a particular origin and request a new quota. The client must 226285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * respond by invoking the 227285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)} 228285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * method of the supplied {@link WebStorage.QuotaUpdater} instance. The 229285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * minimum value that can be set for the new quota is the current quota. The 230285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * default implementation responds with the current quota, so the quota will 231285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * not be increased. 232285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param url The URL of the page that triggered the notification 233285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param databaseIdentifier The identifier of the database where the quota 234285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * was exceeded. 235285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param quota The quota for the origin, in bytes 236285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param estimatedDatabaseSize The estimated size of the offending 237285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * database, in bytes 238285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param totalQuota The total quota for all origins, in bytes 239285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which 240285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * must be used to inform the WebView of the new quota. 2415545d083d35620a625b65fafe97199660d85f059Jonathan Dixon * @deprecated This method is no longer called; WebView now uses the HTML5 / JavaScript Quota 2425545d083d35620a625b65fafe97199660d85f059Jonathan Dixon * Management API. 2437df1985e86635af006be3dfa65987d60e290b5deBen Murdoch */ 2445545d083d35620a625b65fafe97199660d85f059Jonathan Dixon @Deprecated 2457df1985e86635af006be3dfa65987d60e290b5deBen Murdoch public void onExceededDatabaseQuota(String url, String databaseIdentifier, 246285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block long quota, long estimatedDatabaseSize, long totalQuota, 247285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block WebStorage.QuotaUpdater quotaUpdater) { 2487df1985e86635af006be3dfa65987d60e290b5deBen Murdoch // This default implementation passes the current quota back to WebCore. 2497df1985e86635af006be3dfa65987d60e290b5deBen Murdoch // WebCore will interpret this that new quota was declined. 250285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block quotaUpdater.updateQuota(quota); 2517df1985e86635af006be3dfa65987d60e290b5deBen Murdoch } 25210e4d2068aa687e30dd4e5fcae6417f66874823bGuang Zhu 25359e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu /** 254c86bec97279c4a5872d78fe371577748ddf43dcfSelim Gurun * Notify the host application that the Application Cache has reached the 255c86bec97279c4a5872d78fe371577748ddf43dcfSelim Gurun * maximum size. The client must respond by invoking the 256285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)} 257285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * method of the supplied {@link WebStorage.QuotaUpdater} instance. The 258285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * minimum value that can be set for the new quota is the current quota. The 259285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * default implementation responds with the current quota, so the quota will 260285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * not be increased. 261285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param requiredStorage The amount of storage required by the Application 262285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * Cache operation that triggered this notification, 263285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * in bytes. 264c86bec97279c4a5872d78fe371577748ddf43dcfSelim Gurun * @param quota the current maximum Application Cache size, in bytes 265285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which 266285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block * must be used to inform the WebView of the new quota. 2675545d083d35620a625b65fafe97199660d85f059Jonathan Dixon * @deprecated This method is no longer called; WebView now uses the HTML5 / JavaScript Quota 2685545d083d35620a625b65fafe97199660d85f059Jonathan Dixon * Management API. 26959e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu */ 2705545d083d35620a625b65fafe97199660d85f059Jonathan Dixon @Deprecated 271285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block public void onReachedMaxAppCacheSize(long requiredStorage, long quota, 27259e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu WebStorage.QuotaUpdater quotaUpdater) { 273285ddfc8abfcdd252c50477b34c13f8173f9f3f4Steve Block quotaUpdater.updateQuota(quota); 27459e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu } 27559e2ad93bf37c7ded44c033d38fe7c972e2f4118Andrei Popescu 27681e41434b3421a89e3e967e866238719e8468bd5Guang Zhu /** 2777351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Notify the host application that web content from the specified origin 2787351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * is attempting to use the Geolocation API, but no permission state is 2797351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * currently set for that origin. The host application should invoke the 2807351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * specified callback with the desired permission state. See 2817351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * {@link GeolocationPermissions} for details. 2827351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * @param origin The origin of the web content attempting to use the 2837351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Geolocation API. 2847351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * @param callback The callback to use to set the permission state for the 2857351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * origin. 2864faee09c422a70439129e9fb40dd82f03d42c98dSteve Block */ 2874faee09c422a70439129e9fb40dd82f03d42c98dSteve Block public void onGeolocationPermissionsShowPrompt(String origin, 2884faee09c422a70439129e9fb40dd82f03d42c98dSteve Block GeolocationPermissions.Callback callback) {} 2894faee09c422a70439129e9fb40dd82f03d42c98dSteve Block 2904faee09c422a70439129e9fb40dd82f03d42c98dSteve Block /** 2917351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * Notify the host application that a request for Geolocation permissions, 2927351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * made with a previous call to 2937351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * {@link #onGeolocationPermissionsShowPrompt(String,GeolocationPermissions.Callback) onGeolocationPermissionsShowPrompt()} 2947351adf76a97b07bb2d777c56e78752cb7834bb0Steve Block * has been canceled. Any related UI should therefore be hidden. 2954faee09c422a70439129e9fb40dd82f03d42c98dSteve Block */ 2964faee09c422a70439129e9fb40dd82f03d42c98dSteve Block public void onGeolocationPermissionsHidePrompt() {} 2974faee09c422a70439129e9fb40dd82f03d42c98dSteve Block 2984faee09c422a70439129e9fb40dd82f03d42c98dSteve Block /** 29981e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * Tell the client that a JavaScript execution timeout has occured. And the 30081e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * client may decide whether or not to interrupt the execution. If the 30181e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * client returns true, the JavaScript will be interrupted. If the client 30281e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * returns false, the execution will continue. Note that in the case of 30381e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * continuing execution, the timeout counter will be reset, and the callback 30481e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * will continue to occur if the script does not finish at the next check 30581e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * point. 30681e41434b3421a89e3e967e866238719e8468bd5Guang Zhu * @return boolean Whether the JavaScript execution should be interrupted. 3071bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch * @deprecated This method is no longer supported and will not be invoked. 30881e41434b3421a89e3e967e866238719e8468bd5Guang Zhu */ 3091bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // This method was only called when using the JSC javascript engine. V8 became 3101bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // the default JS engine with Froyo and support for building with JSC was 3111bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // removed in b/5495373. V8 does not have a mechanism for making a callback such 3121bd37b176e65fddd04d7412ef05f905bd81f8e95Ben Murdoch // as this. 31381e41434b3421a89e3e967e866238719e8468bd5Guang Zhu public boolean onJsTimeout() { 31481e41434b3421a89e3e967e866238719e8468bd5Guang Zhu return true; 31581e41434b3421a89e3e967e866238719e8468bd5Guang Zhu } 3166262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch 3176262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch /** 3187caaeecce1b04e2098dd4f471fdd69ebe28c31b0Ben Murdoch * Report a JavaScript error message to the host application. The ChromeClient 3197caaeecce1b04e2098dd4f471fdd69ebe28c31b0Ben Murdoch * should override this to process the log message as they see fit. 3206262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param message The error message to report. 3216262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param lineNumber The line number of the error. 3226262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch * @param sourceID The name of the source file that caused the error. 3233141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @deprecated Use {@link #onConsoleMessage(ConsoleMessage) onConsoleMessage(ConsoleMessage)} 3243141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * instead. 3256262ae5c9df44c0673cebaeaf7f655094f5b5485Ben Murdoch */ 3263141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch @Deprecated 3273141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch public void onConsoleMessage(String message, int lineNumber, String sourceID) { } 3283141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch 3293141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch /** 3303141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * Report a JavaScript console message to the host application. The ChromeClient 3313141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * should override this to process the log message as they see fit. 3323141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @param consoleMessage Object containing details of the console message. 3333141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch * @return true if the message is handled by the client. 3343141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch */ 3353141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch public boolean onConsoleMessage(ConsoleMessage consoleMessage) { 3363141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch // Call the old version of this function for backwards compatability. 3373141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(), 3383141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch consoleMessage.sourceId()); 3393141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch return false; 3403141e0a62abe57e93e5d716895a2a57cc052bb50Ben Murdoch } 341bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu 342bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu /** 343f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * When not playing, video elements are represented by a 'poster' image. The 344f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * image to use can be specified by the poster attribute of the video tag in 345f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * HTML. If the attribute is absent, then a default poster will be used. This 346f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * method allows the ChromeClient to provide that default image. 347bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu * 348f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * @return Bitmap The image to use as a default poster, or null if no such image is 349f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * available. 350bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu */ 351bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu public Bitmap getDefaultVideoPoster() { 352bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu return null; 353bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu } 354bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu 355bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu /** 356f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * When the user starts to playback a video element, it may take time for enough 357f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * data to be buffered before the first frames can be rendered. While this buffering 358f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * is taking place, the ChromeClient can use this function to provide a View to be 359f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * displayed. For example, the ChromeClient could show a spinner animation. 360bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu * 361f0c443deca49d597c8268ef3b0f7198976073241Ben Murdoch * @return View The View to be displayed whilst the video is loading. 362bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu */ 363bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu public View getVideoLoadingProgressView() { 364bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu return null; 365bf385d7c7b093564738f8cfd4386daf5e94b8a6dAndrei Popescu } 366194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke 367194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke /** Obtains a list of all visited history items, used for link coloring 368194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke */ 369194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke public void getVisitedHistory(ValueCallback<String[]> callback) { 370194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke } 371194e345eb0fbfd170dcebb81a2bb7d93e8f93f94Leon Clarke 37270ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins /** 37370ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * Tell the client to open a file chooser. 37470ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * @param uploadFile A ValueCallback to set the URI of the file to upload. 3754ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * onReceiveValue must be called to wake up the thread.a 3764ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * @param acceptType The value of the 'accept' attribute of the input tag 3774ae32f5f11f2914196d6d0d195dcbc59d37b92bcBen Murdoch * associated with this file picker. 378be716920e70541c9b334c9389d335f1aa1ed7124Ben Murdoch * @param capture The value of the 'capture' attribute of the input tag 379be716920e70541c9b334c9389d335f1aa1ed7124Ben Murdoch * associated with this file picker. 38070ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins * @hide 38170ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins */ 382be716920e70541c9b334c9389d335f1aa1ed7124Ben Murdoch public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) { 38370ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins uploadFile.onReceiveValue(null); 38470ca3c25b959427359bdb7cf37a8c3d6eb962357Leon Scroggins } 385924af70019f1cc82d850a0c29c2606a2f4faf5cfCary Clark 386924af70019f1cc82d850a0c29c2606a2f4faf5cfCary Clark /** 38757914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * Tell the client that the page being viewed has an autofillable 38857914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * form and the user would like to set a profile up. 38957914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * @param msg A Message to send once the user has successfully 39057914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * set up a profile and to inform the WebTextView it should 39157914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * now autofill using that new profile. 39257914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch * @hide 39357914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch */ 39457914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch public void setupAutoFill(Message msg) { } 39557914381a80c9f19cf5227b4af9e822fa0c74ea9Ben Murdoch 3969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 397