Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / ssl / ssl_host_state.cc
blob06c600205fa8b1277b5252e91cbbf56580320c21
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.
5 #include "content/browser/ssl/ssl_host_state.h"
7 #include "base/logging.h"
8 #include "base/lazy_instance.h"
9 #include "content/public/browser/browser_context.h"
11 const char kKeyName[] = "content_ssl_host_state";
13 namespace content {
15 SSLHostState* SSLHostState::GetFor(BrowserContext* context) {
16 SSLHostState* rv = static_cast<SSLHostState*>(context->GetUserData(kKeyName));
17 if (!rv) {
18 rv = new SSLHostState();
19 context->SetUserData(kKeyName, rv);
21 return rv;
24 SSLHostState::SSLHostState() {
27 SSLHostState::~SSLHostState() {
30 void SSLHostState::HostRanInsecureContent(const std::string& host, int pid) {
31 DCHECK(CalledOnValidThread());
32 ran_insecure_content_hosts_.insert(BrokenHostEntry(host, pid));
35 bool SSLHostState::DidHostRunInsecureContent(const std::string& host,
36 int pid) const {
37 DCHECK(CalledOnValidThread());
38 return !!ran_insecure_content_hosts_.count(BrokenHostEntry(host, pid));
41 void SSLHostState::DenyCertForHost(net::X509Certificate* cert,
42 const std::string& host,
43 net::CertStatus error) {
44 DCHECK(CalledOnValidThread());
46 cert_policy_for_host_[host].Deny(cert, error);
49 void SSLHostState::AllowCertForHost(net::X509Certificate* cert,
50 const std::string& host,
51 net::CertStatus error) {
52 DCHECK(CalledOnValidThread());
54 cert_policy_for_host_[host].Allow(cert, error);
57 void SSLHostState::Clear() {
58 DCHECK(CalledOnValidThread());
60 cert_policy_for_host_.clear();
63 net::CertPolicy::Judgment SSLHostState::QueryPolicy(net::X509Certificate* cert,
64 const std::string& host,
65 net::CertStatus error) {
66 DCHECK(CalledOnValidThread());
68 return cert_policy_for_host_[host].Check(cert, error);
71 } // namespace content