Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ssl/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string16.h" | |
| 9 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "chrome/browser/dom_operation_notification_details.h" | 13 #include "chrome/browser/dom_operation_notification_details.h" |
| 13 #include "chrome/browser/ssl/ssl_error_info.h" | 14 #include "chrome/browser/ssl/ssl_error_info.h" |
| 14 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
| 15 #include "chrome/common/jstemplate_builder.h" | 16 #include "chrome/common/jstemplate_builder.h" |
| 16 #include "content/browser/cert_store.h" | 17 #include "content/browser/cert_store.h" |
| 17 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
| 18 #include "content/browser/ssl/ssl_cert_error_handler.h" | 19 #include "content/browser/ssl/ssl_cert_error_handler.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 DictionaryValue strings; | 72 DictionaryValue strings; |
| 72 SSLErrorInfo error_info = SSLErrorInfo::CreateError( | 73 SSLErrorInfo error_info = SSLErrorInfo::CreateError( |
| 73 SSLErrorInfo::NetErrorToErrorType(handler_->cert_error()), | 74 SSLErrorInfo::NetErrorToErrorType(handler_->cert_error()), |
| 74 handler_->ssl_info().cert, handler_->request_url()); | 75 handler_->ssl_info().cert, handler_->request_url()); |
| 75 | 76 |
| 76 strings.SetString("headLine", error_info.title()); | 77 strings.SetString("headLine", error_info.title()); |
| 77 strings.SetString("description", error_info.details()); | 78 strings.SetString("description", error_info.details()); |
| 78 | 79 |
| 79 strings.SetString("moreInfoTitle", | 80 strings.SetString("moreInfoTitle", |
| 80 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); | 81 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); |
| 81 SetExtraInfo(&strings, error_info.extra_information()); | |
| 82 | 82 |
| 83 int resource_id; | 83 int resource_id; |
| 84 if (overridable_) { | 84 if (overridable_) { |
| 85 resource_id = IDR_SSL_ROAD_BLOCK_HTML; | 85 resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
| 86 strings.SetString("title", | 86 strings.SetString("title", |
| 87 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); | 87 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); |
| 88 strings.SetString("proceed", | 88 strings.SetString("proceed", |
| 89 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED)); | 89 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED)); |
| 90 strings.SetString("exit", | 90 strings.SetString("exit", |
| 91 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT)); | 91 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT)); |
| 92 | |
| 93 // error_info.extra_information() returns const ref, but we need to add | |
| 94 // something. So, add to a copy. | |
| 95 std::vector<string16> extra_info = error_info.extra_information(); | |
| 96 extra_info.push_back( | |
| 97 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_SHOULD_NOT_PROCEED)); | |
|
wtc
2011/12/08 00:35:37
Many of the certificate error messages have some s
Ryan Sleevi
2011/12/08 00:45:11
Should this logic be pushed into SSLErrorInfo::Cre
| |
| 98 SetExtraInfo(&strings, extra_info); | |
| 92 } else { | 99 } else { |
| 93 resource_id = IDR_SSL_ERROR_HTML; | 100 resource_id = IDR_SSL_ERROR_HTML; |
| 94 strings.SetString("title", | 101 strings.SetString("title", |
| 95 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE)); | 102 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE)); |
| 96 strings.SetString("back", | 103 strings.SetString("back", |
| 97 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_BACK)); | 104 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_BACK)); |
| 105 SetExtraInfo(&strings, error_info.extra_information()); | |
| 98 } | 106 } |
| 99 | 107 |
| 100 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); | 108 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); |
| 101 | 109 |
| 102 base::StringPiece html( | 110 base::StringPiece html( |
| 103 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); | 111 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); |
| 104 | 112 |
| 105 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); | 113 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); |
| 106 } | 114 } |
| 107 | 115 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 DCHECK(!callback_.is_null()); | 169 DCHECK(!callback_.is_null()); |
| 162 | 170 |
| 163 callback_.Run(handler_, true); | 171 callback_.Run(handler_, true); |
| 164 callback_.Reset(); | 172 callback_.Reset(); |
| 165 } | 173 } |
| 166 | 174 |
| 167 // static | 175 // static |
| 168 void SSLBlockingPage::SetExtraInfo( | 176 void SSLBlockingPage::SetExtraInfo( |
| 169 DictionaryValue* strings, | 177 DictionaryValue* strings, |
| 170 const std::vector<string16>& extra_info) { | 178 const std::vector<string16>& extra_info) { |
| 171 DCHECK(extra_info.size() < 5); // We allow 5 paragraphs max. | 179 DCHECK_LT(extra_info.size(), 5U); // We allow 5 paragraphs max. |
| 172 const char* keys[5] = { | 180 const char* keys[5] = { |
| 173 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" | 181 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" |
| 174 }; | 182 }; |
| 175 int i; | 183 int i; |
| 176 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { | 184 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { |
| 177 strings->SetString(keys[i], extra_info[i]); | 185 strings->SetString(keys[i], extra_info[i]); |
| 178 } | 186 } |
| 179 for (; i < 5; i++) { | 187 for (; i < 5; i++) { |
| 180 strings->SetString(keys[i], ""); | 188 strings->SetString(keys[i], ""); |
| 181 } | 189 } |
| 182 } | 190 } |
| OLD | NEW |