summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Grace Kloba <klobag@google.com> 2009-05-22 18:55:02 -0700
committer Grace Kloba <klobag@google.com> 2009-05-26 10:35:06 -0700
commit5753430f6408fc5ddc9ef3592f59b968bcf282cc (patch)
treec9c93f0de828e2538f0cdf2eea49a8592df90694
parentc5d0343b677d5ddc2d69fd15b81b084a40ab12ac (diff)
Added postUrl() to WebView so that we can pass lat/lon for the search.
-rw-r--r--core/java/android/webkit/BrowserFrame.java13
-rw-r--r--core/java/android/webkit/WebView.java23
-rw-r--r--core/java/android/webkit/WebViewCore.java10
3 files changed, 45 insertions, 1 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index 6229da763b4a..08ca209fa9e2 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -145,6 +145,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
@@ -754,6 +765,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 66ad2e75e7d7..8fff64440db8 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1216,6 +1216,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 4416f1e36ee9..e4d08cf38884 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -580,7 +580,7 @@ final class WebViewCore {
"GET_SELECTION", // = 129;
"WEBKIT_DRAW", // = 130;
"SYNC_SCROLL", // = 131;
- "", // = 132;
+ "POST_URL", // = 132;
"SPLIT_PICTURE_SET", // = 133;
"CLEAR_CONTENT", // = 134;
"SET_FINAL_FOCUS", // = 135;
@@ -627,6 +627,7 @@ final class WebViewCore {
static final int GET_SELECTION = 129;
static final int WEBKIT_DRAW = 130;
static final int SYNC_SCROLL = 131;
+ static final int POST_URL = 132;
static final int SPLIT_PICTURE_SET = 133;
static final int CLEAR_CONTENT = 134;
@@ -714,6 +715,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");