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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 else | 366 else |
| 365 event_name.append(kEventNotOverridable); | 367 event_name.append(kEventNotOverridable); |
| 366 event_name.append(net::ErrorToString(cert_error_)); | 368 event_name.append(net::ErrorToString(cert_error_)); |
| 367 sampling_event_.reset(new ExperienceSamplingEvent( | 369 sampling_event_.reset(new ExperienceSamplingEvent( |
| 368 event_name, | 370 event_name, |
| 369 request_url_, | 371 request_url_, |
| 370 web_contents_->GetLastCommittedURL(), | 372 web_contents_->GetLastCommittedURL(), |
| 371 web_contents_->GetBrowserContext())); | 373 web_contents_->GetBrowserContext())); |
| 372 #endif | 374 #endif |
| 373 | 375 |
| 376 // For now, allow interstitials to be "danger" overridable by default. | |
| 377 danger_overridable_ = true; | |
|
felt
2014/10/23 23:19:03
you should do this in the init block at the top:
| |
| 378 | |
| 374 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 379 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
| 375 // it leaks memory, so don't create it here. | 380 // it leaks memory, so don't create it here. |
| 376 } | 381 } |
| 377 | 382 |
| 378 SSLBlockingPage::~SSLBlockingPage() { | 383 SSLBlockingPage::~SSLBlockingPage() { |
| 379 // InvalidCommonNameSeverityScore() and InvalidDateSeverityScore() are in the | 384 // InvalidCommonNameSeverityScore() and InvalidDateSeverityScore() are in the |
| 380 // destructor because they depend on knowing whether captive portal detection | 385 // destructor because they depend on knowing whether captive portal detection |
| 381 // happened before the user made a decision. | 386 // happened before the user made a decision. |
| 382 SSLErrorInfo::ErrorType type = | 387 SSLErrorInfo::ErrorType type = |
| 383 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 388 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 411 interstitial_page_->Show(); | 416 interstitial_page_->Show(); |
| 412 } | 417 } |
| 413 | 418 |
| 414 std::string SSLBlockingPage::GetHTMLContents() { | 419 std::string SSLBlockingPage::GetHTMLContents() { |
| 415 base::DictionaryValue load_time_data; | 420 base::DictionaryValue load_time_data; |
| 416 base::string16 url(ASCIIToUTF16(request_url_.host())); | 421 base::string16 url(ASCIIToUTF16(request_url_.host())); |
| 417 if (base::i18n::IsRTL()) | 422 if (base::i18n::IsRTL()) |
| 418 base::i18n::WrapStringWithLTRFormatting(&url); | 423 base::i18n::WrapStringWithLTRFormatting(&url); |
| 419 webui::SetFontAndTextDirection(&load_time_data); | 424 webui::SetFontAndTextDirection(&load_time_data); |
| 420 | 425 |
| 421 // Shared values for both the overridable and non-overridable versions. | |
| 422 load_time_data.SetString("type", "SSL"); | 426 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 | 427 |
| 429 base::Time now = base::Time::NowFromSystemTime(); | 428 base::Time now = base::Time::NowFromSystemTime(); |
| 430 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); | 429 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); |
| 430 | |
| 431 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | |
| 432 | |
| 431 if (bad_clock) { | 433 if (bad_clock) { |
| 434 load_time_data.SetBoolean("bad_clock", true); | |
| 435 load_time_data.SetBoolean("overridable", false); | |
| 436 | |
| 437 // We're showing the SSL clock warning to be helpful, but we haven't | |
| 438 // warned them about the risks. (And there might still be an SSL error | |
| 439 // after they fix their clock.) | |
| 440 // Thus, we don't allow the "danger" override in this case. | |
| 441 danger_overridable_ = false; | |
| 442 | |
| 443 int heading_string = SSLErrorClassification::IsUserClockInTheFuture(now) ? | |
| 444 IDS_SSL_V2_CLOCK_AHEAD_HEADING : | |
| 445 IDS_SSL_V2_CLOCK_BEHIND_HEADING; | |
| 446 | |
| 447 load_time_data.SetString( | |
| 448 "tabTitle", | |
| 449 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_TITLE)); | |
| 450 load_time_data.SetString( | |
| 451 "heading", | |
| 452 l10n_util::GetStringUTF16(heading_string)); | |
| 432 load_time_data.SetString("primaryParagraph", | 453 load_time_data.SetString("primaryParagraph", |
| 433 l10n_util::GetStringFUTF16( | 454 l10n_util::GetStringFUTF16( |
| 434 IDS_SSL_CLOCK_ERROR, | 455 IDS_SSL_V2_CLOCK_PRIMARY_PARAGRAPH , |
| 435 url, | 456 url, |
| 436 base::TimeFormatShortDate(now))); | 457 base::TimeFormatFriendlyDateAndTime(now))); |
| 458 | |
| 459 load_time_data.SetString( | |
| 460 "primaryButtonText", | |
| 461 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_UPDATE_DATE_AND_TIME)); | |
| 462 load_time_data.SetString( | |
| 463 "openDetails", | |
| 464 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); | |
| 465 | |
| 466 // The interstitial template expects these strings, | |
| 467 // but we're not using them. So we send blank strings for now. | |
|
palmer
2014/10/24 00:40:48
Nit: Wrap/format comment paragraphs, throughout (n
lgarron
2014/10/24 08:00:27
I'd be happy to format my comments properly, but I
| |
| 468 load_time_data.SetString("explanationParagraph", std::string()); | |
| 469 load_time_data.SetString("finalParagraph", std::string()); | |
| 437 } else { | 470 } else { |
| 471 load_time_data.SetBoolean("bad_clock", false); | |
| 472 | |
| 473 load_time_data.SetString( | |
| 474 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | |
| 475 load_time_data.SetString( | |
| 476 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | |
| 438 load_time_data.SetString( | 477 load_time_data.SetString( |
| 439 "primaryParagraph", | 478 "primaryParagraph", |
| 440 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 479 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
| 441 } | 480 load_time_data.SetString( |
| 481 "openDetails", | |
| 482 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | |
| 483 load_time_data.SetString( | |
| 484 "closeDetails", | |
| 485 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | |
| 442 | 486 |
| 443 load_time_data.SetString( | 487 if (overridable_) { |
| 444 "openDetails", | 488 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 | 489 |
| 451 if (overridable_) { | 490 SSLErrorInfo error_info = |
| 452 SSLErrorInfo error_info = | 491 SSLErrorInfo::CreateError( |
| 453 SSLErrorInfo::CreateError( | 492 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
| 454 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 493 ssl_info_.cert.get(), |
| 455 ssl_info_.cert.get(), | 494 request_url_); |
| 456 request_url_); | 495 load_time_data.SetString("explanationParagraph", error_info.details()); |
| 457 if (bad_clock) { | 496 load_time_data.SetString( |
| 458 load_time_data.SetString("explanationParagraph", | 497 "primaryButtonText", |
| 459 l10n_util::GetStringFUTF16( | 498 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
| 460 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); | 499 load_time_data.SetString( |
| 500 "finalParagraph", | |
| 501 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | |
| 502 url)); | |
| 461 } else { | 503 } else { |
| 462 load_time_data.SetString("explanationParagraph", error_info.details()); | 504 load_time_data.SetBoolean("overridable", false); |
| 505 | |
| 506 SSLErrorInfo::ErrorType type = | |
| 507 SSLErrorInfo::NetErrorToErrorType(cert_error_); | |
| 508 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | |
| 509 MaybeWindowsLacksSHA256Support()) { | |
| 510 load_time_data.SetString( | |
| 511 "explanationParagraph", | |
| 512 l10n_util::GetStringFUTF16( | |
| 513 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | |
| 514 } else { | |
| 515 load_time_data.SetString("explanationParagraph", | |
| 516 l10n_util::GetStringFUTF16( | |
| 517 IDS_SSL_NONOVERRIDABLE_MORE, url)); | |
| 518 } | |
| 519 load_time_data.SetString( | |
| 520 "primaryButtonText", | |
| 521 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); | |
| 522 // Customize the help link depending on the specific error type. | |
| 523 // Only mark as HSTS if none of the more specific error types apply, | |
| 524 // and use INVALID as a fallback if no other string is appropriate. | |
| 525 load_time_data.SetInteger("errorType", type); | |
| 526 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | |
| 527 switch (type) { | |
| 528 case SSLErrorInfo::CERT_REVOKED: | |
| 529 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; | |
| 530 break; | |
| 531 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: | |
| 532 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; | |
| 533 break; | |
| 534 case SSLErrorInfo::CERT_INVALID: | |
| 535 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | |
| 536 break; | |
| 537 default: | |
| 538 if (strict_enforcement_) | |
| 539 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; | |
| 540 } | |
| 541 load_time_data.SetString( | |
| 542 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url)); | |
| 463 } | 543 } |
| 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 } | 544 } |
| 514 | 545 |
| 515 // Set debugging information at the bottom of the warning. | 546 // Set debugging information at the bottom of the warning. |
| 516 load_time_data.SetString( | 547 load_time_data.SetString( |
| 517 "subject", ssl_info_.cert->subject().GetDisplayName()); | 548 "subject", ssl_info_.cert->subject().GetDisplayName()); |
| 518 load_time_data.SetString( | 549 load_time_data.SetString( |
| 519 "issuer", ssl_info_.cert->issuer().GetDisplayName()); | 550 "issuer", ssl_info_.cert->issuer().GetDisplayName()); |
| 520 load_time_data.SetString( | 551 load_time_data.SetString( |
| 521 "expirationDate", | 552 "expirationDate", |
| 522 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); | 553 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 550 void SSLBlockingPage::CommandReceived(const std::string& command) { | 581 void SSLBlockingPage::CommandReceived(const std::string& command) { |
| 551 int cmd = 0; | 582 int cmd = 0; |
| 552 bool retval = base::StringToInt(command, &cmd); | 583 bool retval = base::StringToInt(command, &cmd); |
| 553 DCHECK(retval); | 584 DCHECK(retval); |
| 554 switch (cmd) { | 585 switch (cmd) { |
| 555 case CMD_DONT_PROCEED: { | 586 case CMD_DONT_PROCEED: { |
| 556 interstitial_page_->DontProceed(); | 587 interstitial_page_->DontProceed(); |
| 557 break; | 588 break; |
| 558 } | 589 } |
| 559 case CMD_PROCEED: { | 590 case CMD_PROCEED: { |
| 560 interstitial_page_->Proceed(); | 591 if (danger_overridable_) { |
| 592 interstitial_page_->Proceed(); | |
| 593 } | |
| 561 break; | 594 break; |
| 562 } | 595 } |
| 563 case CMD_MORE: { | 596 case CMD_MORE: { |
| 564 RecordSSLBlockingPageEventStats(MORE); | 597 RecordSSLBlockingPageEventStats(MORE); |
| 565 #if defined(ENABLE_EXTENSIONS) | 598 #if defined(ENABLE_EXTENSIONS) |
| 566 if (sampling_event_.get()) | 599 if (sampling_event_.get()) |
| 567 sampling_event_->set_has_viewed_details(true); | 600 sampling_event_->set_has_viewed_details(true); |
| 568 #endif | 601 #endif |
| 569 break; | 602 break; |
| 570 } | 603 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 for (; i < 5; i++) { | 701 for (; i < 5; i++) { |
| 669 strings->SetString(keys[i], std::string()); | 702 strings->SetString(keys[i], std::string()); |
| 670 } | 703 } |
| 671 } | 704 } |
| 672 | 705 |
| 673 void SSLBlockingPage::OnGotHistoryCount(bool success, | 706 void SSLBlockingPage::OnGotHistoryCount(bool success, |
| 674 int num_visits, | 707 int num_visits, |
| 675 base::Time first_visit) { | 708 base::Time first_visit) { |
| 676 num_visits_ = num_visits; | 709 num_visits_ = num_visits; |
| 677 } | 710 } |
| OLD | NEW |