Index: content/browser/ssl/ssl_host_state_impl.cc |
diff --git a/content/browser/ssl/ssl_host_state_impl.cc b/content/browser/ssl/ssl_host_state_impl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6ce195b29df0a17390efdc68f2b848d7bbfb9c9e |
--- /dev/null |
+++ b/content/browser/ssl/ssl_host_state_impl.cc |
@@ -0,0 +1,90 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/ssl/ssl_host_state_impl.h" |
+ |
+#include "base/lazy_instance.h" |
+#include "base/logging.h" |
+#include "content/public/browser/browser_context.h" |
+#include "net/http/http_transaction_factory.h" |
+#include "net/url_request/url_request_context.h" |
+#include "net/url_request/url_request_context_getter.h" |
+ |
+const char kKeyName[] = "content_ssl_host_state"; |
+ |
+namespace content { |
+ |
+SSLHostState* SSLHostState::GetFor(BrowserContext* context) { |
+ SSLHostStateImpl* rv = |
+ static_cast<SSLHostStateImpl*>(context->GetUserData(kKeyName)); |
+ if (!rv) { |
+ rv = new SSLHostStateImpl(); |
+ context->SetUserData(kKeyName, rv); |
+ } |
+ return rv; |
+} |
+ |
+SSLHostStateImpl::SSLHostStateImpl() { |
+} |
+ |
+SSLHostStateImpl::~SSLHostStateImpl() { |
+} |
+ |
+void SSLHostStateImpl::HostRanInsecureContent(const std::string& host, |
+ int pid) { |
+ DCHECK(CalledOnValidThread()); |
+ ran_insecure_content_hosts_.insert(BrokenHostEntry(host, pid)); |
+} |
+ |
+bool SSLHostStateImpl::DidHostRunInsecureContent(const std::string& host, |
+ int pid) const { |
+ DCHECK(CalledOnValidThread()); |
+ return !!ran_insecure_content_hosts_.count(BrokenHostEntry(host, pid)); |
+} |
+ |
+void SSLHostStateImpl::DenyCertForHost(net::X509Certificate* cert, |
+ const std::string& host, |
+ net::CertStatus error) { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ cert_policy_for_host_[host].Deny(cert, error); |
+} |
+ |
+void SSLHostStateImpl::AllowCertForHost(net::X509Certificate* cert, |
+ const std::string& host, |
+ net::CertStatus error) { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ cert_policy_for_host_[host].Allow(cert, error); |
+} |
+ |
+void SSLHostStateImpl::Clear() { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ cert_policy_for_host_.clear(); |
+} |
+ |
+void SSLHostStateImpl::RevokeAllowAndDenyPreferences(const std::string& host) { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ cert_policy_for_host_.erase(cert_policy_for_host_.find(host)); |
+} |
+ |
+bool SSLHostStateImpl::HasAllowedOrDeniedCert(const std::string& host) { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ return cert_policy_for_host_[host].HasAllowedCert() || |
+ cert_policy_for_host_[host].HasDeniedCert(); |
+} |
+ |
+net::CertPolicy::Judgment SSLHostStateImpl::QueryPolicy( |
+ net::X509Certificate* cert, |
+ const std::string& host, |
+ net::CertStatus error) { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ return cert_policy_for_host_[host].Check(cert, error); |
+} |
+ |
+} // namespace content |