Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: content/browser/ssl/ssl_host_state.cc

Issue 9348109: Add extra data to BrowserContext so that content layer and other embedders can stash data with it t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_host_state.h" 5 #include "content/browser/ssl/ssl_host_state.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_source.h"
11 #include "content/public/browser/notification_types.h"
12 9
13 namespace { 10 static const char* kKeyName = "content_ssl_host_state";
14 typedef std::map<content::BrowserContext*, SSLHostState*> HostStateMap; 11
15 static base::LazyInstance<HostStateMap> g_host_state_map = 12 SSLHostState* SSLHostState::GetFor(content::BrowserContext* context) {
16 LAZY_INSTANCE_INITIALIZER; 13 SSLHostState* rv = static_cast<SSLHostState*>(context->GetUserData(kKeyName));
14 if (!rv) {
15 rv = new SSLHostState();
16 context->SetUserData(kKeyName, rv);
17 }
18 return rv;
17 } 19 }
18 20
19 SSLHostState* SSLHostState::GetFor(content::BrowserContext* browser_context) { 21 SSLHostState::SSLHostState() {
20 if (!g_host_state_map.Get().count(browser_context))
21 g_host_state_map.Get()[browser_context] = new SSLHostState(browser_context);
22 return g_host_state_map.Get()[browser_context];
23 }
24
25 SSLHostState::SSLHostState(content::BrowserContext* browser_context) {
26 registrar_.Add(this, content::NOTIFICATION_BROWSER_CONTEXT_DESTRUCTION,
27 content::Source<content::BrowserContext>(browser_context));
28 } 22 }
29 23
30 SSLHostState::~SSLHostState() { 24 SSLHostState::~SSLHostState() {
31 } 25 }
32 26
33 void SSLHostState::HostRanInsecureContent(const std::string& host, int pid) { 27 void SSLHostState::HostRanInsecureContent(const std::string& host, int pid) {
34 DCHECK(CalledOnValidThread()); 28 DCHECK(CalledOnValidThread());
35 ran_insecure_content_hosts_.insert(BrokenHostEntry(host, pid)); 29 ran_insecure_content_hosts_.insert(BrokenHostEntry(host, pid));
36 } 30 }
37 31
(...skipping 16 matching lines...) Expand all
54 48
55 cert_policy_for_host_[host].Allow(cert); 49 cert_policy_for_host_[host].Allow(cert);
56 } 50 }
57 51
58 net::CertPolicy::Judgment SSLHostState::QueryPolicy( 52 net::CertPolicy::Judgment SSLHostState::QueryPolicy(
59 net::X509Certificate* cert, const std::string& host) { 53 net::X509Certificate* cert, const std::string& host) {
60 DCHECK(CalledOnValidThread()); 54 DCHECK(CalledOnValidThread());
61 55
62 return cert_policy_for_host_[host].Check(cert); 56 return cert_policy_for_host_[host].Check(cert);
63 } 57 }
64
65 void SSLHostState::Observe(int type,
66 const content::NotificationSource& source,
67 const content::NotificationDetails& details) {
68 delete this;
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698