OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ |
| 6 #define CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 14 #include "base/supports_user_data.h" |
| 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "content/common/content_export.h" |
| 17 #include "net/cert/cert_status_flags.h" |
| 18 #include "net/cert/x509_certificate.h" |
| 19 |
| 20 namespace content { |
| 21 class BrowserContext; |
| 22 class SSLHostStateDelegate; |
| 23 |
| 24 // SSLHostState |
| 25 // |
| 26 // The SSLHostState encapulates the host-specific state for SSL errors. For |
| 27 // example, SSLHostState remembers whether the user has whitelisted a |
| 28 // particular broken cert for use with particular host. We separate this state |
| 29 // from the SSLManager because this state is shared across many navigation |
| 30 // controllers. |
| 31 class CONTENT_EXPORT SSLHostState |
| 32 : NON_EXPORTED_BASE(base::SupportsUserData::Data), |
| 33 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 34 public: |
| 35 // Contexts may specify a NULL certificate decision storage strategy. In that |
| 36 // case, the returned SSLHostState from GetFor() will implement a default |
| 37 // strategy of ignoring all exception requests and returning |
| 38 // net::QueryPolicy::Judgment::UNKOWN from QueryPolicy(). |
| 39 static SSLHostState* GetFor(BrowserContext* browser_context); |
| 40 |
| 41 SSLHostState(); |
| 42 virtual ~SSLHostState(); |
| 43 |
| 44 // Records that a host has run insecure content. |
| 45 void HostRanInsecureContent(const std::string& host, int pid); |
| 46 |
| 47 // Returns whether the specified host ran insecure content. |
| 48 bool DidHostRunInsecureContent(const std::string& host, int pid) const; |
| 49 |
| 50 // Records that |cert| is not permitted to be used for |url| in the future, |
| 51 // for a specified |error| type. |
| 52 void DenyCertForHost(net::X509Certificate* cert, |
| 53 const std::string& host, |
| 54 net::CertStatus error); |
| 55 |
| 56 // Records that |cert| is permitted to be used for |url| in the future, for |
| 57 // a specified |error| type. |
| 58 void AllowCertForHost(net::X509Certificate* cert, |
| 59 const std::string& host, |
| 60 net::CertStatus error); |
| 61 |
| 62 // Revoke all allow/deny preferences for |url|. |
| 63 void RevokeAllowAndDenyPreferences(const std::string& host); |
| 64 |
| 65 bool HasAllowedOrDeniedCert(const std::string& host); |
| 66 |
| 67 // Clear all allow/deny preferences. |
| 68 void Clear(); |
| 69 |
| 70 // Queries whether |cert| is allowed or denied for |url| and |error|. |
| 71 net::CertPolicy::Judgment QueryPolicy(net::X509Certificate* cert, |
| 72 const std::string& host, |
| 73 net::CertStatus error); |
| 74 |
| 75 private: |
| 76 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host |
| 77 // contains insecure content in that renderer process. |
| 78 typedef std::pair<std::string, int> BrokenHostEntry; |
| 79 |
| 80 // Hosts which have been contaminated with insecure content in the |
| 81 // specified process. Note that insecure content can travel between |
| 82 // same-origin frames in one processs but cannot jump between processes. |
| 83 std::set<BrokenHostEntry> ran_insecure_content_hosts_; |
| 84 |
| 85 // The certificate decision store. It may be NULL, depending on the browsing |
| 86 // context. This is owned by the browsing context. |
| 87 SSLHostStateDelegate* delegate_; |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(SSLHostState); |
| 90 }; |
| 91 |
| 92 } // namespace content |
| 93 |
| 94 #endif // CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_ |
OLD | NEW |