/**
  * Implementation of certificate handler for EventHandler. Called every time a resource is loaded
  * via a secure connection. In this context, can be called multiple times if we have redirects
  *
  * @param certificate The SSL certifcate
  */
 public void certificate(SslCertificate certificate) {
   // if this is the top-most main-frame page loader
   if (mIsMainPageLoader) {
     // update the browser frame (ie, the main frame)
     mBrowserFrame.certificate(certificate);
   }
 }
 /** Igore the request for now, the user may be prompted again. */
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:32:39.628 -0500",
     hash_original_method = "FA404A4E1A97322F22CB23ECA9545548",
     hash_generated_method = "3AADC2C31F442BC0C036CF279DEA7EC9")
 public void ignore() {
   mBrowserFrame.nativeSslClientCert(mHandle, null, null);
 }
 /** Proceed with the specified private key and client certificate chain. */
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:32:39.625 -0500",
     hash_original_method = "FD9D9C54290793DEF25EE96780FA43D9",
     hash_generated_method = "0D823BB8817086852D9CC56BB148DF51")
 public void proceed(PrivateKey privateKey, X509Certificate[] chain) {
   byte[] privateKeyBytes = privateKey.getEncoded();
   byte[][] chainBytes;
   try {
     chainBytes = NativeCrypto.encodeCertificates(chain);
   } catch (CertificateEncodingException e) {
     mBrowserFrame.nativeSslClientCert(mHandle, null, null);
     return;
   }
   mTable.Allow(mHostAndPort, privateKeyBytes, chainBytes);
   mBrowserFrame.nativeSslClientCert(mHandle, privateKeyBytes, chainBytes);
 }
 /** Cancel this request, remember the users negative choice. */
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:32:39.630 -0500",
     hash_original_method = "E250E51CEC55FC558312A1D8553D2784",
     hash_generated_method = "16E4B6B0FCD735FE4AE16227A8A11C24")
 public void cancel() {
   mTable.Deny(mHostAndPort);
   mBrowserFrame.nativeSslClientCert(mHandle, null, null);
 }
  /*
   * This function is called from native WebCore code to
   * notify this LoadListener that the content it is currently
   * downloading should be saved to a file and not sent to
   * WebCore.
   */
  void downloadFile() {
    // Setting the Cache Result to null ensures that this
    // content is not added to the cache
    mCacheResult = null;

    // Inform the client that they should download a file
    mBrowserFrame
        .getCallbackProxy()
        .onDownloadStart(
            url(),
            mBrowserFrame.getUserAgentString(),
            mHeaders.getContentDisposition(),
            mMimeType,
            mContentLength);

    // Cancel the download. We need to stop the http load.
    // The native loader object will get cleared by the call to
    // cancel() but will also be cleared on the WebCore side
    // when this function returns.
    cancel();
  }
  /*
   * This message handler is to facilitate communication between the network
   * thread and the browser thread.
   */
  public void handleMessage(Message msg) {
    switch (msg.what) {
      case MSG_CONTENT_HEADERS:
        /*
         * This message is sent when the LoadListener has headers
         * available. The headers are sent onto WebCore to see what we
         * should do with them.
         */
        if (mNativeLoader != 0) {
          commitHeaders();
        }
        break;

      case MSG_CONTENT_DATA:
        /*
         * This message is sent when the LoadListener has data available
         * in it's data buffer. This data buffer could be filled from a
         * file (this thread) or from http (Network thread).
         */
        if (mNativeLoader != 0) {
          commitLoad();
        }
        break;

      case MSG_CONTENT_FINISHED:
        /*
         * This message is sent when the LoadListener knows that the
         * load is finished. This message is not sent in the case of an
         * error.
         *
         */
        tearDown();
        break;

      case MSG_CONTENT_ERROR:
        /*
         * This message is sent when a load error has occured. The
         * LoadListener will clean itself up.
         */
        notifyError();
        tearDown();
        break;

      case MSG_LOCATION_CHANGED:
        /*
         * This message is sent from LoadListener.endData to inform the
         * browser activity that the location of the top level page
         * changed.
         */
        doRedirect();
        break;

      case MSG_LOCATION_CHANGED_REQUEST:
        /*
         * This message is sent from endData on receipt of a 307
         * Temporary Redirect in response to a POST -- the user must
         * confirm whether to continue loading. If the user says Yes,
         * we simply call MSG_LOCATION_CHANGED. If the user says No,
         * we call MSG_CONTENT_FINISHED.
         */
        Message contMsg = obtainMessage(MSG_LOCATION_CHANGED);
        Message stopMsg = obtainMessage(MSG_CONTENT_FINISHED);
        mBrowserFrame.getCallbackProxy().onFormResubmission(stopMsg, contMsg);
        break;
    }
  }