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_PUBLIC_BROWSER_SSL_HOST_STATE_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_SSL_HOST_STATE_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_SSL_HOST_STATE_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_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 "base/threading/non_thread_safe.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // The SSLHostStateDelegate encapulates the host-specific state for SSL errors. | 16 // The SSLHostStateDelegate encapulates the host-specific state for SSL errors. |
17 // For example, SSLHostStateDelegate remembers whether the user has whitelisted | 17 // For example, SSLHostStateDelegate remembers whether the user has whitelisted |
18 // a particular broken cert for use with particular host. We separate this | 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 | 19 // state from the SSLManager because this state is shared across many navigation |
20 // controllers. | 20 // controllers. |
21 // | 21 // |
22 // SSLHostStateDelegate may be implemented by the embedder to provide a storage | 22 // SSLHostStateDelegate may be implemented by the embedder to provide a storage |
23 // strategy for certificate decisions or it may be left unimplemented to use a | 23 // strategy for certificate decisions or it may be left unimplemented to use a |
24 // default strategy of not remembering decisions at all. | 24 // default strategy of not remembering decisions at all. |
25 class SSLHostStateDelegate { | 25 class SSLHostStateDelegate { |
26 public: | 26 public: |
27 // Records that |cert| is not permitted to be used for |host| in the future, | 27 // The judgements that can be reached by a user for invalid certificates. |
28 // for a specified |error| type. | 28 enum CertJudgment { |
29 virtual void DenyCert(const std::string& host, | 29 // This certificate is denied. |
30 net::X509Certificate* cert, | 30 DENIED, |
31 net::CertStatus error) = 0; | 31 |
| 32 // This certificate is allowed. |
| 33 ALLOWED, |
| 34 }; |
32 | 35 |
33 // Records that |cert| is permitted to be used for |host| in the future, for | 36 // Records that |cert| is permitted to be used for |host| in the future, for |
34 // a specified |error| type. | 37 // a specified |error| type. |
35 virtual void AllowCert(const std::string&, | 38 virtual void AllowCert(const std::string&, |
36 net::X509Certificate* cert, | 39 net::X509Certificate* cert, |
37 net::CertStatus error) = 0; | 40 net::CertStatus error) = 0; |
38 | 41 |
39 // Clear all allow/deny preferences. | 42 // Clear all allow preferences. |
40 virtual void Clear() = 0; | 43 virtual void Clear() = 0; |
41 | 44 |
42 // Queries whether |cert| is allowed or denied for |host| and |error|. Returns | 45 // Queries whether |cert| is allowed for |host| and |error|. Returns true in |
43 // true in |expired_previous_decision| if a previous user decision expired | 46 // |expired_previous_decision| if a previous user decision expired immediately |
44 // immediately prior to this query, otherwise false. | 47 // prior to this query, otherwise false. Since the API does not currently |
45 virtual net::CertPolicy::Judgment QueryPolicy( | 48 // provide a way to deny certs, QueryPolicy guarantees to return either |
46 const std::string& host, | 49 // ALLOWED or UNKNOWN but never DENIED. |
47 net::X509Certificate* cert, | 50 virtual CertJudgment QueryPolicy(const std::string& host, |
48 net::CertStatus error, | 51 net::X509Certificate* cert, |
49 bool* expired_previous_decision) = 0; | 52 net::CertStatus error, |
| 53 bool* expired_previous_decision) = 0; |
50 | 54 |
51 // Records that a host has run insecure content. | 55 // Records that a host has run insecure content. |
52 virtual void HostRanInsecureContent(const std::string& host, int pid) = 0; | 56 virtual void HostRanInsecureContent(const std::string& host, int pid) = 0; |
53 | 57 |
54 // Returns whether the specified host ran insecure content. | 58 // Returns whether the specified host ran insecure content. |
55 virtual bool DidHostRunInsecureContent(const std::string& host, | 59 virtual bool DidHostRunInsecureContent(const std::string& host, |
56 int pid) const = 0; | 60 int pid) const = 0; |
57 | 61 |
58 protected: | 62 protected: |
59 virtual ~SSLHostStateDelegate() {} | 63 virtual ~SSLHostStateDelegate() {} |
60 }; | 64 }; |
61 | 65 |
62 } // namespace content | 66 } // namespace content |
63 | 67 |
64 #endif // CONTENT_PUBLIC_BROWSER_SSL_HOST_STATE_DELEGATE_H_ | 68 #endif // CONTENT_PUBLIC_BROWSER_SSL_HOST_STATE_DELEGATE_H_ |
OLD | NEW |