1// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/ssl/ssl_cert_error_handler.h"
6
7#include "chrome/browser/ssl/ssl_manager.h"
8#include "chrome/browser/ssl/ssl_policy.h"
9#include "content/browser/renderer_host/resource_dispatcher_host.h"
10#include "net/base/x509_certificate.h"
11
12SSLCertErrorHandler::SSLCertErrorHandler(
13    ResourceDispatcherHost* rdh,
14    net::URLRequest* request,
15    ResourceType::Type resource_type,
16    int cert_error,
17    net::X509Certificate* cert)
18    : SSLErrorHandler(rdh, request, resource_type),
19      cert_error_(cert_error) {
20  DCHECK(request == resource_dispatcher_host_->GetURLRequest(request_id_));
21
22  // We cannot use the request->ssl_info(), it's not been initialized yet, so
23  // we have to set the fields manually.
24  ssl_info_.cert = cert;
25  ssl_info_.SetCertError(cert_error);
26}
27
28SSLCertErrorHandler* SSLCertErrorHandler::AsSSLCertErrorHandler() {
29  return this;
30}
31
32void SSLCertErrorHandler::OnDispatchFailed() {
33  CancelRequest();
34}
35
36void SSLCertErrorHandler::OnDispatched() {
37  manager_->policy()->OnCertError(this);
38}
39
40SSLCertErrorHandler::~SSLCertErrorHandler() {}
41