OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/ssl/ssl_policy_backend.h" | 5 #include "content/browser/ssl/ssl_policy_backend.h" |
6 | 6 |
7 #include "content/browser/frame_host/navigation_controller_impl.h" | 7 #include "content/browser/frame_host/navigation_controller_impl.h" |
8 #include "content/browser/ssl/ssl_host_state.h" | |
9 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
| 9 #include "content/public/browser/ssl_host_state_delegate.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 SSLPolicyBackend::SSLPolicyBackend(NavigationControllerImpl* controller) | 13 SSLPolicyBackend::SSLPolicyBackend(NavigationControllerImpl* controller) |
14 : ssl_host_state_(SSLHostState::GetFor(controller->GetBrowserContext())), | 14 : ssl_host_state_delegate_( |
| 15 controller->GetBrowserContext()->GetSSLHostStateDelegate()), |
15 controller_(controller) { | 16 controller_(controller) { |
16 DCHECK(controller_); | 17 DCHECK(controller_); |
17 } | 18 } |
18 | 19 |
19 void SSLPolicyBackend::HostRanInsecureContent(const std::string& host, int id) { | 20 void SSLPolicyBackend::HostRanInsecureContent(const std::string& host, int id) { |
20 ssl_host_state_->HostRanInsecureContent(host, id); | 21 if (ssl_host_state_delegate_) |
| 22 ssl_host_state_delegate_->HostRanInsecureContent(host, id); |
21 SSLManager::NotifySSLInternalStateChanged(controller_->GetBrowserContext()); | 23 SSLManager::NotifySSLInternalStateChanged(controller_->GetBrowserContext()); |
22 } | 24 } |
23 | 25 |
24 bool SSLPolicyBackend::DidHostRunInsecureContent(const std::string& host, | 26 bool SSLPolicyBackend::DidHostRunInsecureContent(const std::string& host, |
25 int pid) const { | 27 int pid) const { |
26 return ssl_host_state_->DidHostRunInsecureContent(host, pid); | 28 if (!ssl_host_state_delegate_) |
| 29 return false; |
| 30 |
| 31 return ssl_host_state_delegate_->DidHostRunInsecureContent(host, pid); |
27 } | 32 } |
28 | 33 |
29 void SSLPolicyBackend::DenyCertForHost(net::X509Certificate* cert, | 34 void SSLPolicyBackend::DenyCertForHost(net::X509Certificate* cert, |
30 const std::string& host, | 35 const std::string& host, |
31 net::CertStatus error) { | 36 net::CertStatus error) { |
32 ssl_host_state_->DenyCertForHost(cert, host, error); | 37 if (ssl_host_state_delegate_) |
| 38 ssl_host_state_delegate_->DenyCert(host, cert, error); |
33 } | 39 } |
34 | 40 |
35 void SSLPolicyBackend::AllowCertForHost(net::X509Certificate* cert, | 41 void SSLPolicyBackend::AllowCertForHost(net::X509Certificate* cert, |
36 const std::string& host, | 42 const std::string& host, |
37 net::CertStatus error) { | 43 net::CertStatus error) { |
38 ssl_host_state_->AllowCertForHost(cert, host, error); | 44 if (ssl_host_state_delegate_) |
| 45 ssl_host_state_delegate_->AllowCert(host, cert, error); |
39 } | 46 } |
40 | 47 |
41 net::CertPolicy::Judgment SSLPolicyBackend::QueryPolicy( | 48 net::CertPolicy::Judgment SSLPolicyBackend::QueryPolicy( |
42 net::X509Certificate* cert, | 49 net::X509Certificate* cert, |
43 const std::string& host, | 50 const std::string& host, |
44 net::CertStatus error) { | 51 net::CertStatus error) { |
45 return ssl_host_state_->QueryPolicy(cert, host, error); | 52 if (!ssl_host_state_delegate_) |
| 53 return net::CertPolicy::UNKNOWN; |
| 54 |
| 55 return ssl_host_state_delegate_->QueryPolicy(host, cert, error); |
46 } | 56 } |
47 | 57 |
48 } // namespace content | 58 } // namespace content |
OLD | NEW |