OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HOST_STATE_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_SSL_HOST_STATE_DELEGATE_H_ |
6 #define CONTENT_BROWSER_SSL_HOST_STATE_DELEGATE_H_ | 6 #define CONTENT_BROWSER_SSL_HOST_STATE_DELEGATE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/threading/non_thread_safe.h" |
10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
11 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
| 16 // The SSLHostStateDelegate encapulates the host-specific state for SSL errors. |
| 17 // For example, SSLHostStateDelegate remembers whether the user has whitelisted |
| 18 // a particular broken cert for use with particular host. We separate this |
| 19 // state from the SSLManager because this state is shared across many navigation |
| 20 // controllers. |
| 21 // |
15 // SSLHostStateDelegate may be implemented by the embedder to provide a storage | 22 // SSLHostStateDelegate may be implemented by the embedder to provide a storage |
16 // strategy for certificate decisions. | 23 // strategy for certificate decisions or it may be left unimplemented to use a |
17 class SSLHostStateDelegate { | 24 // default strategy of not remembering decisions at all. |
| 25 class SSLHostStateDelegate : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
18 public: | 26 public: |
| 27 SSLHostStateDelegate() {} |
| 28 |
19 // Records that |cert| is not permitted to be used for |host| in the future, | 29 // Records that |cert| is not permitted to be used for |host| in the future, |
20 // for a specified |error| type. | 30 // for a specified |error| type. |
21 virtual void DenyCert(const std::string& host, | 31 virtual void DenyCert(const std::string& host, |
22 net::X509Certificate* cert, | 32 net::X509Certificate* cert, |
23 net::CertStatus error) = 0; | 33 net::CertStatus error) = 0; |
24 | 34 |
25 // Records that |cert| is permitted to be used for |host| in the future, for | 35 // Records that |cert| is permitted to be used for |host| in the future, for |
26 // a specified |error| type. | 36 // a specified |error| type. |
27 virtual void AllowCert(const std::string&, | 37 virtual void AllowCert(const std::string&, |
28 net::X509Certificate* cert, | 38 net::X509Certificate* cert, |
29 net::CertStatus error) = 0; | 39 net::CertStatus error) = 0; |
30 | 40 |
31 // Clear all allow/deny preferences. | 41 // Clear all allow/deny preferences. |
32 virtual void Clear() = 0; | 42 virtual void Clear() = 0; |
33 | 43 |
34 // Queries whether |cert| is allowed or denied for |host| and |error|. | 44 // Queries whether |cert| is allowed or denied for |host| and |error|. |
35 virtual net::CertPolicy::Judgment QueryPolicy(const std::string& host, | 45 virtual net::CertPolicy::Judgment QueryPolicy(const std::string& host, |
36 net::X509Certificate* cert, | 46 net::X509Certificate* cert, |
37 net::CertStatus error) = 0; | 47 net::CertStatus error) = 0; |
38 | 48 |
39 // Revoke all allow/deny preferences for |host|. | 49 // Revoke all allow/deny preferences for |host|. |
40 virtual void RevokeAllowAndDenyPreferences(const std::string& host) = 0; | 50 virtual void RevokeAllowAndDenyPreferences(const std::string& host) = 0; |
41 | 51 |
42 // Returns true if any decisions has been recorded for |host|, otherwise | 52 // Returns true if any decisions has been recorded for |host|, otherwise |
43 // false. | 53 // false. |
44 virtual bool HasAllowedOrDeniedCert(const std::string& host) = 0; | 54 virtual bool HasAllowedOrDeniedCert(const std::string& host) = 0; |
45 | 55 |
| 56 // Records that a host has run insecure content. |
| 57 virtual void HostRanInsecureContent(const std::string& host, int pid) = 0; |
| 58 |
| 59 // Returns whether the specified host ran insecure content. |
| 60 virtual bool DidHostRunInsecureContent(const std::string& host, |
| 61 int pid) const = 0; |
| 62 |
46 protected: | 63 protected: |
47 virtual ~SSLHostStateDelegate() {} | 64 virtual ~SSLHostStateDelegate() {} |
| 65 |
| 66 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(SSLHostStateDelegate); |
48 }; | 68 }; |
49 | 69 |
50 } // namespace content | 70 } // namespace content |
51 | 71 |
52 #endif // CONTENT_BROWSER_SSL_HOST_STATE_DELEGATE_H_ | 72 #endif // CONTENT_BROWSER_SSL_HOST_STATE_DELEGATE_H_ |
OLD | NEW |