Index: chrome/browser/ssl/ssl_blocking_page.cc |
diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc |
index 056321f5ff30a131a9104fe067e91c6b62578e83..1c380a26bd0273f4f53d555dfe165d145fc37483 100644 |
--- a/chrome/browser/ssl/ssl_blocking_page.cc |
+++ b/chrome/browser/ssl/ssl_blocking_page.cc |
@@ -7,7 +7,9 @@ |
#include "base/i18n/rtl.h" |
#include "base/metrics/field_trial.h" |
#include "base/metrics/histogram.h" |
+#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_piece.h" |
+#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/values.h" |
#include "chrome/browser/history/history_service_factory.h" |
@@ -29,6 +31,7 @@ |
#include "grit/app_locale_settings.h" |
#include "grit/browser_resources.h" |
#include "grit/generated_resources.h" |
+#include "net/base/hash_value.h" |
#include "net/base/net_errors.h" |
#include "net/base/net_util.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -51,7 +54,8 @@ enum SSLBlockingPageCommands { |
CMD_DONT_PROCEED, |
CMD_PROCEED, |
CMD_FOCUS, |
- CMD_MORE |
+ CMD_MORE, |
+ CMD_RELOAD, |
}; |
// Events for UMA. |
@@ -198,51 +202,143 @@ SSLBlockingPage::~SSLBlockingPage() { |
} |
std::string SSLBlockingPage::GetHTMLContents() { |
- // Let's build the html error page. |
DictionaryValue strings; |
- SSLErrorInfo error_info = |
- SSLErrorInfo::CreateError(SSLErrorInfo::NetErrorToErrorType(cert_error_), |
- ssl_info_.cert.get(), |
- request_url_); |
- |
- int resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
- strings.SetString("headLine", error_info.title()); |
- strings.SetString("description", error_info.details()); |
- strings.SetString("moreInfoTitle", |
- l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); |
- SetExtraInfo(&strings, error_info.extra_information()); |
- |
- strings.SetString("exit", |
- l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT)); |
- |
+ int resource_id; |
if (overridable_ && !strict_enforcement_) { |
- strings.SetString("title", |
- l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); |
- strings.SetString("proceed", |
- l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED)); |
- strings.SetString("reasonForNotProceeding", |
- l10n_util::GetStringUTF16( |
- IDS_SSL_BLOCKING_PAGE_SHOULD_NOT_PROCEED)); |
+ // Let's build the overridable error page. |
+ SSLErrorInfo error_info = |
+ SSLErrorInfo::CreateError( |
+ SSLErrorInfo::NetErrorToErrorType(cert_error_), |
+ ssl_info_.cert.get(), |
+ request_url_); |
+ |
+ resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
+ strings.SetString("headLine", error_info.title()); |
+ strings.SetString("description", error_info.details()); |
+ strings.SetString("moreInfoTitle", |
+ l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); |
+ SetExtraInfo(&strings, error_info.extra_information()); |
+ |
+ strings.SetString( |
+ "exit", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_EXIT)); |
+ strings.SetString( |
+ "title", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_TITLE)); |
+ strings.SetString( |
+ "proceed", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_PROCEED)); |
+ strings.SetString( |
+ "reasonForNotProceeding", l10n_util::GetStringUTF16( |
+ IDS_SSL_OVERRIDABLE_PAGE_SHOULD_NOT_PROCEED)); |
strings.SetString("errorType", "overridable"); |
+ strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); |
} else { |
- strings.SetString("title", |
- l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE)); |
- if (strict_enforcement_) { |
- strings.SetString("reasonForNotProceeding", |
- l10n_util::GetStringUTF16( |
- IDS_SSL_ERROR_PAGE_CANNOT_PROCEED)); |
+ // Let's build the blocking error page. |
+ resource_id = IDR_SSL_BLOCKING_HTML; |
+ |
+ // Strings that are not dependent on the URL. |
+ strings.SetString( |
+ "title", l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); |
+ strings.SetString( |
+ "reloadMsg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); |
+ strings.SetString( |
+ "more", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_MORE)); |
+ strings.SetString( |
+ "less", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LESS)); |
+ strings.SetString( |
+ "moreTitle", |
+ l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_MORE_TITLE)); |
+ strings.SetString( |
+ "techTitle", |
+ l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TECH_TITLE)); |
+ |
+ // Strings that are dependent on the URL. |
+ string16 url(ASCIIToUTF16(request_url_.host())); |
+ bool rtl = base::i18n::IsRTL(); |
+ strings.SetString("textDirection", rtl ? "rtl" : "ltr"); |
+ if (rtl) |
+ base::i18n::WrapStringWithLTRFormatting(&url); |
+ strings.SetString( |
+ "headline", l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_HEADLINE, |
+ url.c_str())); |
+ strings.SetString( |
+ "message", l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_BODY_TEXT, |
+ url.c_str())); |
+ strings.SetString( |
+ "moreMessage", |
+ l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_MORE_TEXT, |
+ url.c_str())); |
+ strings.SetString("reloadUrl", request_url_.spec()); |
+ |
+ // Strings that are dependent on the error type. |
+ SSLErrorInfo::ErrorType type = |
+ SSLErrorInfo::NetErrorToErrorType(cert_error_); |
+ string16 errorType; |
+ if (type == SSLErrorInfo::CERT_REVOKED) { |
+ errorType = string16(ASCIIToUTF16("Key revocation")); |
+ strings.SetString( |
+ "failure", |
+ l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_REVOKED)); |
+ } else if (type == SSLErrorInfo::CERT_INVALID) { |
+ errorType = string16(ASCIIToUTF16("Malformed certificate")); |
+ strings.SetString( |
+ "failure", |
+ l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_FORMATTED)); |
+ } else if (type == SSLErrorInfo::CERT_PINNED_KEY_MISSING) { |
+ errorType = string16(ASCIIToUTF16("Certificate pinning failure")); |
+ strings.SetString( |
+ "failure", |
+ l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_PINNING, |
+ url.c_str())); |
+ } else if (type == SSLErrorInfo::CERT_WEAK_KEY_DH) { |
+ errorType = string16(ASCIIToUTF16("Weak DH public key")); |
+ strings.SetString( |
+ "failure", |
+ l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_WEAK_DH, |
+ url.c_str())); |
} else { |
- strings.SetString("reasonForNotProceeding", std::string()); |
+ // HSTS failure. |
+ errorType = string16(ASCIIToUTF16("HSTS failure")); |
+ strings.SetString( |
+ "failure", |
+ l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_HSTS, url.c_str())); |
+ } |
+ if (rtl) |
+ base::i18n::WrapStringWithLTRFormatting(&errorType); |
+ strings.SetString( |
+ "errorType", l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_ERROR, |
+ errorType.c_str())); |
+ |
+ // Strings that display the invalid cert. |
+ string16 subject(ASCIIToUTF16(ssl_info_.cert->subject().GetDisplayName())); |
+ string16 issuer(ASCIIToUTF16(ssl_info_.cert->issuer().GetDisplayName())); |
+ std::string hashes; |
+ for (std::vector<net::HashValue>::iterator it = |
+ ssl_info_.public_key_hashes.begin(); |
+ it != ssl_info_.public_key_hashes.end(); |
+ ++it) { |
+ base::StringAppendF(&hashes, "%s ", it->ToString().c_str()); |
} |
- strings.SetString("errorType", "notoverridable"); |
+ string16 fingerprint(ASCIIToUTF16(hashes)); |
+ if (rtl) { |
+ // These are always going to be LTR. |
+ base::i18n::WrapStringWithLTRFormatting(&subject); |
+ base::i18n::WrapStringWithLTRFormatting(&issuer); |
+ base::i18n::WrapStringWithLTRFormatting(&fingerprint); |
+ } |
+ strings.SetString( |
+ "subject", l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_SUBJECT, |
+ subject.c_str())); |
+ strings.SetString( |
+ "issuer", l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_ISSUER, |
+ issuer.c_str())); |
+ strings.SetString( |
+ "fingerprint", |
+ l10n_util::GetStringFUTF16(IDS_SSL_BLOCKING_PAGE_HASHES, |
+ fingerprint.c_str())); |
} |
- strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); |
- |
base::StringPiece html( |
ResourceBundle::GetSharedInstance().GetRawDataResource( |
resource_id)); |
- |
return webui::GetI18nTemplateHtml(html, &strings); |
} |
@@ -274,6 +370,10 @@ void SSLBlockingPage::CommandReceived(const std::string& command) { |
display_start_time_ = base::TimeTicks::Now(); |
} else if (cmd == CMD_MORE) { |
RecordSSLBlockingPageEventStats(MORE); |
+ } else if (cmd == CMD_RELOAD) { |
+ // The interstitial can't refresh itself. |
+ content::NavigationController* controller = &web_contents_->GetController(); |
+ controller->Reload(true); |
} |
} |