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/build_time.h" | 7 #include "base/build_time.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 #if !defined(OS_CHROMEOS) | 310 #if !defined(OS_CHROMEOS) |
311 base::LaunchOptions options; | 311 base::LaunchOptions options; |
312 options.wait = false; | 312 options.wait = false; |
313 #if defined(OS_LINUX) | 313 #if defined(OS_LINUX) |
314 options.allow_new_privs = true; | 314 options.allow_new_privs = true; |
315 #endif | 315 #endif |
316 base::LaunchProcess(command, options, NULL); | 316 base::LaunchProcess(command, options, NULL); |
317 #endif | 317 #endif |
318 } | 318 } |
319 | 319 |
| 320 bool IsErrorDueToBadClock(const base::Time& now, int error) { |
| 321 if (SSLErrorInfo::NetErrorToErrorType(error) != |
| 322 SSLErrorInfo::CERT_DATE_INVALID) { |
| 323 return false; |
| 324 } |
| 325 return SSLErrorClassification::IsUserClockInThePast(now) || |
| 326 SSLErrorClassification::IsUserClockInTheFuture(now); |
| 327 } |
| 328 |
320 } // namespace | 329 } // namespace |
321 | 330 |
322 // Note that we always create a navigation entry with SSL errors. | 331 // Note that we always create a navigation entry with SSL errors. |
323 // No error happening loading a sub-resource triggers an interstitial so far. | 332 // No error happening loading a sub-resource triggers an interstitial so far. |
324 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, | 333 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
325 int cert_error, | 334 int cert_error, |
326 const net::SSLInfo& ssl_info, | 335 const net::SSLInfo& ssl_info, |
327 const GURL& request_url, | 336 const GURL& request_url, |
328 int options_mask, | 337 int options_mask, |
329 const base::Callback<void(bool)>& callback) | 338 const base::Callback<void(bool)>& callback) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 base::i18n::WrapStringWithLTRFormatting(&url); | 441 base::i18n::WrapStringWithLTRFormatting(&url); |
433 webui::SetFontAndTextDirection(&load_time_data); | 442 webui::SetFontAndTextDirection(&load_time_data); |
434 | 443 |
435 // Shared values for both the overridable and non-overridable versions. | 444 // Shared values for both the overridable and non-overridable versions. |
436 load_time_data.SetBoolean("ssl", true); | 445 load_time_data.SetBoolean("ssl", true); |
437 load_time_data.SetBoolean("overridable", overridable_); | 446 load_time_data.SetBoolean("overridable", overridable_); |
438 load_time_data.SetString( | 447 load_time_data.SetString( |
439 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 448 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
440 load_time_data.SetString( | 449 load_time_data.SetString( |
441 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 450 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
442 if ((SSLErrorClassification::IsUserClockInThePast( | 451 |
443 base::Time::NowFromSystemTime())) | 452 base::Time now = base::Time::NowFromSystemTime(); |
444 && (SSLErrorInfo::NetErrorToErrorType(cert_error_) == | 453 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); |
445 SSLErrorInfo::CERT_DATE_INVALID)) { | 454 if (bad_clock) { |
446 load_time_data.SetString("primaryParagraph", | 455 load_time_data.SetString("primaryParagraph", |
447 l10n_util::GetStringFUTF16( | 456 l10n_util::GetStringFUTF16( |
448 IDS_SSL_CLOCK_ERROR, | 457 IDS_SSL_CLOCK_ERROR, |
449 url, | 458 url, |
450 base::TimeFormatShortDate(base::Time::Now()))); | 459 base::TimeFormatShortDate(now))); |
451 } else { | 460 } else { |
452 load_time_data.SetString( | 461 load_time_data.SetString( |
453 "primaryParagraph", | 462 "primaryParagraph", |
454 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 463 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
455 } | 464 } |
| 465 |
456 load_time_data.SetString( | 466 load_time_data.SetString( |
457 "openDetails", | 467 "openDetails", |
458 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | 468 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); |
459 load_time_data.SetString( | 469 load_time_data.SetString( |
460 "closeDetails", | 470 "closeDetails", |
461 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | 471 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); |
462 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | 472 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); |
463 | 473 |
464 if (overridable_) { // Overridable. | 474 if (overridable_) { |
465 SSLErrorInfo error_info = | 475 SSLErrorInfo error_info = |
466 SSLErrorInfo::CreateError( | 476 SSLErrorInfo::CreateError( |
467 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 477 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
468 ssl_info_.cert.get(), | 478 ssl_info_.cert.get(), |
469 request_url_); | 479 request_url_); |
470 load_time_data.SetString( | 480 if (bad_clock) { |
471 "explanationParagraph", error_info.details()); | 481 load_time_data.SetString("explanationParagraph", |
| 482 l10n_util::GetStringFUTF16( |
| 483 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); |
| 484 } else { |
| 485 load_time_data.SetString("explanationParagraph", error_info.details()); |
| 486 } |
472 load_time_data.SetString( | 487 load_time_data.SetString( |
473 "primaryButtonText", | 488 "primaryButtonText", |
474 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 489 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
475 load_time_data.SetString( | 490 load_time_data.SetString( |
476 "finalParagraph", | 491 "finalParagraph", |
477 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url)); | 492 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
478 } else { // Non-overridable. | 493 url)); |
479 load_time_data.SetBoolean("overridable", false); | 494 } else { |
480 SSLErrorInfo::ErrorType type = | 495 SSLErrorInfo::ErrorType type = |
481 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 496 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
482 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | 497 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: |
483 IsWindowsVersionSP3OrLower()) { | 498 IsWindowsVersionSP3OrLower()) { |
484 load_time_data.SetString( | 499 load_time_data.SetString( |
485 "explanationParagraph", | 500 "explanationParagraph", |
486 l10n_util::GetStringFUTF16( | 501 l10n_util::GetStringFUTF16( |
487 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | 502 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); |
| 503 } else if (bad_clock) { |
| 504 load_time_data.SetString("explanationParagraph", |
| 505 l10n_util::GetStringFUTF16( |
| 506 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); |
488 } else { | 507 } else { |
489 load_time_data.SetString("explanationParagraph", | 508 load_time_data.SetString("explanationParagraph", |
490 l10n_util::GetStringFUTF16( | 509 l10n_util::GetStringFUTF16( |
491 IDS_SSL_NONOVERRIDABLE_MORE, url)); | 510 IDS_SSL_NONOVERRIDABLE_MORE, url)); |
492 } | 511 } |
493 load_time_data.SetString( | 512 load_time_data.SetString( |
494 "primaryButtonText", | 513 "primaryButtonText", |
495 l10n_util::GetStringUTF16(IDS_SSL_NONOVERRIDABLE_RELOAD_BUTTON)); | 514 l10n_util::GetStringUTF16(IDS_SSL_NONOVERRIDABLE_RELOAD_BUTTON)); |
496 // Customize the help link depending on the specific error type. | 515 // Customize the help link depending on the specific error type. |
497 // Only mark as HSTS if none of the more specific error types apply, and use | 516 // Only mark as HSTS if none of the more specific error types apply, and use |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 // sure we don't clear the captive portal flag, since the interstitial was | 715 // sure we don't clear the captive portal flag, since the interstitial was |
697 // potentially caused by the captive portal. | 716 // potentially caused by the captive portal. |
698 captive_portal_detected_ = captive_portal_detected_ || | 717 captive_portal_detected_ = captive_portal_detected_ || |
699 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 718 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
700 // Also keep track of non-HTTP portals and error cases. | 719 // Also keep track of non-HTTP portals and error cases. |
701 captive_portal_no_response_ = captive_portal_no_response_ || | 720 captive_portal_no_response_ = captive_portal_no_response_ || |
702 (results->result == captive_portal::RESULT_NO_RESPONSE); | 721 (results->result == captive_portal::RESULT_NO_RESPONSE); |
703 } | 722 } |
704 #endif | 723 #endif |
705 } | 724 } |
OLD | NEW |