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

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

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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ 5 #ifndef CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_
6 #define CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ 6 #define CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/supports_user_data.h"
15 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
16 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
19 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
20 #include "net/base/x509_certificate.h" 19 #include "net/base/x509_certificate.h"
21 20
22 namespace content { 21 namespace content {
23 class BrowserContext; 22 class BrowserContext;
24 } 23 }
25 24
26 // SSLHostState 25 // SSLHostState
27 // 26 //
28 // The SSLHostState encapulates the host-specific state for SSL errors. For 27 // The SSLHostState encapulates the host-specific state for SSL errors. For
29 // example, SSLHostState remembers whether the user has whitelisted a 28 // example, SSLHostState remembers whether the user has whitelisted a
30 // particular broken cert for use with particular host. We separate this state 29 // particular broken cert for use with particular host. We separate this state
31 // from the SSLManager because this state is shared across many navigation 30 // from the SSLManager because this state is shared across many navigation
32 // controllers. 31 // controllers.
33 32
34 class CONTENT_EXPORT SSLHostState 33 class CONTENT_EXPORT SSLHostState
35 : public content::NotificationObserver, 34 : NON_EXPORTED_BASE(base::SupportsUserData::Data),
36 NON_EXPORTED_BASE(public base::NonThreadSafe) { 35 NON_EXPORTED_BASE(public base::NonThreadSafe) {
37 public: 36 public:
38 static SSLHostState* GetFor(content::BrowserContext* browser_context); 37 static SSLHostState* GetFor(content::BrowserContext* browser_context);
39 38
40 explicit SSLHostState(content::BrowserContext* browser_context); 39 SSLHostState();
41 virtual ~SSLHostState(); 40 virtual ~SSLHostState();
42 41
43 // Records that a host has run insecure content. 42 // Records that a host has run insecure content.
44 void HostRanInsecureContent(const std::string& host, int pid); 43 void HostRanInsecureContent(const std::string& host, int pid);
45 44
46 // Returns whether the specified host ran insecure content. 45 // Returns whether the specified host ran insecure content.
47 bool DidHostRunInsecureContent(const std::string& host, int pid) const; 46 bool DidHostRunInsecureContent(const std::string& host, int pid) const;
48 47
49 // Records that |cert| is permitted to be used for |host| in the future. 48 // Records that |cert| is permitted to be used for |host| in the future.
50 void DenyCertForHost(net::X509Certificate* cert, const std::string& host); 49 void DenyCertForHost(net::X509Certificate* cert, const std::string& host);
51 50
52 // Records that |cert| is not permitted to be used for |host| in the future. 51 // Records that |cert| is not permitted to be used for |host| in the future.
53 void AllowCertForHost(net::X509Certificate* cert, const std::string& host); 52 void AllowCertForHost(net::X509Certificate* cert, const std::string& host);
54 53
55 // Queries whether |cert| is allowed or denied for |host|. 54 // Queries whether |cert| is allowed or denied for |host|.
56 net::CertPolicy::Judgment QueryPolicy( 55 net::CertPolicy::Judgment QueryPolicy(
57 net::X509Certificate* cert, const std::string& host); 56 net::X509Certificate* cert, const std::string& host);
58 57
59 private: 58 private:
60 virtual void Observe(int type,
61 const content::NotificationSource& source,
62 const content::NotificationDetails& details) OVERRIDE;
63
64 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host 59 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host
65 // contains insecure content in that renderer process. 60 // contains insecure content in that renderer process.
66 typedef std::pair<std::string, int> BrokenHostEntry; 61 typedef std::pair<std::string, int> BrokenHostEntry;
67 62
68 // Hosts which have been contaminated with insecure content in the 63 // Hosts which have been contaminated with insecure content in the
69 // specified process. Note that insecure content can travel between 64 // specified process. Note that insecure content can travel between
70 // same-origin frames in one processs but cannot jump between processes. 65 // same-origin frames in one processs but cannot jump between processes.
71 std::set<BrokenHostEntry> ran_insecure_content_hosts_; 66 std::set<BrokenHostEntry> ran_insecure_content_hosts_;
72 67
73 // Certificate policies for each host. 68 // Certificate policies for each host.
74 std::map<std::string, net::CertPolicy> cert_policy_for_host_; 69 std::map<std::string, net::CertPolicy> cert_policy_for_host_;
75 70
76 content::NotificationRegistrar registrar_;
77
78 DISALLOW_COPY_AND_ASSIGN(SSLHostState); 71 DISALLOW_COPY_AND_ASSIGN(SSLHostState);
79 }; 72 };
80 73
81 #endif // CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ 74 #endif // CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698