OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/field_trial.h" |
8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/history/history_service_factory.h" | 16 #include "chrome/browser/history/history_service_factory.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/renderer_preferences_util.h" | 18 #include "chrome/browser/renderer_preferences_util.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 captive_portal_detection_enabled_, | 254 captive_portal_detection_enabled_, |
254 captive_portal_probe_completed_, | 255 captive_portal_probe_completed_, |
255 captive_portal_no_response_, | 256 captive_portal_no_response_, |
256 captive_portal_detected_); | 257 captive_portal_detected_); |
257 // The page is closed without the user having chosen what to do, default to | 258 // The page is closed without the user having chosen what to do, default to |
258 // deny. | 259 // deny. |
259 NotifyDenyCertificate(); | 260 NotifyDenyCertificate(); |
260 } | 261 } |
261 } | 262 } |
262 | 263 |
| 264 std::string SSLBlockingPage::GetHTMLContentsV2() { |
| 265 base::DictionaryValue strings; |
| 266 SSLErrorInfo error_info = |
| 267 SSLErrorInfo::CreateError( |
| 268 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
| 269 ssl_info_.cert.get(), |
| 270 request_url_); |
| 271 base::string16 url(ASCIIToUTF16(request_url_.host())); |
| 272 bool rtl = base::i18n::IsRTL(); |
| 273 strings.SetString("textDirection", rtl ? "rtl" : "ltr"); |
| 274 if (rtl) |
| 275 base::i18n::WrapStringWithLTRFormatting(&url); |
| 276 |
| 277 strings.SetString( |
| 278 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_TITLE)); |
| 279 strings.SetString( |
| 280 "heading", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_HEADING)); |
| 281 strings.SetString( |
| 282 "primaryParagraph", |
| 283 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PRIMARY_PARAGRAPH, |
| 284 url.c_str())); |
| 285 strings.SetString( |
| 286 "explanationParagraph", error_info.details()); |
| 287 strings.SetString( |
| 288 "safetyButtonText", |
| 289 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
| 290 strings.SetString( |
| 291 "openDetails", |
| 292 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_OPEN_DETAILS_BUTTON)); |
| 293 strings.SetString( |
| 294 "closeDetails", |
| 295 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_CLOSE_DETAILS_BUTTON)); |
| 296 strings.SetString( |
| 297 "proceedParagraph", |
| 298 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
| 299 url.c_str())); |
| 300 |
| 301 base::StringPiece html( |
| 302 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 303 IRD_SSL_OVERRIDABLE_V2_HTML)); |
| 304 return webui::GetI18nTemplateHtml(html, &strings); |
| 305 } |
| 306 |
263 std::string SSLBlockingPage::GetHTMLContents() { | 307 std::string SSLBlockingPage::GetHTMLContents() { |
264 base::DictionaryValue strings; | 308 base::DictionaryValue strings; |
265 int resource_id; | 309 int resource_id; |
266 if (overridable_ && !strict_enforcement_) { | 310 if (overridable_ && !strict_enforcement_) { |
| 311 // Check to see if the v2 version should be displayed instead. |
| 312 if (base::FieldTrialList::FindFullName("InterstitialsV2") == "ShowV2") |
| 313 return GetHTMLContentsV2(); |
| 314 |
267 // Let's build the overridable error page. | 315 // Let's build the overridable error page. |
268 SSLErrorInfo error_info = | 316 SSLErrorInfo error_info = |
269 SSLErrorInfo::CreateError( | 317 SSLErrorInfo::CreateError( |
270 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 318 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
271 ssl_info_.cert.get(), | 319 ssl_info_.cert.get(), |
272 request_url_); | 320 request_url_); |
273 | 321 |
274 resource_id = IDR_SSL_ROAD_BLOCK_HTML; | 322 resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
275 strings.SetString("headLine", error_info.title()); | 323 strings.SetString("headLine", error_info.title()); |
276 strings.SetString("description", error_info.details()); | 324 strings.SetString("description", error_info.details()); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 // sure we don't clear the captive portal flag, since the interstitial was | 584 // sure we don't clear the captive portal flag, since the interstitial was |
537 // potentially caused by the captive portal. | 585 // potentially caused by the captive portal. |
538 captive_portal_detected_ = captive_portal_detected_ || | 586 captive_portal_detected_ = captive_portal_detected_ || |
539 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 587 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
540 // Also keep track of non-HTTP portals and error cases. | 588 // Also keep track of non-HTTP portals and error cases. |
541 captive_portal_no_response_ = captive_portal_no_response_ || | 589 captive_portal_no_response_ = captive_portal_no_response_ || |
542 (results->result == captive_portal::RESULT_NO_RESPONSE); | 590 (results->result == captive_portal::RESULT_NO_RESPONSE); |
543 } | 591 } |
544 #endif | 592 #endif |
545 } | 593 } |
OLD | NEW |