This source file includes following definitions.
- JNINamespace
- createLoadDataParams
- createLoadDataParams
- createLoadDataParamsWithBaseUrl
- createLoadDataParamsWithBaseUrl
- createLoadHttpPostParams
- setUrl
- getUrl
- getBaseUrl
- setLoadType
- setTransitionType
- getTransitionType
- setReferrer
- getReferrer
- setExtraHeaders
- getExtraHeadersString
- getExtraHttpRequestHeadersString
- getExtraHeadersString
- setVerbatimHeaders
- getVerbatimHeaders
- setOverrideUserAgent
- setPostData
- getPostData
- setBaseUrlForDataUrl
- setVirtualUrlForDataUrl
- setCanLoadLocalResources
- getLoadUrlType
- isBaseUrlDataScheme
- SuppressWarnings
- initializeConstants
- nativeIsDataScheme
package org.chromium.content.browser;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.content_public.Referrer;
import java.util.Locale;
import java.util.Map;
@JNINamespace("content")
public class LoadUrlParams {
public static int LOAD_TYPE_DEFAULT;
public static int LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
public static int LOAD_TYPE_DATA;
public static int UA_OVERRIDE_INHERIT;
public static int UA_OVERRIDE_FALSE;
public static int UA_OVERRIDE_TRUE;
String mUrl;
int mLoadUrlType;
int mTransitionType;
Referrer mReferrer;
private Map<String, String> mExtraHeaders;
private String mVerbatimHeaders;
int mUaOverrideOption;
byte[] mPostData;
String mBaseUrlForDataUrl;
String mVirtualUrlForDataUrl;
boolean mCanLoadLocalResources;
public LoadUrlParams(String url) {
this(url, PageTransitionTypes.PAGE_TRANSITION_LINK);
}
public LoadUrlParams(String url, int transitionType) {
assert LOAD_TYPE_DEFAULT != LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
mUrl = url;
mTransitionType = transitionType;
mLoadUrlType = LOAD_TYPE_DEFAULT;
mUaOverrideOption = UA_OVERRIDE_INHERIT;
mPostData = null;
mBaseUrlForDataUrl = null;
mVirtualUrlForDataUrl = null;
}
public static LoadUrlParams createLoadDataParams(
String data, String mimeType, boolean isBase64Encoded) {
return createLoadDataParams(data, mimeType, isBase64Encoded, null);
}
public static LoadUrlParams createLoadDataParams(
String data, String mimeType, boolean isBase64Encoded, String charset) {
StringBuilder dataUrl = new StringBuilder("data:");
dataUrl.append(mimeType);
if (charset != null && !charset.isEmpty()) {
dataUrl.append(";charset=" + charset);
}
if (isBase64Encoded) {
dataUrl.append(";base64");
}
dataUrl.append(",");
dataUrl.append(data);
LoadUrlParams params = new LoadUrlParams(dataUrl.toString());
params.setLoadType(LoadUrlParams.LOAD_TYPE_DATA);
params.setTransitionType(PageTransitionTypes.PAGE_TRANSITION_TYPED);
return params;
}
public static LoadUrlParams createLoadDataParamsWithBaseUrl(
String data, String mimeType, boolean isBase64Encoded,
String baseUrl, String historyUrl) {
return createLoadDataParamsWithBaseUrl(data, mimeType, isBase64Encoded,
baseUrl, historyUrl, null);
}
public static LoadUrlParams createLoadDataParamsWithBaseUrl(
String data, String mimeType, boolean isBase64Encoded,
String baseUrl, String historyUrl, String charset) {
LoadUrlParams params = createLoadDataParams(data, mimeType, isBase64Encoded, charset);
if (baseUrl == null || !baseUrl.toLowerCase(Locale.US).startsWith("data:")) {
params.setBaseUrlForDataUrl(baseUrl != null ? baseUrl : "about:blank");
params.setVirtualUrlForDataUrl(historyUrl != null ? historyUrl : "about:blank");
}
return params;
}
public static LoadUrlParams createLoadHttpPostParams(
String url, byte[] postData) {
LoadUrlParams params = new LoadUrlParams(url);
params.setLoadType(LOAD_TYPE_BROWSER_INITIATED_HTTP_POST);
params.setTransitionType(PageTransitionTypes.PAGE_TRANSITION_TYPED);
params.setPostData(postData);
return params;
}
public void setUrl(String url) {
mUrl = url;
}
public String getUrl() {
return mUrl;
}
public String getBaseUrl() {
return mBaseUrlForDataUrl;
}
public void setLoadType(int loadType) {
mLoadUrlType = loadType;
}
public void setTransitionType(int transitionType) {
mTransitionType = transitionType;
}
public int getTransitionType() {
return mTransitionType;
}
public void setReferrer(Referrer referrer) {
mReferrer = referrer;
}
public Referrer getReferrer() {
return mReferrer;
}
public void setExtraHeaders(Map<String, String> extraHeaders) {
mExtraHeaders = extraHeaders;
}
String getExtraHeadersString() {
return getExtraHeadersString("\n", false);
}
public String getExtraHttpRequestHeadersString() {
return getExtraHeadersString("\r\n", true);
}
private String getExtraHeadersString(String delimiter, boolean addTerminator) {
if (mExtraHeaders == null) return null;
StringBuilder headerBuilder = new StringBuilder();
for (Map.Entry<String, String> header : mExtraHeaders.entrySet()) {
if (headerBuilder.length() > 0) headerBuilder.append(delimiter);
headerBuilder.append(header.getKey().toLowerCase(Locale.US));
headerBuilder.append(":");
headerBuilder.append(header.getValue());
}
if (addTerminator)
headerBuilder.append(delimiter);
return headerBuilder.toString();
}
public void setVerbatimHeaders(String headers) {
mVerbatimHeaders = headers;
}
public String getVerbatimHeaders() {
return mVerbatimHeaders;
}
public void setOverrideUserAgent(int uaOption) {
mUaOverrideOption = uaOption;
}
public void setPostData(byte[] postData) {
mPostData = postData;
}
public byte[] getPostData() {
return mPostData;
}
public void setBaseUrlForDataUrl(String baseUrl) {
mBaseUrlForDataUrl = baseUrl;
}
public void setVirtualUrlForDataUrl(String virtualUrl) {
mVirtualUrlForDataUrl = virtualUrl;
}
public void setCanLoadLocalResources(boolean canLoad) {
mCanLoadLocalResources = canLoad;
}
public int getLoadUrlType() {
return mLoadUrlType;
}
public boolean isBaseUrlDataScheme() {
if (mBaseUrlForDataUrl == null && mLoadUrlType == LOAD_TYPE_DATA) {
return true;
}
return nativeIsDataScheme(mBaseUrlForDataUrl);
}
@SuppressWarnings("unused")
@CalledByNative
private static void initializeConstants(
int load_type_default,
int load_type_browser_initiated_http_post,
int load_type_data,
int ua_override_inherit,
int ua_override_false,
int ua_override_true) {
LOAD_TYPE_DEFAULT = load_type_default;
LOAD_TYPE_BROWSER_INITIATED_HTTP_POST = load_type_browser_initiated_http_post;
LOAD_TYPE_DATA = load_type_data;
UA_OVERRIDE_INHERIT = ua_override_inherit;
UA_OVERRIDE_FALSE = ua_override_false;
UA_OVERRIDE_TRUE = ua_override_true;
}
private static native boolean nativeIsDataScheme(String url);
}