Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "net/cert/cert_status_flags.h" | 17 #include "net/cert/cert_status_flags.h" |
| 18 #include "net/cert/x509_certificate.h" | 18 #include "net/cert/x509_certificate.h" |
| 19 | 19 |
| 20 class GURL; | |
| 21 | |
| 20 namespace content { | 22 namespace content { |
| 21 class BrowserContext; | 23 class BrowserContext; |
| 24 class SSLHostStateDecisions; | |
| 22 | 25 |
| 23 // SSLHostState | 26 // SSLHostState |
| 24 // | 27 // |
| 25 // The SSLHostState encapulates the host-specific state for SSL errors. For | 28 // The SSLHostState encapulates the host-specific state for SSL errors. For |
| 26 // example, SSLHostState remembers whether the user has whitelisted a | 29 // example, SSLHostState remembers whether the user has whitelisted a |
| 27 // particular broken cert for use with particular host. We separate this state | 30 // particular broken cert for use with particular host. We separate this state |
| 28 // from the SSLManager because this state is shared across many navigation | 31 // from the SSLManager because this state is shared across many navigation |
| 29 // controllers. | 32 // controllers. |
| 30 | 33 |
| 31 class CONTENT_EXPORT SSLHostState | 34 class CONTENT_EXPORT SSLHostState |
| 32 : NON_EXPORTED_BASE(base::SupportsUserData::Data), | 35 : NON_EXPORTED_BASE(base::SupportsUserData::Data), |
| 33 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 36 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 34 public: | 37 public: |
| 35 static SSLHostState* GetFor(BrowserContext* browser_context); | 38 static SSLHostState* GetFor(BrowserContext* browser_context); |
| 36 | 39 |
| 37 SSLHostState(); | 40 SSLHostState(); |
| 38 virtual ~SSLHostState(); | 41 virtual ~SSLHostState(); |
| 39 | 42 |
| 40 // Records that a host has run insecure content. | 43 // Records that a host has run insecure content. |
| 41 void HostRanInsecureContent(const std::string& host, int pid); | 44 void HostRanInsecureContent(const std::string& host, int pid); |
| 42 | 45 |
| 43 // Returns whether the specified host ran insecure content. | 46 // Returns whether the specified host ran insecure content. |
| 44 bool DidHostRunInsecureContent(const std::string& host, int pid) const; | 47 bool DidHostRunInsecureContent(const std::string& host, int pid) const; |
| 45 | 48 |
| 46 // Records that |cert| is not permitted to be used for |host| in the future, | 49 // Records that |cert| is not permitted to be used for |host| in the future, |
| 47 // for a specified |error| type.. | 50 // for a specified |error| type.. |
| 48 void DenyCertForHost(net::X509Certificate* cert, | 51 void DenyCertForHost(net::X509Certificate* cert, |
| 49 const std::string& host, | 52 const GURL& url, |
| 50 net::CertStatus error); | 53 net::CertStatus error); |
| 51 | 54 |
| 52 // Records that |cert| is permitted to be used for |host| in the future, for | 55 // Records that |cert| is permitted to be used for |host| in the future, for |
| 53 // a specified |error| type. | 56 // a specified |error| type. |
| 54 void AllowCertForHost(net::X509Certificate* cert, | 57 void AllowCertForHost(net::X509Certificate* cert, |
| 55 const std::string& host, | 58 const GURL& url, |
| 56 net::CertStatus error); | 59 net::CertStatus error); |
| 57 | 60 |
| 61 // Revoke all allow/deny preferences for a given url. May close idle | |
| 62 // HTTP/HTTPS connections in the process. | |
| 63 void RevokeAllowAndDenyPreferences(const GURL& url); | |
| 64 | |
| 65 bool HasAllowedOrDeniedCert(const GURL& url); | |
| 66 | |
| 58 // Clear all allow/deny preferences. | 67 // Clear all allow/deny preferences. |
| 59 void Clear(); | 68 void Clear(); |
| 60 | 69 |
| 61 // Queries whether |cert| is allowed or denied for |host| and |error|. | 70 // Queries whether |cert| is allowed or denied for |host| and |error|. |
| 62 net::CertPolicy::Judgment QueryPolicy(net::X509Certificate* cert, | 71 net::CertPolicy::Judgment QueryPolicy(net::X509Certificate* cert, |
| 63 const std::string& host, | 72 const GURL& url, |
| 64 net::CertStatus error); | 73 net::CertStatus error); |
| 65 | 74 |
| 66 private: | 75 private: |
| 67 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host | 76 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host |
| 68 // contains insecure content in that renderer process. | 77 // contains insecure content in that renderer process. |
| 69 typedef std::pair<std::string, int> BrokenHostEntry; | 78 typedef std::pair<std::string, int> BrokenHostEntry; |
| 70 | 79 |
| 71 // Hosts which have been contaminated with insecure content in the | 80 // Hosts which have been contaminated with insecure content in the |
| 72 // specified process. Note that insecure content can travel between | 81 // specified process. Note that insecure content can travel between |
| 73 // same-origin frames in one processs but cannot jump between processes. | 82 // same-origin frames in one processs but cannot jump between processes. |
| 74 std::set<BrokenHostEntry> ran_insecure_content_hosts_; | 83 std::set<BrokenHostEntry> ran_insecure_content_hosts_; |
| 75 | 84 |
| 76 // Certificate policies for each host. | 85 // BrowserContext that the state was created on. |
| 77 std::map<std::string, net::CertPolicy> cert_policy_for_host_; | 86 BrowserContext* browser_context_; |
| 87 | |
| 88 // The certificate decision store. It may be NULl, depending on the browsing | |
|
felt
2014/07/08 17:52:49
nit: NULL
jww
2014/07/08 23:49:01
Done.
| |
| 89 // context. This pointer belongs to the browsing context. | |
| 90 SSLHostStateDecisions* decisions_; | |
| 78 | 91 |
| 79 DISALLOW_COPY_AND_ASSIGN(SSLHostState); | 92 DISALLOW_COPY_AND_ASSIGN(SSLHostState); |
| 80 }; | 93 }; |
| 81 | 94 |
| 82 } // namespace content | 95 } // namespace content |
| 83 | 96 |
| 84 #endif // CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ | 97 #endif // CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ |
| OLD | NEW |