| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_SSL_POLICY_H__ | 5 #ifndef CHROME_BROWSER_SSL_POLICY_H_ |
| 6 #define CHROME_BROWSER_SSL_POLICY_H__ | 6 #define CHROME_BROWSER_SSL_POLICY_H_ |
| 7 | 7 |
| 8 #include "base/singleton.h" |
| 8 #include "chrome/browser/ssl/ssl_blocking_page.h" | 9 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 9 #include "chrome/browser/ssl/ssl_manager.h" | 10 #include "chrome/browser/ssl/ssl_manager.h" |
| 10 | 11 |
| 11 // The basic SSLPolicy. This class contains default implementations of all | 12 // SSLPolicy |
| 12 // the SSLPolicy entry points. It is expected that subclasses will override | 13 // |
| 13 // most of these methods to implement policy specific to certain errors or | 14 // This class is responsible for making the security decisions that concern the |
| 14 // situations. | 15 // SSL trust indicators. It relies on the SSLManager to actually enact the |
| 16 // decisions it reaches. |
| 17 // |
| 15 class SSLPolicy : public SSLManager::Delegate, | 18 class SSLPolicy : public SSLManager::Delegate, |
| 16 public SSLBlockingPage::Delegate { | 19 public SSLBlockingPage::Delegate { |
| 17 public: | 20 public: |
| 18 // Factory method to get the default policy. | 21 // Factory method to get the default policy. |
| 19 // | |
| 20 // SSLPolicy is not meant to be instantiated itself. Only subclasses should | |
| 21 // be instantiated. The default policy has more complex behavior than a | |
| 22 // direct instance of SSLPolicy. | |
| 23 static SSLPolicy* GetDefaultPolicy(); | 22 static SSLPolicy* GetDefaultPolicy(); |
| 24 | 23 |
| 25 // SSLManager::Delegate methods. | 24 // SSLManager::Delegate methods. |
| 26 virtual void OnCertError(const GURL& main_frame_url, | 25 virtual void OnCertError(const GURL& main_frame_url, |
| 27 SSLManager::CertError* error); | 26 SSLManager::CertError* error); |
| 28 virtual void OnMixedContent( | 27 virtual void OnMixedContent( |
| 29 NavigationController* navigation_controller, | 28 NavigationController* navigation_controller, |
| 30 const GURL& main_frame_url, | 29 const GURL& main_frame_url, |
| 31 SSLManager::MixedContentHandler* mixed_content_handler) { | 30 SSLManager::MixedContentHandler* mixed_content_handler); |
| 32 // So far only the default policy is expected to receive mixed-content | |
| 33 // calls. | |
| 34 NOTREACHED(); | |
| 35 } | |
| 36 | |
| 37 virtual void OnRequestStarted(SSLManager* manager, | 31 virtual void OnRequestStarted(SSLManager* manager, |
| 38 const GURL& url, | 32 const GURL& url, |
| 39 ResourceType::Type resource_type, | 33 ResourceType::Type resource_type, |
| 40 int ssl_cert_id, | 34 int ssl_cert_id, |
| 41 int ssl_cert_status); | 35 int ssl_cert_status); |
| 42 virtual SecurityStyle GetDefaultStyle(const GURL& url); | 36 virtual SecurityStyle GetDefaultStyle(const GURL& url); |
| 43 | 37 |
| 44 // This method is static because it is called from both the UI and the IO | 38 // This method is static because it is called from both the UI and the IO |
| 45 // threads. | 39 // threads. |
| 46 static bool IsMixedContent(const GURL& url, | 40 static bool IsMixedContent(const GURL& url, |
| 47 ResourceType::Type resource_type, | 41 ResourceType::Type resource_type, |
| 48 const std::string& main_frame_origin); | 42 const std::string& main_frame_origin); |
| 49 | 43 |
| 50 // SSLBlockingPage::Delegate methods. | 44 // SSLBlockingPage::Delegate methods. |
| 51 virtual SSLErrorInfo GetSSLErrorInfo(SSLManager::CertError* error); | 45 virtual SSLErrorInfo GetSSLErrorInfo(SSLManager::CertError* error); |
| 52 virtual void OnDenyCertificate(SSLManager::CertError* error); | 46 virtual void OnDenyCertificate(SSLManager::CertError* error); |
| 53 virtual void OnAllowCertificate(SSLManager::CertError* error); | 47 virtual void OnAllowCertificate(SSLManager::CertError* error); |
| 54 | 48 |
| 55 protected: | 49 protected: |
| 56 // Allow our subclasses to construct us. | 50 // Construct via |GetDefaultPolicy|. |
| 57 SSLPolicy(); | 51 SSLPolicy(); |
| 52 friend struct DefaultSingletonTraits<SSLPolicy>; |
| 58 | 53 |
| 59 // Helper method for derived classes handling certificate errors that can be | 54 // Helper method for derived classes handling certificate errors that can be |
| 60 // overridden by the user. | 55 // overridden by the user. |
| 61 // Show a blocking page and let the user continue or cancel the request. | 56 // Show a blocking page and let the user continue or cancel the request. |
| 62 void OnOverridableCertError(const GURL& main_frame_url, | 57 void OnOverridableCertError(const GURL& main_frame_url, |
| 63 SSLManager::CertError* error); | 58 SSLManager::CertError* error); |
| 64 | 59 |
| 65 // Helper method for derived classes handling fatal certificate errors. | 60 // Helper method for derived classes handling fatal certificate errors. |
| 66 // Cancel the request and show an error page. | 61 // Cancel the request and show an error page. |
| 67 void OnFatalCertError(const GURL& main_frame_url, | 62 void OnFatalCertError(const GURL& main_frame_url, |
| 68 SSLManager::CertError* error); | 63 SSLManager::CertError* error); |
| 69 | 64 |
| 70 private: | 65 private: |
| 71 DISALLOW_EVIL_CONSTRUCTORS(SSLPolicy); | 66 DISALLOW_COPY_AND_ASSIGN(SSLPolicy); |
| 72 }; | 67 }; |
| 73 | 68 |
| 74 #endif // CHROME_BROWSER_SSL_POLICY_H__ | 69 #endif // CHROME_BROWSER_SSL_POLICY_H_ |
| OLD | NEW |