| 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_POLICY_H_ | 5 #ifndef CONTENT_BROWSER_SSL_SSL_POLICY_H_ |
| 6 #define CONTENT_BROWSER_SSL_SSL_POLICY_H_ | 6 #define CONTENT_BROWSER_SSL_SSL_POLICY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "content/public/browser/certificate_request_result_type.h" | 12 #include "content/public/browser/certificate_request_result_type.h" |
| 13 #include "content/public/common/resource_type.h" | 13 #include "content/public/common/resource_type.h" |
| 14 #include "content/public/common/security_style.h" | 14 #include "content/public/common/security_style.h" |
| 15 #include "net/cert/cert_status_flags.h" | 15 #include "net/cert/cert_status_flags.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class NavigationEntryImpl; | 20 class NavigationEntryImpl; |
| 21 class SSLCertErrorHandler; | 21 class SSLErrorHandler; |
| 22 class SSLPolicyBackend; | 22 class SSLPolicyBackend; |
| 23 class WebContents; | 23 class WebContents; |
| 24 | 24 |
| 25 // SSLPolicy | 25 // SSLPolicy |
| 26 // | 26 // |
| 27 // This class is responsible for making the security decisions that concern the | 27 // This class is responsible for making the security decisions that concern the |
| 28 // SSL trust indicators. It relies on the SSLPolicyBackend to actually enact | 28 // SSL trust indicators. It relies on the SSLPolicyBackend to actually enact |
| 29 // the decisions it reaches. | 29 // the decisions it reaches. |
| 30 // | 30 // |
| 31 class SSLPolicy { | 31 class SSLPolicy { |
| 32 public: | 32 public: |
| 33 explicit SSLPolicy(SSLPolicyBackend* backend); | 33 explicit SSLPolicy(SSLPolicyBackend* backend); |
| 34 | 34 |
| 35 // An error occurred with the certificate in an SSL connection. | 35 // An error occurred with the certificate in an SSL connection. |
| 36 void OnCertError(SSLCertErrorHandler* handler); | 36 void OnCertError(SSLErrorHandler* handler); |
| 37 | 37 |
| 38 void DidRunInsecureContent(NavigationEntryImpl* entry, | 38 void DidRunInsecureContent(NavigationEntryImpl* entry, |
| 39 const GURL& security_origin); | 39 const GURL& security_origin); |
| 40 | 40 |
| 41 // We have started a resource request for |url| with the given |cert_id| and | 41 // We have started a resource request for |url| with the given |cert_id| and |
| 42 // |cert_status|. | 42 // |cert_status|. |
| 43 void OnRequestStarted(const GURL& url, | 43 void OnRequestStarted(const GURL& url, |
| 44 int cert_id, | 44 int cert_id, |
| 45 net::CertStatus cert_status); | 45 net::CertStatus cert_status); |
| 46 | 46 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 net::CertStatus cert_status); | 58 net::CertStatus cert_status); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 enum OnCertErrorInternalOptionsMask { | 61 enum OnCertErrorInternalOptionsMask { |
| 62 OVERRIDABLE = 1 << 0, | 62 OVERRIDABLE = 1 << 0, |
| 63 STRICT_ENFORCEMENT = 1 << 1, | 63 STRICT_ENFORCEMENT = 1 << 1, |
| 64 EXPIRED_PREVIOUS_DECISION = 1 << 2 | 64 EXPIRED_PREVIOUS_DECISION = 1 << 2 |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 // Callback that the user chose to accept or deny the certificate. | 67 // Callback that the user chose to accept or deny the certificate. |
| 68 void OnAllowCertificate(scoped_refptr<SSLCertErrorHandler> handler, | 68 void OnAllowCertificate(scoped_refptr<SSLErrorHandler> handler, |
| 69 CertificateRequestResultType decision); | 69 CertificateRequestResultType decision); |
| 70 | 70 |
| 71 // Helper method for derived classes handling certificate errors. | 71 // Helper method for derived classes handling certificate errors. |
| 72 // | 72 // |
| 73 // Options should be a bitmask combination of OnCertErrorInternalOptionsMask. | 73 // Options should be a bitmask combination of OnCertErrorInternalOptionsMask. |
| 74 // OVERRIDABLE indicates whether or not the user could (assuming perfect | 74 // OVERRIDABLE indicates whether or not the user could (assuming perfect |
| 75 // knowledge) successfully override the error and still get the security | 75 // knowledge) successfully override the error and still get the security |
| 76 // guarantees of TLS. STRICT_ENFORCEMENT indicates whether or not the site the | 76 // guarantees of TLS. STRICT_ENFORCEMENT indicates whether or not the site the |
| 77 // user is trying to connect to has requested strict enforcement of | 77 // user is trying to connect to has requested strict enforcement of |
| 78 // certificate validation (e.g. with HTTP Strict-Transport-Security). | 78 // certificate validation (e.g. with HTTP Strict-Transport-Security). |
| 79 // EXPIRED_PREVIOUS_DECISION indicates whether a user decision had been | 79 // EXPIRED_PREVIOUS_DECISION indicates whether a user decision had been |
| 80 // previously made but the decision has expired. | 80 // previously made but the decision has expired. |
| 81 void OnCertErrorInternal(SSLCertErrorHandler* handler, int options_mask); | 81 void OnCertErrorInternal(SSLErrorHandler* handler, int options_mask); |
| 82 | 82 |
| 83 // If the security style of |entry| has not been initialized, then initialize | 83 // If the security style of |entry| has not been initialized, then initialize |
| 84 // it with the default style for its URL. | 84 // it with the default style for its URL. |
| 85 void InitializeEntryIfNeeded(NavigationEntryImpl* entry); | 85 void InitializeEntryIfNeeded(NavigationEntryImpl* entry); |
| 86 | 86 |
| 87 // The backend we use to enact our decisions. | 87 // The backend we use to enact our decisions. |
| 88 SSLPolicyBackend* backend_; | 88 SSLPolicyBackend* backend_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(SSLPolicy); | 90 DISALLOW_COPY_AND_ASSIGN(SSLPolicy); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace content | 93 } // namespace content |
| 94 | 94 |
| 95 #endif // CONTENT_BROWSER_SSL_SSL_POLICY_H_ | 95 #endif // CONTENT_BROWSER_SSL_SSL_POLICY_H_ |
| OLD | NEW |