Added postUrl() to WebView so that we can pass lat/lon for the search.

This commit is contained in:
Grace Kloba
2009-05-22 18:55:02 -07:00
parent c5d0343b67
commit 5753430f64
3 changed files with 45 additions and 1 deletions

View File

@@ -144,6 +144,17 @@ class BrowserFrame extends Handler {
mLoadInitFromJava = false;
}
/**
* 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
@@ -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);

View File

@@ -1215,6 +1215,29 @@ public class WebView extends AbsoluteLayout
clearTextEntry();
}
/**
* 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

View File

@@ -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");