From c12544a201667383bc3dfb4bd3ad62d98cacd24f Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Thu, 11 Nov 2010 13:16:44 -0500 Subject: Offer a callback to intercept url requests. The new callback allows applications to return a response for a particular url. Deprecate onLoadResource in favor of the new api. onLoadResource is not currently being used by the new network stack and applications can post a message from shouldInterceptRequest to handle onLoadResource. Bug: 2905943 Change-Id: Icf48ab3110d85d76112b3c3b4a1a8c8a333b82f0 --- core/java/android/webkit/WebViewClient.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'core/java/android/webkit/WebViewClient.java') diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java index 1f8eeba9016c..db605de6dc77 100644 --- a/core/java/android/webkit/WebViewClient.java +++ b/core/java/android/webkit/WebViewClient.java @@ -77,6 +77,26 @@ public class WebViewClient { public void onLoadResource(WebView view, String url) { } + /** + * Notify the host application of a resource request and allow the + * application to return the data. If the return value is null, the WebView + * will continue to load the resource as usual. Otherwise, the return + * response and data will be used. NOTE: This method is called by the + * network thread so clients should exercise caution when accessing private + * data. + * + * @param view The {@link android.webkit.WebView} that is requesting the + * resource. + * @param url The raw url of the resource. + * @return A {@link android.webkit.WebResourceResponse} containing the + * response information or null if the WebView should load the + * resource itself. + */ + public WebResourceResponse shouldInterceptRequest(WebView view, + String url) { + return null; + } + /** * Notify the host application that there have been an excessive number of * HTTP redirects. As the host application if it would like to continue -- cgit v1.2.3