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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 const GURL& request_url, | 312 const GURL& request_url, |
311 int options_mask, | 313 int options_mask, |
312 const base::Callback<void(bool)>& callback) | 314 const base::Callback<void(bool)>& callback) |
313 : callback_(callback), | 315 : callback_(callback), |
314 web_contents_(web_contents), | 316 web_contents_(web_contents), |
315 cert_error_(cert_error), | 317 cert_error_(cert_error), |
316 ssl_info_(ssl_info), | 318 ssl_info_(ssl_info), |
317 request_url_(request_url), | 319 request_url_(request_url), |
318 overridable_(options_mask & OVERRIDABLE && | 320 overridable_(options_mask & OVERRIDABLE && |
319 !(options_mask & STRICT_ENFORCEMENT)), | 321 !(options_mask & STRICT_ENFORCEMENT)), |
| 322 danger_overridable_(true), |
320 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), | 323 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
321 interstitial_page_(NULL), | 324 interstitial_page_(NULL), |
322 internal_(false), | 325 internal_(false), |
323 num_visits_(-1), | 326 num_visits_(-1), |
324 expired_but_previously_allowed_( | 327 expired_but_previously_allowed_( |
325 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { | 328 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { |
326 Profile* profile = Profile::FromBrowserContext( | 329 Profile* profile = Profile::FromBrowserContext( |
327 web_contents->GetBrowserContext()); | 330 web_contents->GetBrowserContext()); |
328 // For UMA stats. | 331 // For UMA stats. |
329 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) | 332 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 interstitial_page_->Show(); | 414 interstitial_page_->Show(); |
412 } | 415 } |
413 | 416 |
414 std::string SSLBlockingPage::GetHTMLContents() { | 417 std::string SSLBlockingPage::GetHTMLContents() { |
415 base::DictionaryValue load_time_data; | 418 base::DictionaryValue load_time_data; |
416 base::string16 url(ASCIIToUTF16(request_url_.host())); | 419 base::string16 url(ASCIIToUTF16(request_url_.host())); |
417 if (base::i18n::IsRTL()) | 420 if (base::i18n::IsRTL()) |
418 base::i18n::WrapStringWithLTRFormatting(&url); | 421 base::i18n::WrapStringWithLTRFormatting(&url); |
419 webui::SetFontAndTextDirection(&load_time_data); | 422 webui::SetFontAndTextDirection(&load_time_data); |
420 | 423 |
421 // Shared values for both the overridable and non-overridable versions. | |
422 load_time_data.SetString("type", "SSL"); | 424 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 | 425 |
429 base::Time now = base::Time::NowFromSystemTime(); | 426 base::Time now = base::Time::NowFromSystemTime(); |
430 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); | 427 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); |
| 428 |
| 429 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); |
| 430 |
431 if (bad_clock) { | 431 if (bad_clock) { |
| 432 load_time_data.SetBoolean("bad_clock", true); |
| 433 load_time_data.SetBoolean("overridable", false); |
| 434 |
| 435 // We're showing the SSL clock warning to be helpful, but we haven't warned |
| 436 // them about the risks. (And there might still be an SSL error after they |
| 437 // fix their clock.) Thus, we don't allow the "danger" override in this |
| 438 // case. |
| 439 danger_overridable_ = false; |
| 440 |
| 441 int heading_string = SSLErrorClassification::IsUserClockInTheFuture(now) ? |
| 442 IDS_SSL_V2_CLOCK_AHEAD_HEADING : |
| 443 IDS_SSL_V2_CLOCK_BEHIND_HEADING; |
| 444 |
| 445 load_time_data.SetString( |
| 446 "tabTitle", |
| 447 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_TITLE)); |
| 448 load_time_data.SetString( |
| 449 "heading", |
| 450 l10n_util::GetStringUTF16(heading_string)); |
432 load_time_data.SetString("primaryParagraph", | 451 load_time_data.SetString("primaryParagraph", |
433 l10n_util::GetStringFUTF16( | 452 l10n_util::GetStringFUTF16( |
434 IDS_SSL_CLOCK_ERROR, | 453 IDS_SSL_V2_CLOCK_PRIMARY_PARAGRAPH , |
435 url, | 454 url, |
436 base::TimeFormatShortDate(now))); | 455 base::TimeFormatFriendlyDateAndTime(now))); |
| 456 |
| 457 load_time_data.SetString( |
| 458 "primaryButtonText", |
| 459 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_UPDATE_DATE_AND_TIME)); |
| 460 load_time_data.SetString( |
| 461 "openDetails", |
| 462 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); |
| 463 |
| 464 // The interstitial template expects these strings, but we're not using |
| 465 // them. So we send blank strings for now. |
| 466 load_time_data.SetString("explanationParagraph", std::string()); |
| 467 load_time_data.SetString("finalParagraph", std::string()); |
437 } else { | 468 } else { |
| 469 load_time_data.SetBoolean("bad_clock", false); |
| 470 |
| 471 load_time_data.SetString( |
| 472 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
| 473 load_time_data.SetString( |
| 474 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
438 load_time_data.SetString( | 475 load_time_data.SetString( |
439 "primaryParagraph", | 476 "primaryParagraph", |
440 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 477 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
441 } | 478 load_time_data.SetString( |
| 479 "openDetails", |
| 480 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); |
| 481 load_time_data.SetString( |
| 482 "closeDetails", |
| 483 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); |
442 | 484 |
443 load_time_data.SetString( | 485 if (overridable_) { |
444 "openDetails", | 486 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 | 487 |
451 if (overridable_) { | 488 SSLErrorInfo error_info = |
452 SSLErrorInfo error_info = | 489 SSLErrorInfo::CreateError( |
453 SSLErrorInfo::CreateError( | 490 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
454 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 491 ssl_info_.cert.get(), |
455 ssl_info_.cert.get(), | 492 request_url_); |
456 request_url_); | 493 load_time_data.SetString("explanationParagraph", error_info.details()); |
457 if (bad_clock) { | 494 load_time_data.SetString( |
458 load_time_data.SetString("explanationParagraph", | 495 "primaryButtonText", |
459 l10n_util::GetStringFUTF16( | 496 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
460 IDS_SSL_CLOCK_ERROR_EXPLANATION, url)); | 497 load_time_data.SetString( |
| 498 "finalParagraph", |
| 499 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
| 500 url)); |
461 } else { | 501 } else { |
462 load_time_data.SetString("explanationParagraph", error_info.details()); | 502 load_time_data.SetBoolean("overridable", false); |
| 503 |
| 504 SSLErrorInfo::ErrorType type = |
| 505 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
| 506 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: |
| 507 MaybeWindowsLacksSHA256Support()) { |
| 508 load_time_data.SetString( |
| 509 "explanationParagraph", |
| 510 l10n_util::GetStringFUTF16( |
| 511 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); |
| 512 } else { |
| 513 load_time_data.SetString("explanationParagraph", |
| 514 l10n_util::GetStringFUTF16( |
| 515 IDS_SSL_NONOVERRIDABLE_MORE, url)); |
| 516 } |
| 517 load_time_data.SetString( |
| 518 "primaryButtonText", |
| 519 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); |
| 520 // Customize the help link depending on the specific error type. |
| 521 // Only mark as HSTS if none of the more specific error types apply, |
| 522 // and use INVALID as a fallback if no other string is appropriate. |
| 523 load_time_data.SetInteger("errorType", type); |
| 524 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; |
| 525 switch (type) { |
| 526 case SSLErrorInfo::CERT_REVOKED: |
| 527 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; |
| 528 break; |
| 529 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: |
| 530 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; |
| 531 break; |
| 532 case SSLErrorInfo::CERT_INVALID: |
| 533 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; |
| 534 break; |
| 535 default: |
| 536 if (strict_enforcement_) |
| 537 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; |
| 538 } |
| 539 load_time_data.SetString( |
| 540 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url)); |
463 } | 541 } |
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 } | 542 } |
514 | 543 |
515 // Set debugging information at the bottom of the warning. | 544 // Set debugging information at the bottom of the warning. |
516 load_time_data.SetString( | 545 load_time_data.SetString( |
517 "subject", ssl_info_.cert->subject().GetDisplayName()); | 546 "subject", ssl_info_.cert->subject().GetDisplayName()); |
518 load_time_data.SetString( | 547 load_time_data.SetString( |
519 "issuer", ssl_info_.cert->issuer().GetDisplayName()); | 548 "issuer", ssl_info_.cert->issuer().GetDisplayName()); |
520 load_time_data.SetString( | 549 load_time_data.SetString( |
521 "expirationDate", | 550 "expirationDate", |
522 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); | 551 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); |
(...skipping 27 matching lines...) Expand all Loading... |
550 void SSLBlockingPage::CommandReceived(const std::string& command) { | 579 void SSLBlockingPage::CommandReceived(const std::string& command) { |
551 int cmd = 0; | 580 int cmd = 0; |
552 bool retval = base::StringToInt(command, &cmd); | 581 bool retval = base::StringToInt(command, &cmd); |
553 DCHECK(retval); | 582 DCHECK(retval); |
554 switch (cmd) { | 583 switch (cmd) { |
555 case CMD_DONT_PROCEED: { | 584 case CMD_DONT_PROCEED: { |
556 interstitial_page_->DontProceed(); | 585 interstitial_page_->DontProceed(); |
557 break; | 586 break; |
558 } | 587 } |
559 case CMD_PROCEED: { | 588 case CMD_PROCEED: { |
560 interstitial_page_->Proceed(); | 589 if (danger_overridable_) { |
| 590 interstitial_page_->Proceed(); |
| 591 } |
561 break; | 592 break; |
562 } | 593 } |
563 case CMD_MORE: { | 594 case CMD_MORE: { |
564 RecordSSLBlockingPageEventStats(MORE); | 595 RecordSSLBlockingPageEventStats(MORE); |
565 #if defined(ENABLE_EXTENSIONS) | 596 #if defined(ENABLE_EXTENSIONS) |
566 if (sampling_event_.get()) | 597 if (sampling_event_.get()) |
567 sampling_event_->set_has_viewed_details(true); | 598 sampling_event_->set_has_viewed_details(true); |
568 #endif | 599 #endif |
569 break; | 600 break; |
570 } | 601 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 for (; i < 5; i++) { | 699 for (; i < 5; i++) { |
669 strings->SetString(keys[i], std::string()); | 700 strings->SetString(keys[i], std::string()); |
670 } | 701 } |
671 } | 702 } |
672 | 703 |
673 void SSLBlockingPage::OnGotHistoryCount(bool success, | 704 void SSLBlockingPage::OnGotHistoryCount(bool success, |
674 int num_visits, | 705 int num_visits, |
675 base::Time first_visit) { | 706 base::Time first_visit) { |
676 num_visits_ = num_visits; | 707 num_visits_ = num_visits; |
677 } | 708 } |
OLD | NEW |