diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 04:08:24 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 04:08:24 +0000 |
commit | 5d063840bdb2c53dc013e2bad48d76cb43ac89a5 (patch) | |
tree | 9dcfc89734943ba273eee63ee2895740c7a3b3c5 /chrome/browser/ssl/ssl_policy.h | |
parent | fddf0d42dc3c82d8e8b7a780eb1483723d0915fc (diff) | |
download | chromium_src-5d063840bdb2c53dc013e2bad48d76cb43ac89a5.zip chromium_src-5d063840bdb2c53dc013e2bad48d76cb43ac89a5.tar.gz chromium_src-5d063840bdb2c53dc013e2bad48d76cb43ac89a5.tar.bz2 |
Finish refactoring to make SSLPolicy and friends unit testable. Next stop: tests!
TBR=jcampan
BUG=http://crbug.com/8782
Review URL: http://codereview.chromium.org/115389
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl/ssl_policy.h')
-rw-r--r-- | chrome/browser/ssl/ssl_policy.h | 72 |
1 files changed, 58 insertions, 14 deletions
diff --git a/chrome/browser/ssl/ssl_policy.h b/chrome/browser/ssl/ssl_policy.h index 117120d..48a5f0d 100644 --- a/chrome/browser/ssl/ssl_policy.h +++ b/chrome/browser/ssl/ssl_policy.h @@ -5,9 +5,17 @@ #ifndef CHROME_BROWSER_SSL_SSL_POLICY_H_ #define CHROME_BROWSER_SSL_SSL_POLICY_H_ -#include "base/singleton.h" +#include <string> + #include "chrome/browser/ssl/ssl_blocking_page.h" -#include "chrome/browser/ssl/ssl_manager.h" +#include "chrome/common/filter_policy.h" +#include "webkit/glue/resource_type.h" + +class NavigationEntry; +class SSLCertErrorHandler; +class SSLMixedContentHandler; +class SSLPolicyBackend; +class SSLRequestInfo; // SSLPolicy // @@ -15,17 +23,23 @@ // SSL trust indicators. It relies on the SSLPolicyBackend to actually enact // the decisions it reaches. // -class SSLPolicy : public SSLManager::Delegate, - public SSLBlockingPage::Delegate { +class SSLPolicy : public SSLBlockingPage::Delegate { public: - // Factory method to get the default policy. - static SSLPolicy* GetDefaultPolicy(); + explicit SSLPolicy(SSLPolicyBackend* backend); + + // An error occurred with the certificate in an SSL connection. + void OnCertError(SSLCertErrorHandler* handler); + + // A request for a mixed-content resource was made. Note that the resource + // request was not started yet and the delegate is responsible for starting + // it. + void OnMixedContent(SSLMixedContentHandler* handler); - // SSLManager::Delegate methods. - virtual void OnCertError(SSLCertErrorHandler* handler); - virtual void OnMixedContent(SSLMixedContentHandler* handler); - virtual void OnRequestStarted(SSLRequestInfo* info); - virtual void UpdateEntry(SSLPolicyBackend* backend, NavigationEntry* entry); + // We have started a resource request with the given info. + void OnRequestStarted(SSLRequestInfo* info); + + // Update the SSL information in |entry| to match the current state. + void UpdateEntry(NavigationEntry* entry); // This method is static because it is called from both the UI and the IO // threads. @@ -34,15 +48,15 @@ class SSLPolicy : public SSLManager::Delegate, FilterPolicy::Type filter_policy, const std::string& frame_origin); + SSLPolicyBackend* backend() const { return backend_; } + // SSLBlockingPage::Delegate methods. virtual SSLErrorInfo GetSSLErrorInfo(SSLCertErrorHandler* handler); virtual void OnDenyCertificate(SSLCertErrorHandler* handler); virtual void OnAllowCertificate(SSLCertErrorHandler* handler); private: - // Construct via |GetDefaultPolicy|. - SSLPolicy(); - friend struct DefaultSingletonTraits<SSLPolicy>; + class ShowMixedContentTask; // Helper method for derived classes handling certificate errors that can be // overridden by the user. @@ -53,6 +67,36 @@ class SSLPolicy : public SSLManager::Delegate, // Cancel the request and show an error page. void OnFatalCertError(SSLCertErrorHandler* handler); + // Show an error page for this certificate error. This error page does not + // give the user the opportunity to ingore the error. + void ShowErrorPage(SSLCertErrorHandler* handler); + + // Add a warning about mixed content to the JavaScript console. This warning + // helps web developers track down and eliminate mixed content on their site. + void AddMixedContentWarningToConsole(SSLMixedContentHandler* handler); + + // If the security style of |entry| has not been initialized, then initialize + // it with the default style for its URL. + void InitializeEntryIfNeeded(NavigationEntry* entry); + + // Mark |origin| as containing insecure content in the process with ID |pid|. + void MarkOriginAsBroken(const std::string& origin, int pid); + + // Allow |origin| to include mixed content. This stops us from showing an + // infobar warning after the user as approved mixed content. + void AllowMixedContentForOrigin(const std::string& origin); + + // Called after we've decided that |info| represents a request for mixed + // content. Updates our internal state to reflect that we've loaded |info|. + void UpdateStateForMixedContent(SSLRequestInfo* info); + + // Called after we've decided that |info| represents a request for unsafe + // content. Updates our internal state to reflect that we've loaded |info|. + void UpdateStateForUnsafeContent(SSLRequestInfo* info); + + // The backend we use to enact our decisions. + SSLPolicyBackend* backend_; + DISALLOW_COPY_AND_ASSIGN(SSLPolicy); }; |