コード例 #1
0
 /**
  * Helper method to create a LoadUrlParams object for an HTTP POST load.
  *
  * @param url URL of the load.
  * @param postData Post data of the load. Can be null.
  */
 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;
 }
コード例 #2
0
  public void loadData(String data, String mimeType, String encoding) {

    final LoadUrlParams params = new LoadUrlParams(data);
    params.setLoadType(LoadUrlParams.LOAD_TYPE_DATA);
    this.postTask(
        new Runnable() {
          @Override
          public void run() {
            getContentViewCore().loadUrl(params);
          }
        });
  }
コード例 #3
0
  public void loadUrl(String url) {

    final LoadUrlParams params = new LoadUrlParams(url);
    params.setLoadType(LoadUrlParams.LOAD_TYPE_DEFAULT);

    this.postTask(
        new Runnable() {
          @Override
          public void run() {
            getContentViewCore().loadUrl(params);
          }
        });
  }
コード例 #4
0
  public void loadDataWithBaseURL(
      String baseUrl, String data, String mimeType, String encoding, String failUrl) {

    final LoadUrlParams params = new LoadUrlParams(data);
    params.setLoadType(LoadUrlParams.LOAD_TYPE_DATA);
    params.setBaseUrlForDataUrl(baseUrl);
    this.postTask(
        new Runnable() {
          @Override
          public void run() {
            getContentViewCore().loadUrl(params);
          }
        });
  }
コード例 #5
0
  /**
   * Helper method to create a LoadUrlParams object for data url.
   *
   * @param data Data to be loaded.
   * @param mimeType Mime type of the data.
   * @param isBase64Encoded True if the data is encoded in Base 64 format.
   * @param charset The character set for the data. Pass null if the mime type does not require a
   *     special charset.
   */
  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;
  }
コード例 #6
0
 /**
  * Helper method to create a LoadUrlParams object for data url with base and virtual url.
  *
  * @param data Data to be loaded.
  * @param mimeType Mime type of the data.
  * @param isBase64Encoded True if the data is encoded in Base 64 format.
  * @param baseUrl Base url of this data load. Note that for WebView compatibility, baseUrl and
  *     historyUrl are ignored if this is a data: url. Defaults to about:blank if null.
  * @param historyUrl History url for this data load. Note that for WebView compatibility, this is
  *     ignored if baseUrl is a data: url. Defaults to about:blank if null.
  * @param charset The character set for the data. Pass null if the mime type does not require a
  *     special charset.
  */
 public static LoadUrlParams createLoadDataParamsWithBaseUrl(
     String data,
     String mimeType,
     boolean isBase64Encoded,
     String baseUrl,
     String historyUrl,
     String charset) {
   LoadUrlParams params = createLoadDataParams(data, mimeType, isBase64Encoded, charset);
   // For WebView compatibility, when the base URL has the 'data:'
   // scheme, we treat it as a regular data URL load and skip setting
   // baseUrl and historyUrl.
   // TODO(joth): we should just append baseURL and historyURL here, and move the
   // WebView specific transform up to a wrapper factory function in android_webview/.
   if (baseUrl == null || !baseUrl.toLowerCase().startsWith("data:")) {
     params.setBaseUrlForDataUrl(baseUrl != null ? baseUrl : "about:blank");
     params.setVirtualUrlForDataUrl(historyUrl != null ? historyUrl : "about:blank");
   }
   return params;
 }
コード例 #7
0
 @Override
 public void run() {
   awContents.loadUrl(LoadUrlParams.createLoadHttpPostParams(url, mPostData));
 }