| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bad_clock_blocking_page.h" | 5 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "chrome/browser/interstitials/chrome_controller_client.h" | 11 #include "chrome/browser/interstitials/chrome_controller_client.h" |
| 12 #include "chrome/browser/interstitials/chrome_metrics_helper.h" | 12 #include "chrome/browser/interstitials/chrome_metrics_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/renderer_preferences_util.h" | 14 #include "chrome/browser/renderer_preferences_util.h" |
| 15 #include "chrome/browser/ssl/cert_report_helper.h" | 15 #include "chrome/browser/ssl/cert_report_helper.h" |
| 16 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 16 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 17 #include "components/security_interstitials/core/bad_clock_ui.h" | 17 #include "components/security_interstitials/core/bad_clock_ui.h" |
| 18 #include "components/security_interstitials/core/controller_client.h" | 18 #include "components/security_interstitials/core/controller_client.h" |
| 19 #include "components/security_interstitials/core/metrics_helper.h" | 19 #include "components/security_interstitials/core/metrics_helper.h" |
| 20 #include "content/public/browser/cert_store.h" | |
| 21 #include "content/public/browser/interstitial_page.h" | 20 #include "content/public/browser/interstitial_page.h" |
| 22 #include "content/public/browser/interstitial_page_delegate.h" | 21 #include "content/public/browser/interstitial_page_delegate.h" |
| 23 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/renderer_preferences.h" | 27 #include "content/public/common/renderer_preferences.h" |
| 29 #include "content/public/common/ssl_status.h" | 28 #include "content/public/common/ssl_status.h" |
| 30 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 controller_->set_interstitial_page(interstitial_page()); | 100 controller_->set_interstitial_page(interstitial_page()); |
| 102 } | 101 } |
| 103 | 102 |
| 104 void BadClockBlockingPage::PopulateInterstitialStrings( | 103 void BadClockBlockingPage::PopulateInterstitialStrings( |
| 105 base::DictionaryValue* load_time_data) { | 104 base::DictionaryValue* load_time_data) { |
| 106 bad_clock_ui_->PopulateStringsForHTML(load_time_data); | 105 bad_clock_ui_->PopulateStringsForHTML(load_time_data); |
| 107 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); | 106 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); |
| 108 } | 107 } |
| 109 | 108 |
| 110 void BadClockBlockingPage::OverrideEntry(NavigationEntry* entry) { | 109 void BadClockBlockingPage::OverrideEntry(NavigationEntry* entry) { |
| 111 const int process_id = web_contents()->GetRenderProcessHost()->GetID(); | |
| 112 const int cert_id = content::CertStore::GetInstance()->StoreCert( | |
| 113 ssl_info_.cert.get(), process_id); | |
| 114 DCHECK(cert_id); | |
| 115 | |
| 116 entry->GetSSL() = content::SSLStatus( | 110 entry->GetSSL() = content::SSLStatus( |
| 117 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, ssl_info_); | 111 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, ssl_info_.cert, ssl_info_); |
| 118 } | 112 } |
| 119 | 113 |
| 120 void BadClockBlockingPage::SetSSLCertReporterForTesting( | 114 void BadClockBlockingPage::SetSSLCertReporterForTesting( |
| 121 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { | 115 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { |
| 122 cert_report_helper_->SetSSLCertReporterForTesting( | 116 cert_report_helper_->SetSSLCertReporterForTesting( |
| 123 std::move(ssl_cert_reporter)); | 117 std::move(ssl_cert_reporter)); |
| 124 } | 118 } |
| 125 | 119 |
| 126 // This handles the commands sent from the interstitial JavaScript. | 120 // This handles the commands sent from the interstitial JavaScript. |
| 127 void BadClockBlockingPage::CommandReceived(const std::string& command) { | 121 void BadClockBlockingPage::CommandReceived(const std::string& command) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 156 void BadClockBlockingPage::NotifyDenyCertificate() { | 150 void BadClockBlockingPage::NotifyDenyCertificate() { |
| 157 // It's possible that callback_ may not exist if the user clicks "Proceed" | 151 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 158 // followed by pressing the back button before the interstitial is hidden. | 152 // followed by pressing the back button before the interstitial is hidden. |
| 159 // In that case the certificate will still be treated as allowed. | 153 // In that case the certificate will still be treated as allowed. |
| 160 if (callback_.is_null()) | 154 if (callback_.is_null()) |
| 161 return; | 155 return; |
| 162 | 156 |
| 163 base::ResetAndReturn(&callback_) | 157 base::ResetAndReturn(&callback_) |
| 164 .Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); | 158 .Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); |
| 165 } | 159 } |
| OLD | NEW |