OLD | NEW |
1 // Copyright (c) 2006-2009 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 #ifndef CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ |
6 #define CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ | 6 #define CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/non_thread_safe.h" | 13 #include "base/non_thread_safe.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "net/base/x509_certificate.h" | 15 #include "net/base/x509_certificate.h" |
16 | 16 |
17 // SSLHostState | 17 // SSLHostState |
18 // | 18 // |
19 // The SSLHostState encapulates the host-specific state for SSL errors. For | 19 // The SSLHostState encapulates the host-specific state for SSL errors. For |
20 // example, SSLHostState remembers whether the user has whitelisted a | 20 // example, SSLHostState remembers whether the user has whitelisted a |
21 // particular broken cert for use with particular host. We separate this state | 21 // particular broken cert for use with particular host. We separate this state |
22 // from the SSLManager because this state is shared across many navigation | 22 // from the SSLManager because this state is shared across many navigation |
23 // controllers. | 23 // controllers. |
24 | 24 |
25 class SSLHostState : public NonThreadSafe { | 25 class SSLHostState : public NonThreadSafe { |
26 public: | 26 public: |
27 SSLHostState(); | 27 SSLHostState(); |
28 ~SSLHostState(); | 28 ~SSLHostState(); |
29 | 29 |
30 // Records that a host is "broken" in a particular render process. That is, | 30 // Records that a host has run insecure content. |
31 // the origin for that host has been contaminated with insecure content, | 31 void HostRanInsecureContent(const std::string& host, int pid); |
32 // either via HTTP or via HTTPS with a bad certificate. | |
33 void MarkHostAsBroken(const std::string& host, int pid); | |
34 | 32 |
35 // Returns whether the specified host was marked as broken in a particular | 33 // Returns whether the specified host ran insecure content. |
36 // render process. | 34 bool DidHostRunInsecureContent(const std::string& host, int pid) const; |
37 bool DidMarkHostAsBroken(const std::string& host, int pid); | |
38 | 35 |
39 // Records that |cert| is permitted to be used for |host| in the future. | 36 // Records that |cert| is permitted to be used for |host| in the future. |
40 void DenyCertForHost(net::X509Certificate* cert, const std::string& host); | 37 void DenyCertForHost(net::X509Certificate* cert, const std::string& host); |
41 | 38 |
42 // Records that |cert| is not permitted to be used for |host| in the future. | 39 // Records that |cert| is not permitted to be used for |host| in the future. |
43 void AllowCertForHost(net::X509Certificate* cert, const std::string& host); | 40 void AllowCertForHost(net::X509Certificate* cert, const std::string& host); |
44 | 41 |
45 // Queries whether |cert| is allowed or denied for |host|. | 42 // Queries whether |cert| is allowed or denied for |host|. |
46 net::X509Certificate::Policy::Judgment QueryPolicy( | 43 net::X509Certificate::Policy::Judgment QueryPolicy( |
47 net::X509Certificate* cert, const std::string& host); | 44 net::X509Certificate* cert, const std::string& host); |
48 | 45 |
49 private: | 46 private: |
50 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host | 47 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host |
51 // contains insecure content in that renderer process. | 48 // contains insecure content in that renderer process. |
52 typedef std::pair<std::string, int> BrokenHostEntry; | 49 typedef std::pair<std::string, int> BrokenHostEntry; |
53 | 50 |
54 // Hosts which have been contaminated with insecure content in the | 51 // Hosts which have been contaminated with insecure content in the |
55 // specified process. Note that insecure content can travel between | 52 // specified process. Note that insecure content can travel between |
56 // same-origin frames in one processs but cannot jump between processes. | 53 // same-origin frames in one processs but cannot jump between processes. |
57 std::set<BrokenHostEntry> broken_hosts_; | 54 std::set<BrokenHostEntry> ran_insecure_content_hosts_; |
58 | 55 |
59 // Certificate policies for each host. | 56 // Certificate policies for each host. |
60 std::map<std::string, net::X509Certificate::Policy> cert_policy_for_host_; | 57 std::map<std::string, net::X509Certificate::Policy> cert_policy_for_host_; |
61 | 58 |
62 DISALLOW_COPY_AND_ASSIGN(SSLHostState); | 59 DISALLOW_COPY_AND_ASSIGN(SSLHostState); |
63 }; | 60 }; |
64 | 61 |
65 #endif // CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ | 62 #endif // CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ |
OLD | NEW |