WebViewClient.java revision 8d4f07f8d377fc1888879d3ef84c084d3bc5fb5d
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
199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.graphics.Bitmap;
209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.net.http.SslError;
219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.Message;
22899d70568b565280dd33fa8892e25c5511f95769Michael Wrightimport android.view.InputEvent;
239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.view.KeyEvent;
24d6b1098e1f46530528dfea415655468ec994bbb6John Reckimport android.view.ViewRootImpl;
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class WebViewClient {
279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Give the host application a chance to take over the control when a new
309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * url is about to be loaded in the current WebView. If WebViewClient is not
319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * provided, by default WebView will ask Activity Manager to choose the
329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * proper handler for the url. If WebViewClient is provided, return true
339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * means the host application handles the url, while return false means the
349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * current WebView handles the url.
35881c49c99be006f90a51a444db6b96289947e73aMartin Kosiba     * This method is not called for requests using the POST "method".
36a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param url The url to be loaded.
399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return True if the host application wants to leave the current WebView
409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *         and handle the url itself, otherwise return false.
419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean shouldOverrideUrlLoading(WebView view, String url) {
439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return false;
449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application that a page has started loading. This method
489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is called once for each main frame load so a page with iframes or
499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * framesets will call onPageStarted one time for the main frame. This also
509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * means that onPageStarted will not be called when the contents of an
5116687cc956af678032f03e1c9ec5ee51736bc763Marcin Kosiba     * embedded frame changes, i.e. clicking a link whose target is an iframe,
5216687cc956af678032f03e1c9ec5ee51736bc763Marcin Kosiba     * it will also not be called for fragment navigations (navigations to
5316687cc956af678032f03e1c9ec5ee51736bc763Marcin Kosiba     * #fragment_id).
54a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param url The url to be loaded.
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param favicon The favicon for this page if it already exists in the
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            database.
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onPageStarted(WebView view, String url, Bitmap favicon) {
619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application that a page has finished loading. This method
659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is called only for main frame. When onPageFinished() is called, the
669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * rendering picture may not be updated yet. To get the notification for the
679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * new Picture, use {@link WebView.PictureListener#onNewPicture}.
68a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param url The url of the page.
719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onPageFinished(WebView view, String url) {
739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application that the WebView will load the resource
779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * specified by the given url.
78a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param url The url of the resource the WebView will load.
819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onLoadResource(WebView view, String url) {
839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
86b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * Notify the host application that {@link android.webkit.WebView} content left over from
87b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * previous page navigations will no longer be drawn.
88a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant     *
89b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * <p>This callback can be used to determine the point at which it is safe to make a recycled
90b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * {@link android.webkit.WebView} visible, ensuring that no stale content is shown. It is called
91b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * at the earliest point at which it can be guaranteed that {@link WebView#onDraw} will no
92b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * longer draw any content from previous navigations. The next draw will display either the
93b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * {@link WebView#setBackgroundColor background color} of the {@link WebView}, or some of the
94b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * contents of the newly loaded page.
95a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant     *
96b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * <p>This method is called when the body of the HTTP response has started loading, is reflected
97b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * in the DOM, and will be visible in subsequent draws. This callback occurs early in the
98b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * document loading process, and as such you should expect that linked resources (for example,
99b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * css and images) may not be available.</p>
100a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant     *
101b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * <p>For more fine-grained notification of visual state updates, see {@link
102b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * WebView#postVisualStateCallback}.</p>
103a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant     *
104b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * <p>Please note that all the conditions and recommendations applicable to
105b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * {@link WebView#postVisualStateCallback} also apply to this API.<p>
106b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     *
107b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * <p>This callback is only called for main frame navigations.</p>
108b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     *
109b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * @param view The {@link android.webkit.WebView} for which the navigation occurred.
110b3656049777a3cb9257357ff51c78d7b170938f0Tobias Sargeant     * @param url  The URL corresponding to the page navigation that triggered this callback.
111a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant     */
112a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant    public void onPageCommitVisible(WebView view, String url) {
113a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant    }
114a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant
115a8352f40316fb265c74d42e908eb30284259b47dTobias Sargeant    /**
116c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     * Notify the host application of a resource request and allow the
117c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     * application to return the data.  If the return value is null, the WebView
118c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     * will continue to load the resource as usual.  Otherwise, the return
11915cb82549375d89feb1cf0f2825e3e31a94d0c38Martin Kosiba     * response and data will be used.  NOTE: This method is called on a thread
12015cb82549375d89feb1cf0f2825e3e31a94d0c38Martin Kosiba     * other than the UI thread so clients should exercise caution
12115cb82549375d89feb1cf0f2825e3e31a94d0c38Martin Kosiba     * when accessing private data or the view system.
122c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     *
123c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     * @param view The {@link android.webkit.WebView} that is requesting the
124c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     *             resource.
125c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     * @param url The raw url of the resource.
126c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     * @return A {@link android.webkit.WebResourceResponse} containing the
127c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     *         response information or null if the WebView should load the
128c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     *         resource itself.
129d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * @deprecated Use {@link #shouldInterceptRequest(WebView, WebResourceRequest)
130d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     *             shouldInterceptRequest(WebView, WebResourceRequest)} instead.
131c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott     */
132d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba    @Deprecated
133c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott    public WebResourceResponse shouldInterceptRequest(WebView view,
134c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott            String url) {
135c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott        return null;
136c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott    }
137c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott
138c12544a201667383bc3dfb4bd3ad62d98cacd24fPatrick Scott    /**
139d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * Notify the host application of a resource request and allow the
140d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * application to return the data.  If the return value is null, the WebView
141d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * will continue to load the resource as usual.  Otherwise, the return
142d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * response and data will be used.  NOTE: This method is called on a thread
143d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * other than the UI thread so clients should exercise caution
144d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * when accessing private data or the view system.
145d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     *
146d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * @param view The {@link android.webkit.WebView} that is requesting the
147d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     *             resource.
148d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * @param request Object containing the details of the request.
149d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     * @return A {@link android.webkit.WebResourceResponse} containing the
150d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     *         response information or null if the WebView should load the
151d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     *         resource itself.
152d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba     */
153d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba    public WebResourceResponse shouldInterceptRequest(WebView view,
154d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba            WebResourceRequest request) {
155d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba        return shouldInterceptRequest(view, request.getUrl().toString());
156d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba    }
157d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba
158d72e7ba1c04b2f7b128c5710607a72867b73bf1cMarcin Kosiba    /**
1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application that there have been an excessive number of
1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * HTTP redirects. As the host application if it would like to continue
1619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * trying to load the resource. The default behavior is to send the cancel
1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * message.
163a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
1659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param cancelMsg The message to send if the host wants to cancel
1669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param continueMsg The message to send if the host wants to continue
1676a5b0ecae5dc89a951e1e204bc007f50f944c5d1Patrick Scott     * @deprecated This method is no longer called. When the WebView encounters
1686a5b0ecae5dc89a951e1e204bc007f50f944c5d1Patrick Scott     *             a redirect loop, it will cancel the load.
1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
170b5503c168a49f0f2b1372678f87d874e7d82aaadKristian Monsen    @Deprecated
1719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onTooManyRedirects(WebView view, Message cancelMsg,
1729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            Message continueMsg) {
1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        cancelMsg.sendToTarget();
1749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
17605c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    // These ints must match up to the hidden values in EventHandler.
17705c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Generic error */
17805c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_UNKNOWN = -1;
17905c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Server or proxy hostname lookup failed */
18005c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_HOST_LOOKUP = -2;
18105c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Unsupported authentication scheme (not basic or digest) */
18205c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;
18305c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** User authentication failed on server */
18405c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_AUTHENTICATION = -4;
18505c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** User authentication failed on proxy */
18605c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_PROXY_AUTHENTICATION = -5;
18705c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Failed to connect to the server */
18805c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_CONNECT = -6;
18905c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Failed to read or write to the server */
19005c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_IO = -7;
19105c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Connection timed out */
19205c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_TIMEOUT = -8;
19305c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Too many redirects */
19405c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_REDIRECT_LOOP = -9;
19505c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Unsupported URI scheme */
19605c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_UNSUPPORTED_SCHEME = -10;
19705c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Failed to perform SSL handshake */
19805c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_FAILED_SSL_HANDSHAKE = -11;
19905c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Malformed URL */
20005c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_BAD_URL = -12;
20105c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Generic file error */
20205c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_FILE = -13;
20305c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** File not found */
20405c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_FILE_NOT_FOUND = -14;
20505c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    /** Too many requests during this load */
20605c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott    public static final int ERROR_TOO_MANY_REQUESTS = -15;
20705c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott
2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
20905c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott     * Report an error to the host application. These errors are unrecoverable
21005c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott     * (i.e. the main resource is unavailable). The errorCode parameter
21105c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott     * corresponds to one of the ERROR_* constants.
2129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
213447811c64f60d29a5c0bf2d7ba94b91c68fe2612Patrick Scott     * @param errorCode The error code corresponding to an ERROR_* value.
21405c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott     * @param description A String describing the error.
21505c9ed9ce1d920c322ee1431cfed64541f0acf3cPatrick Scott     * @param failingUrl The url that failed to load.
21625e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @deprecated Use {@link #onReceivedError(WebView, WebResourceRequest, WebResourceError)
21725e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     *             onReceivedError(WebView, WebResourceRequest, WebResourceError)} instead.
2189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
21925e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    @Deprecated
2209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onReceivedError(WebView view, int errorCode,
2219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            String description, String failingUrl) {
2229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
22525e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * Report web resource loading error to the host application. These errors usually indicate
22625e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * inability to connect to the server. Note that unlike the deprecated version of the callback,
22725e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * the new version will be called for any resource (iframe, image, etc), not just for the main
22825e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * page. Thus, it is recommended to perform minimum required work in this callback.
22925e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @param view The WebView that is initiating the callback.
23025e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @param request The originating request.
23125e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @param error Information about the error occured.
23225e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     */
23325e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
23425e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov        if (request.isForMainFrame()) {
23525e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov            onReceivedError(view,
2368d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov                    error.getErrorCode(), error.getDescription().toString(),
2378d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov                    request.getUrl().toString());
23825e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov        }
23925e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    }
24025e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov
24125e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    /**
2428d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov     * This method will be deleted after updated WebView.apk will be submitted
2438d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov     * into the Android tree.
2448d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov     */
2458d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov    public void onReceivedHttpError(
2468d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov            WebView view, WebResourceRequest request, WebResourceResponseBase errorResponse) {
2478d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov    }
2488d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov
2498d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov    /**
25025e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * Notify the host application that an HTTP error has been received from the server while
25125e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * loading a resource.  HTTP errors have status codes &gt;= 400.  This callback will be called
25225e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * for any resource (iframe, image, etc), not just for the main page. Thus, it is recommended to
25325e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * perform minimum required work in this callback. Note that the content of the server
25425e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * response may not be provided within the <b>errorResponse</b> parameter.
25525e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @param view The WebView that is initiating the callback.
25625e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @param request The originating request.
25725e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     * @param errorResponse Information about the error occured.
25825e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov     */
25925e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    public void onReceivedHttpError(
2608d4f07f8d377fc1888879d3ef84c084d3bc5fb5dMikhail Naganov            WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
26125e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    }
26225e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov
26325e89545736d62c59d19dd9b9587f7b0cbbee068Mikhail Naganov    /**
2649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * As the host application if the browser should resend data as the
2659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * requested page was a result of a POST. The default is to not resend the
2669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * data.
267a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
2689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
2699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dontResend The message to send if the browser should not resend
2709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param resend The message to send if the browser should resend data
2719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onFormResubmission(WebView view, Message dontResend,
2739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            Message resend) {
2749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        dontResend.sendToTarget();
2759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application to update its visited links database.
279a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
2809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
2819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param url The url being visited.
2829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param isReload True if this url is being reloaded.
2839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void doUpdateVisitedHistory(WebView view, String url,
2859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            boolean isReload) {
2869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
289fe33a75cc8883dc5d50dd5a2fb0eac702f2a6992Steve Block     * Notify the host application that an SSL error occurred while loading a
290fe33a75cc8883dc5d50dd5a2fb0eac702f2a6992Steve Block     * resource. The host application must call either handler.cancel() or
291fe33a75cc8883dc5d50dd5a2fb0eac702f2a6992Steve Block     * handler.proceed(). Note that the decision may be retained for use in
292fe33a75cc8883dc5d50dd5a2fb0eac702f2a6992Steve Block     * response to future SSL errors. The default behavior is to cancel the
293fe33a75cc8883dc5d50dd5a2fb0eac702f2a6992Steve Block     * load.
294a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
2959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param handler An SslErrorHandler object that will handle the user's
2979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            response.
2989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param error The SSL error object.
2999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onReceivedSslError(WebView view, SslErrorHandler handler,
3019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            SslError error) {
3029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        handler.cancel();
303a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom    }
304a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom
305a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom    /**
306b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * Notify the host application to handle a SSL client certificate
307b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * request. The host application is responsible for showing the UI
308b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * if desired and providing the keys. There are three ways to
309b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * respond: proceed(), cancel() or ignore(). Webview remembers the
310b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * response if proceed() or cancel() is called and does not
311b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * call onReceivedClientCertRequest() again for the same host and port
312b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * pair. Webview does not remember the response if ignore() is called.
313b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     *
314b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * This method is called on the UI thread. During the callback, the
315b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * connection is suspended.
316b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     *
317b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * The default behavior is to cancel, returning no client certificate.
318b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     *
319b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * @param view The WebView that is initiating the callback
320b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     * @param request An instance of a {@link ClientCertRequest}
321b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     *
322b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun     */
323b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun    public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
324b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun        request.cancel();
325b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun    }
326b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun
327b6aa97e0a0cd13846c148716fc0c7947422cea04Selim Gurun    /**
32846ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * Notifies the host application that the WebView received an HTTP
32946ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * authentication request. The host application can use the supplied
33046ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * {@link HttpAuthHandler} to set the WebView's response to the request.
33146ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * The default behavior is to cancel the request.
332a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
33346ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * @param view the WebView that is initiating the callback
33446ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * @param handler the HttpAuthHandler used to set the WebView's response
33546ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * @param host the host requiring authentication
33646ce1db6ff3290b82b12f11715fbe82734a44322Steve Block     * @param realm the realm for which authentication is required
33747aaba3faf5c950e1d7b2c613fe8e2c73c6748a7Jonathan Dixon     * @see WebView#getHttpAuthUsernamePassword
3389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onReceivedHttpAuthRequest(WebView view,
3409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            HttpAuthHandler handler, String host, String realm) {
3419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        handler.cancel();
3429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Give the host application a chance to handle the key event synchronously.
3469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * e.g. menu shortcut key events need to be filtered this way. If return
3479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * true, WebView will not handle the key event. If return false, WebView
3489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * will always handle the key event, so none of the super in the view chain
3499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * will see the key event. The default behavior returns false.
350a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
3519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
3529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param event The key event.
3539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return True if the host application wants to handle the key event
3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *         itself, otherwise return false
3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return false;
3589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application that a key was not handled by the WebView.
3629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Except system keys, WebView always consumes the keys in the normal flow
3639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * or if shouldOverrideKeyEvent returns true. This is called asynchronously
364f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa     * from where the key is dispatched. It gives the host application a chance
3659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to handle the unhandled key events.
366a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
3679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view The WebView that is initiating the callback.
3689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param event The key event.
369899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * @deprecated This method is subsumed by the more generic onUnhandledInputEvent.
3709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
371899d70568b565280dd33fa8892e25c5511f95769Michael Wright    @Deprecated
3729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
373899d70568b565280dd33fa8892e25c5511f95769Michael Wright        onUnhandledInputEventInternal(view, event);
374899d70568b565280dd33fa8892e25c5511f95769Michael Wright    }
375899d70568b565280dd33fa8892e25c5511f95769Michael Wright
376899d70568b565280dd33fa8892e25c5511f95769Michael Wright    /**
377899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * Notify the host application that a input event was not handled by the WebView.
378899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * Except system keys, WebView always consumes input events in the normal flow
379899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * or if shouldOverrideKeyEvent returns true. This is called asynchronously
380899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * from where the event is dispatched. It gives the host application a chance
381899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * to handle the unhandled input events.
382899d70568b565280dd33fa8892e25c5511f95769Michael Wright     *
3831feb11f511af25aa5d62d073d970071d16985661Michael Wright     * Note that if the event is a {@link android.view.MotionEvent}, then it's lifetime is only
3841feb11f511af25aa5d62d073d970071d16985661Michael Wright     * that of the function call. If the WebViewClient wishes to use the event beyond that, then it
3851feb11f511af25aa5d62d073d970071d16985661Michael Wright     * <i>must</i> create a copy of the event.
386899d70568b565280dd33fa8892e25c5511f95769Michael Wright     *
3871feb11f511af25aa5d62d073d970071d16985661Michael Wright     * It is the responsibility of overriders of this method to call
3881feb11f511af25aa5d62d073d970071d16985661Michael Wright     * {@link #onUnhandledKeyEvent(WebView, KeyEvent)}
389899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * when appropriate if they wish to continue receiving events through it.
390899d70568b565280dd33fa8892e25c5511f95769Michael Wright     *
391899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * @param view The WebView that is initiating the callback.
392899d70568b565280dd33fa8892e25c5511f95769Michael Wright     * @param event The input event.
393899d70568b565280dd33fa8892e25c5511f95769Michael Wright     */
394899d70568b565280dd33fa8892e25c5511f95769Michael Wright    public void onUnhandledInputEvent(WebView view, InputEvent event) {
395899d70568b565280dd33fa8892e25c5511f95769Michael Wright        if (event instanceof KeyEvent) {
396899d70568b565280dd33fa8892e25c5511f95769Michael Wright            onUnhandledKeyEvent(view, (KeyEvent) event);
397899d70568b565280dd33fa8892e25c5511f95769Michael Wright            return;
398899d70568b565280dd33fa8892e25c5511f95769Michael Wright        }
399899d70568b565280dd33fa8892e25c5511f95769Michael Wright        onUnhandledInputEventInternal(view, event);
400899d70568b565280dd33fa8892e25c5511f95769Michael Wright    }
401899d70568b565280dd33fa8892e25c5511f95769Michael Wright
402899d70568b565280dd33fa8892e25c5511f95769Michael Wright    private void onUnhandledInputEventInternal(WebView view, InputEvent event) {
403d6b1098e1f46530528dfea415655468ec994bbb6John Reck        ViewRootImpl root = view.getViewRootImpl();
404d6b1098e1f46530528dfea415655468ec994bbb6John Reck        if (root != null) {
405899d70568b565280dd33fa8892e25c5511f95769Michael Wright            root.dispatchUnhandledInputEvent(event);
406d6b1098e1f46530528dfea415655468ec994bbb6John Reck        }
4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Notify the host application that the scale applied to the WebView has
4119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * changed.
412a14775949c97a616196f5293209b092ee3d4e9a9Brian Carlstrom     *
4139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param view he WebView that is initiating the callback.
4149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param oldScale The old scale factor
4159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param newScale The new scale factor
4169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void onScaleChanged(WebView view, float oldScale, float newScale) {
4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
41985a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott
42085a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott    /**
42185a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     * Notify the host application that a request to automatically log in the
42285a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     * user has been processed.
42385a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     * @param view The WebView requesting the login.
42485a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     * @param realm The account realm used to look up accounts.
42585a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     * @param account An optional account. If not null, the account should be
42685a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     *                checked against accounts on the device. If it is a valid
42785a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     *                account, it should be used to log in the user.
42885a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     * @param args Authenticator specific arguments used to log in the user.
42985a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott     */
43085a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott    public void onReceivedLoginRequest(WebView view, String realm,
43185a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott            String account, String args) {
43285a50ff48b2331913cc87f483eafba9f231c8c8cPatrick Scott    }
4339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
434