This source file includes following definitions.
- request_has_been_notified_
- OnDispatchFailed
- OnDispatched
- AsSSLCertErrorHandler
- Dispatch
- CancelRequest
- DenyRequest
- ContinueRequest
- TakeNoAction
- CompleteCancelRequest
- CompleteContinueRequest
- CompleteTakeNoAction
#include "content/browser/ssl/ssl_error_handler.h"
#include "base/bind.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/ssl/ssl_cert_error_handler.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
using net::SSLInfo;
namespace content {
SSLErrorHandler::SSLErrorHandler(const base::WeakPtr<Delegate>& delegate,
const GlobalRequestID& id,
ResourceType::Type resource_type,
const GURL& url,
int render_process_id,
int render_frame_id)
: manager_(NULL),
request_id_(id),
delegate_(delegate),
render_process_id_(render_process_id),
render_frame_id_(render_frame_id),
request_url_(url),
resource_type_(resource_type),
request_has_been_notified_(false) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(delegate.get());
AddRef();
}
SSLErrorHandler::~SSLErrorHandler() {}
void SSLErrorHandler::OnDispatchFailed() {
TakeNoAction();
}
void SSLErrorHandler::OnDispatched() {
TakeNoAction();
}
SSLCertErrorHandler* SSLErrorHandler::AsSSLCertErrorHandler() {
return NULL;
}
void SSLErrorHandler::Dispatch() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
WebContents* web_contents = NULL;
RenderFrameHost* render_frame_host =
RenderFrameHost::FromID(render_process_id_, render_frame_id_);
web_contents = WebContents::FromRenderFrameHost(render_frame_host);
if (!web_contents) {
OnDispatchFailed();
return;
}
manager_ =
static_cast<NavigationControllerImpl*>(&web_contents->GetController())->
ssl_manager();
OnDispatched();
}
void SSLErrorHandler::CancelRequest() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(
&SSLErrorHandler::CompleteCancelRequest, this, net::ERR_ABORTED));
}
void SSLErrorHandler::DenyRequest() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(
&SSLErrorHandler::CompleteCancelRequest, this,
net::ERR_INSECURE_RESPONSE));
}
void SSLErrorHandler::ContinueRequest() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&SSLErrorHandler::CompleteContinueRequest, this));
}
void SSLErrorHandler::TakeNoAction() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&SSLErrorHandler::CompleteTakeNoAction, this));
}
void SSLErrorHandler::CompleteCancelRequest(int error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!request_has_been_notified_);
if (request_has_been_notified_)
return;
SSLCertErrorHandler* cert_error = AsSSLCertErrorHandler();
const SSLInfo* ssl_info = NULL;
if (cert_error)
ssl_info = &cert_error->ssl_info();
if (delegate_.get())
delegate_->CancelSSLRequest(request_id_, error, ssl_info);
request_has_been_notified_ = true;
Release();
}
void SSLErrorHandler::CompleteContinueRequest() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!request_has_been_notified_);
if (request_has_been_notified_)
return;
if (delegate_.get())
delegate_->ContinueSSLRequest(request_id_);
request_has_been_notified_ = true;
Release();
}
void SSLErrorHandler::CompleteTakeNoAction() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!request_has_been_notified_);
if (request_has_been_notified_)
return;
request_has_been_notified_ = true;
Release();
}
}