OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 has run insecure content. | 30 // Records that a host is "broken" in a particular render process. That is, |
31 void HostRanInsecureContent(const std::string& host, int pid); | 31 // the origin for that host has been contaminated with insecure content, |
| 32 // either via HTTP or via HTTPS with a bad certificate. |
| 33 void MarkHostAsBroken(const std::string& host, int pid); |
32 | 34 |
33 // Returns whether the specified host ran insecure content. | 35 // Returns whether the specified host was marked as broken in a particular |
34 bool DidHostRunInsecureContent(const std::string& host, int pid) const; | 36 // render process. |
| 37 bool DidMarkHostAsBroken(const std::string& host, int pid); |
35 | 38 |
36 // Records that |cert| is permitted to be used for |host| in the future. | 39 // Records that |cert| is permitted to be used for |host| in the future. |
37 void DenyCertForHost(net::X509Certificate* cert, const std::string& host); | 40 void DenyCertForHost(net::X509Certificate* cert, const std::string& host); |
38 | 41 |
39 // Records that |cert| is not permitted to be used for |host| in the future. | 42 // Records that |cert| is not permitted to be used for |host| in the future. |
40 void AllowCertForHost(net::X509Certificate* cert, const std::string& host); | 43 void AllowCertForHost(net::X509Certificate* cert, const std::string& host); |
41 | 44 |
42 // Queries whether |cert| is allowed or denied for |host|. | 45 // Queries whether |cert| is allowed or denied for |host|. |
43 net::X509Certificate::Policy::Judgment QueryPolicy( | 46 net::X509Certificate::Policy::Judgment QueryPolicy( |
44 net::X509Certificate* cert, const std::string& host); | 47 net::X509Certificate* cert, const std::string& host); |
45 | 48 |
46 private: | 49 private: |
47 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host | 50 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host |
48 // contains insecure content in that renderer process. | 51 // contains insecure content in that renderer process. |
49 typedef std::pair<std::string, int> BrokenHostEntry; | 52 typedef std::pair<std::string, int> BrokenHostEntry; |
50 | 53 |
51 // Hosts which have been contaminated with insecure content in the | 54 // Hosts which have been contaminated with insecure content in the |
52 // specified process. Note that insecure content can travel between | 55 // specified process. Note that insecure content can travel between |
53 // same-origin frames in one processs but cannot jump between processes. | 56 // same-origin frames in one processs but cannot jump between processes. |
54 std::set<BrokenHostEntry> ran_insecure_content_hosts_; | 57 std::set<BrokenHostEntry> broken_hosts_; |
55 | 58 |
56 // Certificate policies for each host. | 59 // Certificate policies for each host. |
57 std::map<std::string, net::X509Certificate::Policy> cert_policy_for_host_; | 60 std::map<std::string, net::X509Certificate::Policy> cert_policy_for_host_; |
58 | 61 |
59 DISALLOW_COPY_AND_ASSIGN(SSLHostState); | 62 DISALLOW_COPY_AND_ASSIGN(SSLHostState); |
60 }; | 63 }; |
61 | 64 |
62 #endif // CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ | 65 #endif // CHROME_BROWSER_SSL_SSL_HOST_STATE_H_ |
OLD | NEW |