Chromium Code Reviews| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 "'com.android.settings/.Settings$DateTimeSettingsActivity'"); | 233 "'com.android.settings/.Settings$DateTimeSettingsActivity'"); |
| 234 #elif defined(OS_IOS) | 234 #elif defined(OS_IOS) |
| 235 // iOS does not have a way to launch the date and time settings. | 235 // iOS does not have a way to launch the date and time settings. |
| 236 return; | 236 return; |
| 237 #elif defined(OS_LINUX) | 237 #elif defined(OS_LINUX) |
| 238 struct ClockCommand { | 238 struct ClockCommand { |
| 239 const char* pathname; | 239 const char* pathname; |
| 240 const char* argument; | 240 const char* argument; |
| 241 }; | 241 }; |
| 242 static const ClockCommand kClockCommands[] = { | 242 static const ClockCommand kClockCommands[] = { |
| 243 // Unity | |
| 244 { "/usr/bin/unity-control-center", "datetime" }, | |
| 243 // GNOME | 245 // GNOME |
| 244 // | 246 // |
| 245 // NOTE: On old Ubuntu, naming control panels doesn't work, so it | 247 // NOTE: On old Ubuntu, naming control panels doesn't work, so it |
| 246 // opens the overview. This will have to be good enough. | 248 // opens the overview. This will have to be good enough. |
| 247 { "/usr/bin/gnome-control-center", "datetime" }, | 249 { "/usr/bin/gnome-control-center", "datetime" }, |
| 248 { "/usr/local/bin/gnome-control-center", "datetime" }, | 250 { "/usr/local/bin/gnome-control-center", "datetime" }, |
| 249 { "/opt/bin/gnome-control-center", "datetime" }, | 251 { "/opt/bin/gnome-control-center", "datetime" }, |
| 250 // KDE | 252 // KDE |
| 251 { "/usr/bin/kcmshell4", "clock" }, | 253 { "/usr/bin/kcmshell4", "clock" }, |
| 252 { "/usr/local/bin/kcmshell4", "clock" }, | 254 { "/usr/local/bin/kcmshell4", "clock" }, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 interstitial_page_->Show(); | 413 interstitial_page_->Show(); |
| 412 } | 414 } |
| 413 | 415 |
| 414 std::string SSLBlockingPage::GetHTMLContents() { | 416 std::string SSLBlockingPage::GetHTMLContents() { |
| 415 base::DictionaryValue load_time_data; | 417 base::DictionaryValue load_time_data; |
| 416 base::string16 url(ASCIIToUTF16(request_url_.host())); | 418 base::string16 url(ASCIIToUTF16(request_url_.host())); |
| 417 if (base::i18n::IsRTL()) | 419 if (base::i18n::IsRTL()) |
| 418 base::i18n::WrapStringWithLTRFormatting(&url); | 420 base::i18n::WrapStringWithLTRFormatting(&url); |
| 419 webui::SetFontAndTextDirection(&load_time_data); | 421 webui::SetFontAndTextDirection(&load_time_data); |
| 420 | 422 |
| 421 // Shared values for both the overridable and non-overridable versions. | |
| 422 load_time_data.SetString("type", "SSL"); | 423 load_time_data.SetString("type", "SSL"); |
| 423 load_time_data.SetBoolean("overridable", overridable_); | |
| 424 load_time_data.SetString( | |
| 425 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | |
| 426 load_time_data.SetString( | |
| 427 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | |
| 428 | 424 |
| 429 base::Time now = base::Time::NowFromSystemTime(); | 425 base::Time now = base::Time::NowFromSystemTime(); |
| 430 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); | 426 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); |
| 427 | |
| 428 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | |
| 429 | |
| 431 if (bad_clock) { | 430 if (bad_clock) { |
| 431 load_time_data.SetBoolean("bad_clock", true); | |
| 432 load_time_data.SetBoolean("overridable", false); | |
| 433 | |
| 434 base::string16 headingString; | |
| 435 if (SSLErrorClassification::IsUserClockInTheFuture(now)) { | |
| 436 headingString = l10n_util::GetStringUTF16( | |
| 437 IDS_SSL_V2_CLOCK_AHEAD_HEADING); | |
| 438 } else { | |
| 439 headingString = l10n_util::GetStringUTF16( | |
| 440 IDS_SSL_V2_CLOCK_BEHIND_HEADING); | |
| 441 } | |
| 442 | |
| 443 load_time_data.SetString("tabTitle", | |
| 444 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_TITLE)); | |
| 445 load_time_data.SetString("heading", headingString); | |
| 432 load_time_data.SetString("primaryParagraph", | 446 load_time_data.SetString("primaryParagraph", |
| 433 l10n_util::GetStringFUTF16( | 447 l10n_util::GetStringFUTF16( |
| 434 IDS_SSL_CLOCK_ERROR, | 448 IDS_SSL_V2_CLOCK_PRIMARY_PARAGRAPH , |
| 435 url, | 449 url, |
| 436 base::TimeFormatShortDate(now))); | 450 base::TimeFormatFriendlyDateAndTime(now))); |
| 451 | |
| 452 load_time_data.SetString( | |
| 453 "primaryButtonText", | |
| 454 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_UPDATE_DATE_AND_TIME)); | |
| 455 load_time_data.SetString( | |
| 456 "openDetails", | |
| 457 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_RELOAD)); | |
| 458 | |
| 459 // The interstitial template expects these strings, | |
| 460 // but we're not using them. So we send blank strings for now. | |
| 461 load_time_data.SetString("explanationParagraph", ""); | |
| 462 load_time_data.SetString("finalParagraph", ""); | |
| 437 } else { | 463 } else { |
| 464 load_time_data.SetBoolean("bad_clock", false); | |
| 465 | |
| 466 load_time_data.SetString( | |
| 467 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | |
| 468 load_time_data.SetString( | |
| 469 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | |
| 438 load_time_data.SetString( | 470 load_time_data.SetString( |
| 439 "primaryParagraph", | 471 "primaryParagraph", |
| 440 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 472 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
| 441 } | 473 load_time_data.SetString( |
| 474 "openDetails", | |
| 475 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | |
| 476 load_time_data.SetString( | |
| 477 "closeDetails", | |
| 478 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | |
| 442 | 479 |
| 443 load_time_data.SetString( | 480 if (overridable_) { |
| 444 "openDetails", | 481 load_time_data.SetBoolean("overridable", true); |
| 445 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | |
| 446 load_time_data.SetString( | |
| 447 "closeDetails", | |
| 448 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | |
| 449 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | |
| 450 | 482 |
| 451 if (overridable_) { | 483 SSLErrorInfo error_info = |
| 452 SSLErrorInfo error_info = | 484 SSLErrorInfo::CreateError( |
| 453 SSLErrorInfo::CreateError( | 485 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
| 454 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 486 ssl_info_.cert.get(), |
| 455 ssl_info_.cert.get(), | 487 request_url_); |
| 456 request_url_); | 488 load_time_data.SetString("explanationParagraph", error_info.details()); |
| 457 if (bad_clock) { | 489 load_time_data.SetString( |
| 458 load_time_data.SetString("explanationParagraph", | 490 "primaryButtonText", |
| 459 l10n_util::GetStringFUTF16( | 491 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
| 460 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); | 492 load_time_data.SetString( |
| 493 "finalParagraph", | |
| 494 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | |
| 495 url)); | |
| 461 } else { | 496 } else { |
| 462 load_time_data.SetString("explanationParagraph", error_info.details()); | 497 load_time_data.SetBoolean("overridable", false); |
| 498 | |
| 499 SSLErrorInfo::ErrorType type = | |
| 500 SSLErrorInfo::NetErrorToErrorType(cert_error_); | |
| 501 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | |
| 502 MaybeWindowsLacksSHA256Support()) { | |
| 503 load_time_data.SetString( | |
| 504 "explanationParagraph", | |
| 505 l10n_util::GetStringFUTF16( | |
| 506 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | |
| 507 } else { | |
| 508 load_time_data.SetString("explanationParagraph", | |
| 509 l10n_util::GetStringFUTF16( | |
| 510 IDS_SSL_NONOVERRIDABLE_MORE, url)); | |
| 511 } | |
| 512 load_time_data.SetString( | |
| 513 "primaryButtonText", | |
| 514 l10n_util::GetStringUTF16(IDS_SSL_NONOVERRIDABLE_RELOAD_BUTTON)); | |
| 515 // Customize the help link depending on the specific error type. | |
| 516 // Only mark as HSTS if none of the more specific error types apply, | |
| 517 // and use INVALID as a fallback if no other string is appropriate. | |
| 518 load_time_data.SetInteger("errorType", type); | |
| 519 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | |
| 520 switch (type) { | |
| 521 case SSLErrorInfo::CERT_REVOKED: | |
| 522 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; | |
| 523 break; | |
| 524 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: | |
| 525 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; | |
| 526 break; | |
| 527 case SSLErrorInfo::CERT_INVALID: | |
| 528 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | |
| 529 break; | |
| 530 default: | |
| 531 if (strict_enforcement_) | |
| 532 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; | |
| 533 } | |
| 534 load_time_data.SetString( | |
| 535 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url)); | |
| 463 } | 536 } |
| 464 load_time_data.SetString( | |
| 465 "primaryButtonText", | |
| 466 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | |
| 467 load_time_data.SetString( | |
| 468 "finalParagraph", | |
| 469 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | |
| 470 url)); | |
| 471 } else { | |
| 472 SSLErrorInfo::ErrorType type = | |
| 473 SSLErrorInfo::NetErrorToErrorType(cert_error_); | |
| 474 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | |
| 475 MaybeWindowsLacksSHA256Support()) { | |
| 476 load_time_data.SetString( | |
| 477 "explanationParagraph", | |
| 478 l10n_util::GetStringFUTF16( | |
| 479 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | |
| 480 } else if (bad_clock) { | |
| 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", | |
| 486 l10n_util::GetStringFUTF16( | |
| 487 IDS_SSL_NONOVERRIDABLE_MORE, url)); | |
| 488 } | |
| 489 load_time_data.SetString( | |
| 490 "primaryButtonText", | |
| 491 l10n_util::GetStringUTF16(IDS_SSL_NONOVERRIDABLE_RELOAD_BUTTON)); | |
| 492 // Customize the help link depending on the specific error type. | |
| 493 // Only mark as HSTS if none of the more specific error types apply, and use | |
| 494 // INVALID as a fallback if no other string is appropriate. | |
| 495 load_time_data.SetInteger("errorType", type); | |
| 496 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | |
| 497 switch (type) { | |
| 498 case SSLErrorInfo::CERT_REVOKED: | |
| 499 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; | |
| 500 break; | |
| 501 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: | |
| 502 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; | |
| 503 break; | |
| 504 case SSLErrorInfo::CERT_INVALID: | |
| 505 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | |
| 506 break; | |
| 507 default: | |
| 508 if (strict_enforcement_) | |
| 509 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; | |
| 510 } | |
| 511 load_time_data.SetString( | |
| 512 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url)); | |
| 513 } | 537 } |
| 514 | 538 |
| 515 // Set debugging information at the bottom of the warning. | 539 // Set debugging information at the bottom of the warning. |
| 516 load_time_data.SetString( | 540 load_time_data.SetString( |
| 517 "subject", ssl_info_.cert->subject().GetDisplayName()); | 541 "subject", ssl_info_.cert->subject().GetDisplayName()); |
| 518 load_time_data.SetString( | 542 load_time_data.SetString( |
| 519 "issuer", ssl_info_.cert->issuer().GetDisplayName()); | 543 "issuer", ssl_info_.cert->issuer().GetDisplayName()); |
| 520 load_time_data.SetString( | 544 load_time_data.SetString( |
| 521 "expirationDate", | 545 "expirationDate", |
| 522 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); | 546 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 549 // DO NOT reorder or change this logic without also changing the JavaScript! | 573 // DO NOT reorder or change this logic without also changing the JavaScript! |
| 550 void SSLBlockingPage::CommandReceived(const std::string& command) { | 574 void SSLBlockingPage::CommandReceived(const std::string& command) { |
| 551 int cmd = 0; | 575 int cmd = 0; |
| 552 bool retval = base::StringToInt(command, &cmd); | 576 bool retval = base::StringToInt(command, &cmd); |
| 553 DCHECK(retval); | 577 DCHECK(retval); |
| 554 switch (cmd) { | 578 switch (cmd) { |
| 555 case CMD_DONT_PROCEED: { | 579 case CMD_DONT_PROCEED: { |
| 556 interstitial_page_->DontProceed(); | 580 interstitial_page_->DontProceed(); |
| 557 break; | 581 break; |
| 558 } | 582 } |
| 559 case CMD_PROCEED: { | 583 case CMD_PROCEED: { |
|
felt
2014/10/23 01:54:11
I don't want people to be able to type danger and
lgarron
2014/10/23 03:02:04
The interstitial JS can't call "proceed". There ar
felt
2014/10/23 05:26:22
handleKeypress is registered, which means that you
lgarron
2014/10/23 19:37:44
I didn't know about typing "danger". I can look in
felt
2014/10/23 20:48:57
It's because the normal error warns the user. This
| |
| 560 interstitial_page_->Proceed(); | 584 interstitial_page_->Proceed(); |
| 561 break; | 585 break; |
| 562 } | 586 } |
| 563 case CMD_MORE: { | 587 case CMD_MORE: { |
| 564 RecordSSLBlockingPageEventStats(MORE); | 588 RecordSSLBlockingPageEventStats(MORE); |
| 565 #if defined(ENABLE_EXTENSIONS) | 589 #if defined(ENABLE_EXTENSIONS) |
| 566 if (sampling_event_.get()) | 590 if (sampling_event_.get()) |
| 567 sampling_event_->set_has_viewed_details(true); | 591 sampling_event_->set_has_viewed_details(true); |
| 568 #endif | 592 #endif |
| 569 break; | 593 break; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 for (; i < 5; i++) { | 692 for (; i < 5; i++) { |
| 669 strings->SetString(keys[i], std::string()); | 693 strings->SetString(keys[i], std::string()); |
| 670 } | 694 } |
| 671 } | 695 } |
| 672 | 696 |
| 673 void SSLBlockingPage::OnGotHistoryCount(bool success, | 697 void SSLBlockingPage::OnGotHistoryCount(bool success, |
| 674 int num_visits, | 698 int num_visits, |
| 675 base::Time first_visit) { | 699 base::Time first_visit) { |
| 676 num_visits_ = num_visits; | 700 num_visits_ = num_visits; |
| 677 } | 701 } |
| OLD | NEW |