summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/WebViewClient.java
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2015-10-26 13:27:33 -0700
committerMikhail Naganov <mnaganov@google.com>2015-10-28 16:05:41 -0700
commitb851929c329b90295718e592d86969860d9b920b (patch)
tree4e018e2fa0bf97fa43838a873806c9480adb8f46 /core/java/android/webkit/WebViewClient.java
parent7d428c860657b34df85bb29312da36a9c4d5c021 (diff)
Add new version of WebViewClient.shouldOverrideUrlLoading callback
The new version provides more information about the origin of the load, which helps making more secure decision on how to proceed with it. Bug: 22346196 Change-Id: I27f591bf5e846bde14335a2c929758a2b48d0763
Diffstat (limited to 'core/java/android/webkit/WebViewClient.java')
-rw-r--r--core/java/android/webkit/WebViewClient.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java
index f2bb55a7db13..0e5034de7f4f 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -38,12 +38,42 @@ public class WebViewClient {
* @param url The url to be loaded.
* @return True if the host application wants to leave the current WebView
* and handle the url itself, otherwise return false.
+ * @deprecated Use {@link #shouldOverrideUrlLoading(WebView, WebResourceRequest)
+ * shouldOverrideUrlLoading(WebView, WebResourceRequest)} instead.
*/
+ @Deprecated
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
/**
+ * Give the host application a chance to take over the control when a new
+ * url is about to be loaded in the current WebView. If WebViewClient is not
+ * provided, by default WebView will ask Activity Manager to choose the
+ * proper handler for the url. If WebViewClient is provided, return true
+ * means the host application handles the url, while return false means the
+ * current WebView handles the url.
+ *
+ * <p>Notes:
+ * <ul>
+ * <li>This method is not called for requests using the POST &quot;method&quot;.</li>
+ * <li>This method is also called for subframes with non-http schemes, thus it is
+ * strongly disadvised to unconditionally call {@link WebView#loadUrl(String)}
+ * with the request's url from inside the method and then return true,
+ * as this will make WebView to attempt loading a non-http url, and thus fail.</li>
+ * </ul>
+ * </p>
+ *
+ * @param view The WebView that is initiating the callback.
+ * @param request Object containing the details of the request.
+ * @return True if the host application wants to leave the current WebView
+ * and handle the url itself, otherwise return false.
+ */
+ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
+ return shouldOverrideUrlLoading(view, request.getUrl().toString());
+ }
+
+ /**
* Notify the host application that a page has started loading. This method
* is called once for each main frame load so a page with iframes or
* framesets will call onPageStarted one time for the main frame. This also