| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 renderer_preferences_util::UpdateFromSystemSettings( | 580 renderer_preferences_util::UpdateFromSystemSettings( |
| 581 prefs, profile, web_contents()); | 581 prefs, profile, web_contents()); |
| 582 } | 582 } |
| 583 | 583 |
| 584 void SSLBlockingPage::OnProceed() { | 584 void SSLBlockingPage::OnProceed() { |
| 585 metrics_helper()->RecordUserDecision( | 585 metrics_helper()->RecordUserDecision( |
| 586 SecurityInterstitialMetricsHelper::PROCEED); | 586 SecurityInterstitialMetricsHelper::PROCEED); |
| 587 | 587 |
| 588 // Finish collecting information about invalid certificates, if the | 588 // Finish collecting information about invalid certificates, if the |
| 589 // user opted in to. | 589 // user opted in to. |
| 590 FinishCertCollection(); | 590 FinishCertCollection(CertificateErrorReport::USER_PROCEEDED); |
| 591 | 591 |
| 592 RecordSSLExpirationPageEventState( | 592 RecordSSLExpirationPageEventState( |
| 593 expired_but_previously_allowed_, true, overridable_); | 593 expired_but_previously_allowed_, true, overridable_); |
| 594 // Accepting the certificate resumes the loading of the page. | 594 // Accepting the certificate resumes the loading of the page. |
| 595 NotifyAllowCertificate(); | 595 NotifyAllowCertificate(); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void SSLBlockingPage::OnDontProceed() { | 598 void SSLBlockingPage::OnDontProceed() { |
| 599 metrics_helper()->RecordUserDecision( | 599 metrics_helper()->RecordUserDecision( |
| 600 SecurityInterstitialMetricsHelper::DONT_PROCEED); | 600 SecurityInterstitialMetricsHelper::DONT_PROCEED); |
| 601 | 601 |
| 602 // Finish collecting information about invalid certificates, if the | 602 // Finish collecting information about invalid certificates, if the |
| 603 // user opted in to. | 603 // user opted in to. |
| 604 FinishCertCollection(); | 604 FinishCertCollection(CertificateErrorReport::USER_DID_NOT_PROCEED); |
| 605 | 605 |
| 606 RecordSSLExpirationPageEventState( | 606 RecordSSLExpirationPageEventState( |
| 607 expired_but_previously_allowed_, false, overridable_); | 607 expired_but_previously_allowed_, false, overridable_); |
| 608 NotifyDenyCertificate(); | 608 NotifyDenyCertificate(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void SSLBlockingPage::NotifyDenyCertificate() { | 611 void SSLBlockingPage::NotifyDenyCertificate() { |
| 612 // It's possible that callback_ may not exist if the user clicks "Proceed" | 612 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 613 // followed by pressing the back button before the interstitial is hidden. | 613 // followed by pressing the back button before the interstitial is hidden. |
| 614 // In that case the certificate will still be treated as allowed. | 614 // In that case the certificate will still be treated as allowed. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 643 std::string SSLBlockingPage::GetSamplingEventName() const { | 643 std::string SSLBlockingPage::GetSamplingEventName() const { |
| 644 std::string event_name(kEventNameBase); | 644 std::string event_name(kEventNameBase); |
| 645 if (overridable_) | 645 if (overridable_) |
| 646 event_name.append(kEventOverridable); | 646 event_name.append(kEventOverridable); |
| 647 else | 647 else |
| 648 event_name.append(kEventNotOverridable); | 648 event_name.append(kEventNotOverridable); |
| 649 event_name.append(net::ErrorToString(cert_error_)); | 649 event_name.append(net::ErrorToString(cert_error_)); |
| 650 return event_name; | 650 return event_name; |
| 651 } | 651 } |
| 652 | 652 |
| 653 void SSLBlockingPage::FinishCertCollection() { | 653 void SSLBlockingPage::FinishCertCollection( |
| 654 CertificateErrorReport::ProceedDecision user_proceeded) { |
| 654 if (!ShouldShowCertificateReporterCheckbox()) | 655 if (!ShouldShowCertificateReporterCheckbox()) |
| 655 return; | 656 return; |
| 656 | 657 |
| 657 const bool enabled = | 658 const bool enabled = |
| 658 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | 659 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
| 659 | 660 |
| 660 if (!enabled) | 661 if (!enabled) |
| 661 return; | 662 return; |
| 662 | 663 |
| 663 metrics_helper()->RecordUserInteraction( | 664 metrics_helper()->RecordUserInteraction( |
| 664 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); | 665 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| 665 | 666 |
| 666 if (ShouldReportCertificateError()) { | 667 if (ShouldReportCertificateError()) { |
| 667 std::string serialized_report; | 668 std::string serialized_report; |
| 668 CertificateErrorReport report(request_url().host(), ssl_info_); | 669 CertificateErrorReport report(request_url().host(), ssl_info_); |
| 669 | 670 |
| 671 CertificateErrorReport::InterstitialReason report_interstitial_reason; |
| 672 switch (interstitial_reason_) { |
| 673 case SSL_REASON_SSL: |
| 674 report_interstitial_reason = CertificateErrorReport::INTERSTITIAL_SSL; |
| 675 break; |
| 676 case SSL_REASON_BAD_CLOCK: |
| 677 report_interstitial_reason = CertificateErrorReport::INTERSTITIAL_CLOCK; |
| 678 break; |
| 679 } |
| 680 |
| 681 report.SetInterstitialInfo( |
| 682 report_interstitial_reason, user_proceeded, |
| 683 overridable_ ? CertificateErrorReport::INTERSTITIAL_OVERRIDABLE |
| 684 : CertificateErrorReport::INTERSTITIAL_NOT_OVERRIDABLE); |
| 685 |
| 670 if (!report.Serialize(&serialized_report)) { | 686 if (!report.Serialize(&serialized_report)) { |
| 671 LOG(ERROR) << "Failed to serialize certificate report."; | 687 LOG(ERROR) << "Failed to serialize certificate report."; |
| 672 return; | 688 return; |
| 673 } | 689 } |
| 674 | 690 |
| 675 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); | 691 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); |
| 676 } | 692 } |
| 677 } | 693 } |
| 678 | 694 |
| 679 bool SSLBlockingPage::ShouldShowCertificateReporterCheckbox() { | 695 bool SSLBlockingPage::ShouldShowCertificateReporterCheckbox() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 | 730 |
| 715 // static | 731 // static |
| 716 bool SSLBlockingPage::IsOverridable(int options_mask, | 732 bool SSLBlockingPage::IsOverridable(int options_mask, |
| 717 const Profile* const profile) { | 733 const Profile* const profile) { |
| 718 const bool is_overridable = | 734 const bool is_overridable = |
| 719 (options_mask & SSLBlockingPage::OVERRIDABLE) && | 735 (options_mask & SSLBlockingPage::OVERRIDABLE) && |
| 720 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && | 736 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && |
| 721 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 737 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
| 722 return is_overridable; | 738 return is_overridable; |
| 723 } | 739 } |
| OLD | NEW |