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 12 matching lines...) Expand all Loading... |
30 #include "content/public/common/ssl_status.h" | 31 #include "content/public/common/ssl_status.h" |
31 #include "grit/app_locale_settings.h" | 32 #include "grit/app_locale_settings.h" |
32 #include "grit/browser_resources.h" | 33 #include "grit/browser_resources.h" |
33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
34 #include "net/base/hash_value.h" | 35 #include "net/base/hash_value.h" |
35 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
36 #include "net/base/net_util.h" | 37 #include "net/base/net_util.h" |
37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
39 #include "ui/base/webui/jstemplate_builder.h" | 40 #include "ui/base/webui/jstemplate_builder.h" |
| 41 #include "ui/base/webui/web_ui_util.h" |
40 | 42 |
41 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 43 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
42 #include "chrome/browser/captive_portal/captive_portal_service.h" | 44 #include "chrome/browser/captive_portal/captive_portal_service.h" |
43 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 45 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
44 #endif | 46 #endif |
45 | 47 |
46 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
47 #include "base/win/windows_version.h" | 49 #include "base/win/windows_version.h" |
48 #endif | 50 #endif |
49 | 51 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 captive_portal_detection_enabled_, | 255 captive_portal_detection_enabled_, |
254 captive_portal_probe_completed_, | 256 captive_portal_probe_completed_, |
255 captive_portal_no_response_, | 257 captive_portal_no_response_, |
256 captive_portal_detected_); | 258 captive_portal_detected_); |
257 // The page is closed without the user having chosen what to do, default to | 259 // The page is closed without the user having chosen what to do, default to |
258 // deny. | 260 // deny. |
259 NotifyDenyCertificate(); | 261 NotifyDenyCertificate(); |
260 } | 262 } |
261 } | 263 } |
262 | 264 |
| 265 std::string SSLBlockingPage::GetHTMLContentsV2() { |
| 266 base::DictionaryValue strings; |
| 267 SSLErrorInfo error_info = |
| 268 SSLErrorInfo::CreateError( |
| 269 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
| 270 ssl_info_.cert.get(), |
| 271 request_url_); |
| 272 base::string16 url(ASCIIToUTF16(request_url_.host())); |
| 273 bool rtl = base::i18n::IsRTL(); |
| 274 strings.SetString("textDirection", rtl ? "rtl" : "ltr"); |
| 275 if (rtl) |
| 276 base::i18n::WrapStringWithLTRFormatting(&url); |
| 277 webui::SetFontAndTextDirection(&strings); |
| 278 |
| 279 strings.SetString( |
| 280 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_TITLE)); |
| 281 strings.SetString( |
| 282 "heading", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_HEADING)); |
| 283 strings.SetString( |
| 284 "primaryParagraph", |
| 285 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PRIMARY_PARAGRAPH, |
| 286 url.c_str())); |
| 287 strings.SetString( |
| 288 "explanationParagraph", error_info.details()); |
| 289 strings.SetString( |
| 290 "safetyButtonText", |
| 291 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
| 292 strings.SetString( |
| 293 "openDetails", |
| 294 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_OPEN_DETAILS_BUTTON)); |
| 295 strings.SetString( |
| 296 "closeDetails", |
| 297 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_CLOSE_DETAILS_BUTTON)); |
| 298 strings.SetString( |
| 299 "proceedParagraph", |
| 300 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
| 301 url.c_str())); |
| 302 |
| 303 base::StringPiece html( |
| 304 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 305 IRD_SSL_OVERRIDABLE_V2_HTML)); |
| 306 webui::UseVersion2 version; |
| 307 return webui::GetI18nTemplateHtml(html, &strings); |
| 308 } |
| 309 |
263 std::string SSLBlockingPage::GetHTMLContents() { | 310 std::string SSLBlockingPage::GetHTMLContents() { |
264 base::DictionaryValue strings; | 311 base::DictionaryValue strings; |
265 int resource_id; | 312 int resource_id; |
266 if (overridable_ && !strict_enforcement_) { | 313 if (overridable_ && !strict_enforcement_) { |
| 314 // Check to see if the v2 version should be displayed instead. |
| 315 if (base::FieldTrialList::FindFullName("InterstitialsV2") == "ShowV2") |
| 316 return GetHTMLContentsV2(); |
| 317 |
267 // Let's build the overridable error page. | 318 // Let's build the overridable error page. |
268 SSLErrorInfo error_info = | 319 SSLErrorInfo error_info = |
269 SSLErrorInfo::CreateError( | 320 SSLErrorInfo::CreateError( |
270 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 321 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
271 ssl_info_.cert.get(), | 322 ssl_info_.cert.get(), |
272 request_url_); | 323 request_url_); |
273 | 324 |
274 resource_id = IDR_SSL_ROAD_BLOCK_HTML; | 325 resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
275 strings.SetString("headLine", error_info.title()); | 326 strings.SetString("headLine", error_info.title()); |
276 strings.SetString("description", error_info.details()); | 327 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 | 587 // sure we don't clear the captive portal flag, since the interstitial was |
537 // potentially caused by the captive portal. | 588 // potentially caused by the captive portal. |
538 captive_portal_detected_ = captive_portal_detected_ || | 589 captive_portal_detected_ = captive_portal_detected_ || |
539 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 590 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
540 // Also keep track of non-HTTP portals and error cases. | 591 // Also keep track of non-HTTP portals and error cases. |
541 captive_portal_no_response_ = captive_portal_no_response_ || | 592 captive_portal_no_response_ = captive_portal_no_response_ || |
542 (results->result == captive_portal::RESULT_NO_RESPONSE); | 593 (results->result == captive_portal::RESULT_NO_RESPONSE); |
543 } | 594 } |
544 #endif | 595 #endif |
545 } | 596 } |
OLD | NEW |