summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ssl
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-03 20:43:23 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-03 20:43:23 +0000
commit266869fcc3ec4e68f7c6f2e7d2060f8f5bb6a9dd (patch)
tree1d19a09534c9876e5803851fd0a84835658137a4 /chrome/browser/ssl
parentef3e7220440a9810be9d5ed99a0a109ea044691b (diff)
downloadchromium_src-266869fcc3ec4e68f7c6f2e7d2060f8f5bb6a9dd.zip
chromium_src-266869fcc3ec4e68f7c6f2e7d2060f8f5bb6a9dd.tar.gz
chromium_src-266869fcc3ec4e68f7c6f2e7d2060f8f5bb6a9dd.tar.bz2
Add an SSLBlockingPage::ErrorLevel enum type to make the
code more readable than using an "overridable" bool argument. R=jcivelli BUG=41360 TEST=None. Covered by existing tests. Review URL: http://codereview.chromium.org/1862002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46271 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl')
-rw-r--r--chrome/browser/ssl/ssl_blocking_page.cc7
-rw-r--r--chrome/browser/ssl/ssl_blocking_page.h18
-rw-r--r--chrome/browser/ssl/ssl_policy.cc8
-rw-r--r--chrome/browser/ssl/ssl_policy.h11
4 files changed, 26 insertions, 18 deletions
diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc
index aa3df31..b6be8ed 100644
--- a/chrome/browser/ssl/ssl_blocking_page.cc
+++ b/chrome/browser/ssl/ssl_blocking_page.cc
@@ -46,12 +46,12 @@ void RecordSSLBlockingPageStats(SSLBlockingPageEvent event) {
// No error happening loading a sub-resource triggers an interstitial so far.
SSLBlockingPage::SSLBlockingPage(SSLCertErrorHandler* handler,
Delegate* delegate,
- bool overridable)
+ ErrorLevel error_level)
: InterstitialPage(handler->GetTabContents(), true, handler->request_url()),
handler_(handler),
delegate_(delegate),
delegate_has_been_notified_(false),
- overridable_(overridable) {
+ error_level_(error_level) {
RecordSSLBlockingPageStats(SHOW);
}
@@ -75,7 +75,7 @@ std::string SSLBlockingPage::GetHTMLContents() {
SetExtraInfo(&strings, error_info.extra_information());
int resource_id;
- if (overridable_) {
+ if (error_level_ == ERROR_OVERRIDABLE) {
resource_id = IDR_SSL_ROAD_BLOCK_HTML;
strings.SetString(L"title",
l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE));
@@ -84,6 +84,7 @@ std::string SSLBlockingPage::GetHTMLContents() {
strings.SetString(L"exit",
l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT));
} else {
+ DCHECK_EQ(error_level_, ERROR_FATAL);
resource_id = IDR_SSL_ERROR_HTML;
strings.SetString(L"title", l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE));
strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK));
diff --git a/chrome/browser/ssl/ssl_blocking_page.h b/chrome/browser/ssl/ssl_blocking_page.h
index dd282ad..2f85c07 100644
--- a/chrome/browser/ssl/ssl_blocking_page.h
+++ b/chrome/browser/ssl/ssl_blocking_page.h
@@ -33,8 +33,15 @@ class SSLBlockingPage : public InterstitialPage {
virtual void OnAllowCertificate(SSLCertErrorHandler* handler) = 0;
};
+ // The severity of the certificate error.
+ enum ErrorLevel {
+ ERROR_OVERRIDABLE, // The interstitial page has a "Proceed anyway" button.
+ ERROR_FATAL, // The interstitial page doesn't allow the user to
+ // proceed to the site.
+ };
+
SSLBlockingPage(SSLCertErrorHandler* handler, Delegate* delegate,
- bool overridable);
+ ErrorLevel error_level);
virtual ~SSLBlockingPage();
// A method that sets strings in the specified dictionary from the passed
@@ -53,8 +60,8 @@ class SSLBlockingPage : public InterstitialPage {
virtual void DontProceed();
private:
- void NotifyDenyCertificate();
- void NotifyAllowCertificate();
+ void NotifyDenyCertificate();
+ void NotifyAllowCertificate();
// The error we represent. We will either call CancelRequest() or
// ContinueRequest() on this object.
@@ -67,9 +74,8 @@ class SSLBlockingPage : public InterstitialPage {
// A flag to indicate if we've notified |delegate_| of the user's decision.
bool delegate_has_been_notified_;
- // Can the user override the certificate error?
- bool overridable_;
-
+ // Is the certificate error overridable or fatal?
+ ErrorLevel error_level_;
DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage);
};
diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc
index 7f3ad87..4f5f54a 100644
--- a/chrome/browser/ssl/ssl_policy.cc
+++ b/chrome/browser/ssl/ssl_policy.cc
@@ -60,7 +60,7 @@ void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) {
case net::ERR_CERT_DATE_INVALID:
case net::ERR_CERT_AUTHORITY_INVALID:
case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
- OnCertErrorInternal(handler, true);
+ OnCertErrorInternal(handler, SSLBlockingPage::ERROR_OVERRIDABLE);
break;
case net::ERR_CERT_NO_REVOCATION_MECHANISM:
// Ignore this error.
@@ -74,7 +74,7 @@ void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) {
case net::ERR_CERT_CONTAINS_ERRORS:
case net::ERR_CERT_REVOKED:
case net::ERR_CERT_INVALID:
- OnCertErrorInternal(handler, false);
+ OnCertErrorInternal(handler, SSLBlockingPage::ERROR_FATAL);
break;
default:
NOTREACHED();
@@ -185,7 +185,7 @@ void SSLPolicy::OnAllowCertificate(SSLCertErrorHandler* handler) {
// Certificate Error Routines
void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler,
- bool overridable) {
+ SSLBlockingPage::ErrorLevel error_level) {
if (handler->resource_type() != ResourceType::MAIN_FRAME) {
// A sub-resource has a certificate error. The user doesn't really
// have a context for making the right decision, so block the
@@ -195,7 +195,7 @@ void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler,
return;
}
SSLBlockingPage* blocking_page = new SSLBlockingPage(handler, this,
- overridable);
+ error_level);
blocking_page->Show();
}
diff --git a/chrome/browser/ssl/ssl_policy.h b/chrome/browser/ssl/ssl_policy.h
index bd30df5..adb574f 100644
--- a/chrome/browser/ssl/ssl_policy.h
+++ b/chrome/browser/ssl/ssl_policy.h
@@ -48,11 +48,12 @@ class SSLPolicy : public SSLBlockingPage::Delegate {
private:
// Helper method for derived classes handling certificate errors.
- // If the error can be overridden by the user, pass overriable=true, which
- // shows a blocking page and lets the user continue or cancel the request.
- // For fatal certificate errors, pass overridable=false, which show an error
- // page.
- void OnCertErrorInternal(SSLCertErrorHandler* handler, bool overridable);
+ // If the error can be overridden by the user, show a blocking page that
+ // lets the user continue or cancel the request.
+ // For fatal certificate errors, show a blocking page that only lets the
+ // user cancel the request.
+ void OnCertErrorInternal(SSLCertErrorHandler* handler,
+ SSLBlockingPage::ErrorLevel error_level);
// If the security style of |entry| has not been initialized, then initialize
// it with the default style for its URL.