/** Sets the current URL associated with this load. */
 void setUrl(String url) {
   if (url != null) {
     if (URLUtil.isDataUrl(url)) {
       // Don't strip anchor as that is a valid part of the URL
       mUrl = url;
     } else {
       mUrl = URLUtil.stripAnchor(url);
     }
     mUri = null;
     if (URLUtil.isNetworkUrl(mUrl)) {
       try {
         mUri = new WebAddress(mUrl);
       } catch (ParseException e) {
         e.printStackTrace();
       }
     }
   }
 }
  /**
   * Issues the load request.
   *
   * <p>Return value does not indicate if the load was successful or not. It simply indicates that
   * the load request is reasonable.
   *
   * @return true if the load is reasonable.
   */
  public boolean executeLoad() {
    String url = mListener.url();

    // Attempt to decode the percent-encoded url.
    try {
      url = new String(URLUtil.decode(url.getBytes()));
    } catch (IllegalArgumentException e) {
      // Fail with a bad url error if the decode fails.
      mListener.error(
          EventHandler.ERROR_BAD_URL,
          mListener.getContext().getString(com.android.internal.R.string.httpErrorBadUrl));
      return false;
    }

    if (URLUtil.isNetworkUrl(url)) {
      if (mSettings.getBlockNetworkLoads()) {
        mListener.error(
            EventHandler.ERROR_BAD_URL,
            mListener.getContext().getString(com.android.internal.R.string.httpErrorBadUrl));
        return false;
      }
      mNetwork = Network.getInstance(mListener.getContext());
      return handleHTTPLoad();
    } else if (handleLocalFile(url, mListener, mSettings)) {
      return true;
    }
    if (WebView.LOGV_ENABLED) {
      Log.v(LOGTAG, "FrameLoader.executeLoad: url protocol not supported:" + mListener.url());
    }
    mListener.error(
        EventHandler.ERROR_UNSUPPORTED_SCHEME,
        mListener
            .getContext()
            .getText(com.android.internal.R.string.httpErrorUnsupportedScheme)
            .toString());
    return false;
  }
  /*
   * Perform the actual redirection. This involves setting up the new URL,
   * informing WebCore and then telling the Network to start loading again.
   */
  private void doRedirect() {
    // as cancel() can cancel the load before doRedirect() is
    // called through handleMessage, needs to check to see if we
    // are canceled before proceed
    if (mCancelled) {
      return;
    }

    String redirectTo = mHeaders.getLocation();
    if (redirectTo != null) {
      int nativeResponse = createNativeResponse();
      redirectTo = nativeRedirectedToUrl(mUrl, redirectTo, nativeResponse);
      // nativeRedirectedToUrl() may call cancel(), e.g. when redirect
      // from a https site to a http site, check mCancelled again
      if (mCancelled) {
        return;
      }
      if (redirectTo == null) {
        Log.d(LOGTAG, "Redirection failed for " + mHeaders.getLocation());
        cancel();
        return;
      } else if (!URLUtil.isNetworkUrl(redirectTo)) {
        final String text =
            mContext.getString(com.android.internal.R.string.open_permission_deny)
                + "\n"
                + redirectTo;
        nativeAddData(text.getBytes(), text.length());
        nativeFinished();
        clearNativeLoader();
        return;
      }

      if (mOriginalUrl == null) {
        mOriginalUrl = mUrl;
      }

      // Cache the redirect response
      if (mCacheResult != null) {
        if (getErrorID() == OK) {
          CacheManager.saveCacheFile(mUrl, mCacheResult);
        }
        mCacheResult = null;
      }

      setUrl(redirectTo);

      // Redirect may be in the cache
      if (mRequestHeaders == null) {
        mRequestHeaders = new HashMap<String, String>();
      }
      if (!checkCache(mRequestHeaders)) {
        // mRequestHandle can be null when the request was satisfied
        // by the cache, and the cache returned a redirect
        if (mRequestHandle != null) {
          mRequestHandle.setupRedirect(redirectTo, mStatusCode, mRequestHeaders);
        } else {
          String method = mMethod;

          if (method == null) {
            return;
          }

          Network network = Network.getInstance(getContext());
          network.requestURL(method, mRequestHeaders, mPostData, this, mIsHighPriority);
        }
      }
    } else {
      cancel();
    }

    if (Config.LOGV) {
      Log.v(LOGTAG, "LoadListener.onRedirect(): redirect to: " + redirectTo);
    }
  }
 public void setReferrer(String ref) {
   // only set referrer for http or https
   if (URLUtil.isNetworkUrl(ref)) mReferrer = ref;
 }