[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_SSL_SSL_POLICY_H_ |
6 | #define CONTENT_BROWSER_SSL_SSL_POLICY_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 11 | #include "webkit/common/resource_type.h" |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 12 | |
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 13 | namespace content { |
14 | class NavigationEntryImpl; | ||||
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 15 | class SSLCertErrorHandler; |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 16 | class SSLPolicyBackend; |
17 | class SSLRequestInfo; | ||||
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 18 | class WebContentsImpl; |
[email protected] | 10f417c5 | 2011-12-28 21:04:23 | [diff] [blame] | 19 | |
[email protected] | 425210cc | 2009-03-17 18:56:42 | [diff] [blame] | 20 | // SSLPolicy |
21 | // | ||||
22 | // This class is responsible for making the security decisions that concern the | ||||
[email protected] | 5edce1e | 2009-05-14 08:47:30 | [diff] [blame] | 23 | // SSL trust indicators. It relies on the SSLPolicyBackend to actually enact |
24 | // the decisions it reaches. | ||||
[email protected] | 425210cc | 2009-03-17 18:56:42 | [diff] [blame] | 25 | // |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 26 | class SSLPolicy { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | public: |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 28 | explicit SSLPolicy(SSLPolicyBackend* backend); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 30 | // An error occurred with the certificate in an SSL connection. |
31 | void OnCertError(SSLCertErrorHandler* handler); | ||||
32 | |||||
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 33 | void DidRunInsecureContent(NavigationEntryImpl* entry, |
[email protected] | 4b8d7493 | 2009-09-29 07:26:25 | [diff] [blame] | 34 | const std::string& security_origin); |
[email protected] | 09843b5f | 2009-09-26 08:30:59 | [diff] [blame] | 35 | |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 36 | // We have started a resource request with the given info. |
37 | void OnRequestStarted(SSLRequestInfo* info); | ||||
38 | |||||
39 | // Update the SSL information in |entry| to match the current state. | ||||
[email protected] | 770005b | 2012-04-16 15:58:13 | [diff] [blame] | 40 | // |web_contents| is the WebContentsImpl associated with this entry. |
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 41 | void UpdateEntry(NavigationEntryImpl* entry, |
42 | WebContentsImpl* web_contents); | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 43 | |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 44 | SSLPolicyBackend* backend() const { return backend_; } |
45 | |||||
[email protected] | 9281268 | 2009-03-18 01:07:07 | [diff] [blame] | 46 | private: |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 47 | // Callback that the user chose to accept or deny the certificate. |
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 48 | void OnAllowCertificate(scoped_refptr<SSLCertErrorHandler> handler, |
49 | bool allow); | ||||
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 50 | |
[email protected] | faf9cd6 | 2010-04-20 19:17:58 | [diff] [blame] | 51 | // Helper method for derived classes handling certificate errors. |
[email protected] | d9be4770 | 2012-05-16 03:41:22 | [diff] [blame] | 52 | // |
53 | // |overridable| indicates whether or not the user could (assuming perfect | ||||
54 | // knowledge) successfully override the error and still get the security | ||||
55 | // guarantees of TLS. |strict_enforcement| indicates whether or not the | ||||
56 | // site the user is trying to connect to has requested strict enforcement | ||||
57 | // of certificate validation (e.g. with HTTP Strict-Transport-Security). | ||||
58 | void OnCertErrorInternal(SSLCertErrorHandler* handler, | ||||
59 | bool overridable, | ||||
60 | bool strict_enforcement); | ||||
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 61 | |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 62 | // If the security style of |entry| has not been initialized, then initialize |
63 | // it with the default style for its URL. | ||||
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 64 | void InitializeEntryIfNeeded(NavigationEntryImpl* entry); |
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 65 | |
[email protected] | f17a0ee | 2010-05-17 17:38:47 | [diff] [blame] | 66 | // Mark |origin| as having run insecure content in the process with ID |pid|. |
67 | void OriginRanInsecureContent(const std::string& origin, int pid); | ||||
[email protected] | 5d06384 | 2009-05-15 04:08:24 | [diff] [blame] | 68 | |
69 | // The backend we use to enact our decisions. | ||||
70 | SSLPolicyBackend* backend_; | ||||
71 | |||||
[email protected] | 425210cc | 2009-03-17 18:56:42 | [diff] [blame] | 72 | DISALLOW_COPY_AND_ASSIGN(SSLPolicy); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 73 | }; |
74 | |||||
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 75 | } // namespace content |
76 | |||||
[email protected] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 77 | #endif // CONTENT_BROWSER_SSL_SSL_POLICY_H_ |