diff options
-rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 13 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 23 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewCore.java | 11 |
3 files changed, 47 insertions, 0 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java index ba3f78cf22ec..dbd268291aa2 100644 --- a/core/java/android/webkit/BrowserFrame.java +++ b/core/java/android/webkit/BrowserFrame.java @@ -143,6 +143,17 @@ class BrowserFrame extends Handler { } /** + * Load a url with "POST" method from the network into the main frame. + * @param url The url to load. + * @param data The data for POST request. + */ + public void postUrl(String url, byte[] data) { + mLoadInitFromJava = true; + nativePostUrl(url, data); + mLoadInitFromJava = false; + } + + /** * Load the content as if it was loaded by the provided base URL. The * failUrl is used as the history entry for the load data. If null or * an empty string is passed for the failUrl, then no history entry is @@ -752,6 +763,8 @@ class BrowserFrame extends Handler { */ private native void nativeLoadUrl(String url); + private native void nativePostUrl(String url, byte[] postData); + private native void nativeLoadData(String baseUrl, String data, String mimeType, String encoding, String failUrl); diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 563d819d301f..8e0a80c78962 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1118,6 +1118,29 @@ public class WebView extends AbsoluteLayout } /** + * Load the url with postData using "POST" method into the WebView. If url + * is not a network url, it will be loaded with {link + * {@link #loadUrl(String)} instead. + * + * @param url The url of the resource to load. + * @param postData The data will be passed to "POST" request. + * + * @hide pending API solidification + */ + public void postUrl(String url, byte[] postData) { + if (URLUtil.isNetworkUrl(url)) { + switchOutDrawHistory(); + HashMap arg = new HashMap(); + arg.put("url", url); + arg.put("data", postData); + mWebViewCore.sendMessage(EventHub.POST_URL, arg); + clearTextEntry(); + } else { + loadUrl(url); + } + } + + /** * Load the given data into the WebView. This will load the data into * WebView using the data: scheme. Content loaded through this mechanism * does not have the ability to load content from the network. diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index e9df453b78f1..0dbfb83b7eb6 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -544,6 +544,8 @@ final class WebViewCore { "WEBKIT_DRAW", // = 130; "SYNC_SCROLL", // = 131; "REFRESH_PLUGINS", // = 132; + // this will replace REFRESH_PLUGINS in the next release + "POST_URL", // = 142; "SPLIT_PICTURE_SET", // = 133; "CLEAR_CONTENT", // = 134; "SET_FINAL_FOCUS", // = 135; @@ -589,6 +591,8 @@ final class WebViewCore { static final int WEBKIT_DRAW = 130; static final int SYNC_SCROLL = 131; static final int REFRESH_PLUGINS = 132; + // this will replace REFRESH_PLUGINS in the next release + static final int POST_URL = 142; static final int SPLIT_PICTURE_SET = 133; static final int CLEAR_CONTENT = 134; @@ -672,6 +676,13 @@ final class WebViewCore { loadUrl((String) msg.obj); break; + case POST_URL: { + HashMap param = (HashMap) msg.obj; + String url = (String) param.get("url"); + byte[] data = (byte[]) param.get("data"); + mBrowserFrame.postUrl(url, data); + break; + } case LOAD_DATA: HashMap loadParams = (HashMap) msg.obj; String baseUrl = (String) loadParams.get("baseUrl"); |