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" | 20 #include "content/public/browser/cert_store.h" |
21 #include "content/public/browser/interstitial_page.h" | 21 #include "content/public/browser/interstitial_page.h" |
22 #include "content/public/browser/interstitial_page_delegate.h" | 22 #include "content/public/browser/interstitial_page_delegate.h" |
23 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
24 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/signed_certificate_timestamp_store.h" | |
28 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
29 #include "content/public/common/renderer_preferences.h" | 28 #include "content/public/common/renderer_preferences.h" |
30 #include "content/public/common/ssl_status.h" | 29 #include "content/public/common/ssl_status.h" |
31 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
32 | 31 |
33 using content::InterstitialPageDelegate; | 32 using content::InterstitialPageDelegate; |
34 using content::NavigationController; | 33 using content::NavigationController; |
35 using content::NavigationEntry; | 34 using content::NavigationEntry; |
36 | 35 |
37 namespace { | 36 namespace { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 bad_clock_ui_->PopulateStringsForHTML(load_time_data); | 106 bad_clock_ui_->PopulateStringsForHTML(load_time_data); |
108 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); | 107 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); |
109 } | 108 } |
110 | 109 |
111 void BadClockBlockingPage::OverrideEntry(NavigationEntry* entry) { | 110 void BadClockBlockingPage::OverrideEntry(NavigationEntry* entry) { |
112 const int process_id = web_contents()->GetRenderProcessHost()->GetID(); | 111 const int process_id = web_contents()->GetRenderProcessHost()->GetID(); |
113 const int cert_id = content::CertStore::GetInstance()->StoreCert( | 112 const int cert_id = content::CertStore::GetInstance()->StoreCert( |
114 ssl_info_.cert.get(), process_id); | 113 ssl_info_.cert.get(), process_id); |
115 DCHECK(cert_id); | 114 DCHECK(cert_id); |
116 | 115 |
117 content::SignedCertificateTimestampStore* sct_store( | 116 entry->GetSSL() = content::SSLStatus( |
118 content::SignedCertificateTimestampStore::GetInstance()); | 117 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, ssl_info_); |
119 content::SignedCertificateTimestampIDStatusList sct_ids; | |
120 for (const auto& sct_and_status : ssl_info_.signed_certificate_timestamps) { | |
121 const int sct_id(sct_store->Store(sct_and_status.sct.get(), process_id)); | |
122 DCHECK(sct_id); | |
123 sct_ids.push_back(content::SignedCertificateTimestampIDAndStatus( | |
124 sct_id, sct_and_status.status)); | |
125 } | |
126 | |
127 entry->GetSSL() = | |
128 content::SSLStatus(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, | |
129 sct_ids, ssl_info_); | |
130 } | 118 } |
131 | 119 |
132 void BadClockBlockingPage::SetSSLCertReporterForTesting( | 120 void BadClockBlockingPage::SetSSLCertReporterForTesting( |
133 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { | 121 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { |
134 cert_report_helper_->SetSSLCertReporterForTesting( | 122 cert_report_helper_->SetSSLCertReporterForTesting( |
135 std::move(ssl_cert_reporter)); | 123 std::move(ssl_cert_reporter)); |
136 } | 124 } |
137 | 125 |
138 // This handles the commands sent from the interstitial JavaScript. | 126 // This handles the commands sent from the interstitial JavaScript. |
139 void BadClockBlockingPage::CommandReceived(const std::string& command) { | 127 void BadClockBlockingPage::CommandReceived(const std::string& command) { |
(...skipping 27 matching lines...) Expand all Loading... |
167 | 155 |
168 void BadClockBlockingPage::NotifyDenyCertificate() { | 156 void BadClockBlockingPage::NotifyDenyCertificate() { |
169 // It's possible that callback_ may not exist if the user clicks "Proceed" | 157 // It's possible that callback_ may not exist if the user clicks "Proceed" |
170 // followed by pressing the back button before the interstitial is hidden. | 158 // followed by pressing the back button before the interstitial is hidden. |
171 // In that case the certificate will still be treated as allowed. | 159 // In that case the certificate will still be treated as allowed. |
172 if (callback_.is_null()) | 160 if (callback_.is_null()) |
173 return; | 161 return; |
174 | 162 |
175 base::ResetAndReturn(&callback_).Run(false); | 163 base::ResetAndReturn(&callback_).Run(false); |
176 } | 164 } |
OLD | NEW |