Add request header support for the Browser/WebView.
QSB can use this instead of POST to send the location data. After QSB makes the switch, we should also remove the POST_DATA intent which is hidden. Add loadUrl(String url, HashMap extraHeaders) to WebView so that the caller can send the extra http headers. Remove "inline:" as no one is using it and it is a hidden feature. Part 1 of 3-project checkin.
This commit is contained in:
@@ -119960,6 +119960,28 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="EXTRA_HEADERS_KEY"
|
||||
type="java.lang.String"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value=""com.android.browser.headers_key""
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="EXTRA_HEADERS_VALUE"
|
||||
type="java.lang.String"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value=""com.android.browser.headers_value""
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="HISTORY_PROJECTION"
|
||||
type="java.lang.String[]"
|
||||
transient="false"
|
||||
@@ -189850,6 +189872,21 @@
|
||||
>
|
||||
<parameter name="url" type="java.lang.String">
|
||||
</parameter>
|
||||
<parameter name="extraHeaders" type="java.util.Map<java.lang.String, java.lang.String>">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="loadUrl"
|
||||
return="void"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="url" type="java.lang.String">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="onChildViewAdded"
|
||||
return="void"
|
||||
|
||||
@@ -33,12 +33,6 @@ public class Browser {
|
||||
public static final Uri BOOKMARKS_URI =
|
||||
Uri.parse("content://browser/bookmarks");
|
||||
|
||||
/**
|
||||
* The inline scheme to show embedded content in a browser.
|
||||
* @hide
|
||||
*/
|
||||
public static final Uri INLINE_URI = Uri.parse("inline:");
|
||||
|
||||
/**
|
||||
* The name of extra data when starting Browser with ACTION_VIEW or
|
||||
* ACTION_SEARCH intent.
|
||||
@@ -61,24 +55,6 @@ public class Browser {
|
||||
public static final String EXTRA_APPLICATION_ID =
|
||||
"com.android.browser.application_id";
|
||||
|
||||
/**
|
||||
* The content to be rendered when url's scheme is inline.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_INLINE_CONTENT ="com.android.browser.inline.content";
|
||||
|
||||
/**
|
||||
* The encoding of the inlined content for inline scheme.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_INLINE_ENCODING ="com.android.browser.inline.encoding";
|
||||
|
||||
/**
|
||||
* The url used when the inline content is falied to render.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_INLINE_FAILURL ="com.android.browser.inline.failurl";
|
||||
|
||||
/**
|
||||
* The name of the extra data in the VIEW intent. The data is in boolean.
|
||||
* <p>
|
||||
@@ -102,6 +78,27 @@ public class Browser {
|
||||
*/
|
||||
public static final String EXTRA_POST_DATA = "com.android.browser.post_data";
|
||||
|
||||
/**
|
||||
* The name of the extra data in the VIEW intent. The data is in the format
|
||||
* of String array. This should be paired with EXTRA_HEADERS_VALUE.
|
||||
* <p>
|
||||
* The keys will be combined with the values and sent in the HTTP request
|
||||
* headers for the provided url. The keys can't be the standard HTTP headers
|
||||
* as they are set by the WebView. The url's schema must be http(s).
|
||||
* <p>
|
||||
*/
|
||||
public static final String EXTRA_HEADERS_KEY = "com.android.browser.headers_key";
|
||||
|
||||
/**
|
||||
* The name of the extra data in the VIEW intent. The data is in the format
|
||||
* of String array. This should be paired with EXTRA_HEADERS_KEY.
|
||||
* <p>
|
||||
* The values will be combined with the keys and sent in the HTTP request
|
||||
* headers for the provided url. The url's schema must be http(s).
|
||||
* <p>
|
||||
*/
|
||||
public static final String EXTRA_HEADERS_VALUE = "com.android.browser.headers_value";
|
||||
|
||||
/* if you change column order you must also change indices
|
||||
below */
|
||||
public static final String[] HISTORY_PROJECTION = new String[] {
|
||||
|
||||
@@ -177,18 +177,21 @@ class BrowserFrame extends Handler {
|
||||
|
||||
/**
|
||||
* Load a url from the network or the filesystem into the main frame.
|
||||
* Following the same behaviour as Safari, javascript: URLs are not
|
||||
* passed to the main frame, instead they are evaluated immediately.
|
||||
* Following the same behaviour as Safari, javascript: URLs are not passed
|
||||
* to the main frame, instead they are evaluated immediately.
|
||||
* @param url The url to load.
|
||||
* @param extraHeaders The extra headers sent with this url. This should not
|
||||
* include the common headers like "user-agent". If it does, it
|
||||
* will be replaced by the intrinsic value of the WebView.
|
||||
*/
|
||||
public void loadUrl(String url) {
|
||||
public void loadUrl(String url, Map<String, String> extraHeaders) {
|
||||
mLoadInitFromJava = true;
|
||||
if (URLUtil.isJavaScriptUrl(url)) {
|
||||
// strip off the scheme and evaluate the string
|
||||
stringByEvaluatingJavaScriptFromString(
|
||||
url.substring("javascript:".length()));
|
||||
} else {
|
||||
nativeLoadUrl(url);
|
||||
nativeLoadUrl(url, extraHeaders);
|
||||
}
|
||||
mLoadInitFromJava = false;
|
||||
}
|
||||
@@ -904,7 +907,7 @@ class BrowserFrame extends Handler {
|
||||
/**
|
||||
* Returns false if the url is bad.
|
||||
*/
|
||||
private native void nativeLoadUrl(String url);
|
||||
private native void nativeLoadUrl(String url, Map<String, String> headers);
|
||||
|
||||
private native void nativePostUrl(String url, byte[] postData);
|
||||
|
||||
|
||||
@@ -1375,6 +1375,22 @@ public class WebView extends AbsoluteLayout
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the given url with the extra headers.
|
||||
* @param url The url of the resource to load.
|
||||
* @param extraHeaders The extra headers sent with this url. This should not
|
||||
* include the common headers like "user-agent". If it does, it
|
||||
* will be replaced by the intrinsic value of the WebView.
|
||||
*/
|
||||
public void loadUrl(String url, Map<String, String> extraHeaders) {
|
||||
switchOutDrawHistory();
|
||||
WebViewCore.GetUrlData arg = new WebViewCore.GetUrlData();
|
||||
arg.mUrl = url;
|
||||
arg.mExtraHeaders = extraHeaders;
|
||||
mWebViewCore.sendMessage(EventHub.LOAD_URL, arg);
|
||||
clearTextEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the given url.
|
||||
* @param url The url of the resource to load.
|
||||
@@ -1383,9 +1399,7 @@ public class WebView extends AbsoluteLayout
|
||||
if (url == null) {
|
||||
return;
|
||||
}
|
||||
switchOutDrawHistory();
|
||||
mWebViewCore.sendMessage(EventHub.LOAD_URL, url);
|
||||
clearTextEntry();
|
||||
loadUrl(url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -686,6 +686,11 @@ final class WebViewCore {
|
||||
int mY;
|
||||
}
|
||||
|
||||
static class GetUrlData {
|
||||
String mUrl;
|
||||
Map<String, String> mExtraHeaders;
|
||||
}
|
||||
|
||||
static class PostUrlData {
|
||||
String mUrl;
|
||||
byte[] mPostData;
|
||||
@@ -958,9 +963,11 @@ final class WebViewCore {
|
||||
((Float) msg.obj).floatValue(), msg.arg1);
|
||||
break;
|
||||
|
||||
case LOAD_URL:
|
||||
loadUrl((String) msg.obj);
|
||||
case LOAD_URL: {
|
||||
GetUrlData param = (GetUrlData) msg.obj;
|
||||
loadUrl(param.mUrl, param.mExtraHeaders);
|
||||
break;
|
||||
}
|
||||
|
||||
case POST_URL: {
|
||||
PostUrlData param = (PostUrlData) msg.obj;
|
||||
@@ -1545,9 +1552,9 @@ final class WebViewCore {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadUrl(String url) {
|
||||
private void loadUrl(String url, Map<String, String> extraHeaders) {
|
||||
if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, " CORE loadUrl " + url);
|
||||
mBrowserFrame.loadUrl(url);
|
||||
mBrowserFrame.loadUrl(url, extraHeaders);
|
||||
}
|
||||
|
||||
private void key(KeyEvent evt, boolean isDown) {
|
||||
|
||||
Reference in New Issue
Block a user