1 // Copyright (c) 2012 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 "content/browser/ssl/ssl_policy_backend.h"
6
7 #include "content/browser/frame_host/navigation_controller_impl.h"
8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/ssl_host_state_delegate.h"
10
11 namespace content {
12
SSLPolicyBackend(NavigationControllerImpl * controller)13 SSLPolicyBackend::SSLPolicyBackend(NavigationControllerImpl* controller)
14 : ssl_host_state_delegate_(
15 controller->GetBrowserContext()->GetSSLHostStateDelegate()),
16 controller_(controller) {
17 DCHECK(controller_);
18 }
19
HostRanInsecureContent(const std::string & host,int id)20 void SSLPolicyBackend::HostRanInsecureContent(const std::string& host, int id) {
21 if (ssl_host_state_delegate_)
22 ssl_host_state_delegate_->HostRanInsecureContent(host, id);
23 SSLManager::NotifySSLInternalStateChanged(controller_->GetBrowserContext());
24 }
25
DidHostRunInsecureContent(const std::string & host,int pid) const26 bool SSLPolicyBackend::DidHostRunInsecureContent(const std::string& host,
27 int pid) const {
28 if (!ssl_host_state_delegate_)
29 return false;
30
31 return ssl_host_state_delegate_->DidHostRunInsecureContent(host, pid);
32 }
33
AllowCertForHost(const net::X509Certificate & cert,const std::string & host,net::CertStatus error)34 void SSLPolicyBackend::AllowCertForHost(const net::X509Certificate& cert,
35 const std::string& host,
36 net::CertStatus error) {
37 if (ssl_host_state_delegate_)
38 ssl_host_state_delegate_->AllowCert(host, cert, error);
39 }
40
QueryPolicy(const net::X509Certificate & cert,const std::string & host,net::CertStatus error,bool * expired_previous_decision)41 SSLHostStateDelegate::CertJudgment SSLPolicyBackend::QueryPolicy(
42 const net::X509Certificate& cert,
43 const std::string& host,
44 net::CertStatus error,
45 bool* expired_previous_decision) {
46 return ssl_host_state_delegate_ ?
47 ssl_host_state_delegate_->QueryPolicy(
48 host, cert, error, expired_previous_decision) :
49 SSLHostStateDelegate::DENIED;
50 }
51
52 } // namespace content
53