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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bad_clock_ui_->PopulateStringsForHTML(load_time_data); | 107 bad_clock_ui_->PopulateStringsForHTML(load_time_data); |
109 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); | 108 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); |
110 } | 109 } |
111 | 110 |
112 void BadClockBlockingPage::OverrideEntry(NavigationEntry* entry) { | 111 void BadClockBlockingPage::OverrideEntry(NavigationEntry* entry) { |
113 const int process_id = web_contents()->GetRenderProcessHost()->GetID(); | 112 const int process_id = web_contents()->GetRenderProcessHost()->GetID(); |
114 const int cert_id = content::CertStore::GetInstance()->StoreCert( | 113 const int cert_id = content::CertStore::GetInstance()->StoreCert( |
115 ssl_info_.cert.get(), process_id); | 114 ssl_info_.cert.get(), process_id); |
116 DCHECK(cert_id); | 115 DCHECK(cert_id); |
117 | 116 |
118 content::SignedCertificateTimestampStore* sct_store( | |
119 content::SignedCertificateTimestampStore::GetInstance()); | |
120 content::SignedCertificateTimestampIDStatusList sct_ids; | |
121 for (const auto& sct_and_status : ssl_info_.signed_certificate_timestamps) { | |
122 const int sct_id(sct_store->Store(sct_and_status.sct.get(), process_id)); | |
123 DCHECK(sct_id); | |
124 sct_ids.push_back(content::SignedCertificateTimestampIDAndStatus( | |
125 sct_id, sct_and_status.status)); | |
126 } | |
127 | |
128 entry->GetSSL() = | 117 entry->GetSSL() = |
129 content::SSLStatus(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, | 118 content::SSLStatus(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, |
130 sct_ids, ssl_info_); | 119 ssl_info_); |
131 } | 120 } |
132 | 121 |
133 void BadClockBlockingPage::SetSSLCertReporterForTesting( | 122 void BadClockBlockingPage::SetSSLCertReporterForTesting( |
134 scoped_ptr<SSLCertReporter> ssl_cert_reporter) { | 123 scoped_ptr<SSLCertReporter> ssl_cert_reporter) { |
135 cert_report_helper_->SetSSLCertReporterForTesting( | 124 cert_report_helper_->SetSSLCertReporterForTesting( |
136 std::move(ssl_cert_reporter)); | 125 std::move(ssl_cert_reporter)); |
137 } | 126 } |
138 | 127 |
139 // This handles the commands sent from the interstitial JavaScript. | 128 // This handles the commands sent from the interstitial JavaScript. |
140 void BadClockBlockingPage::CommandReceived(const std::string& command) { | 129 void BadClockBlockingPage::CommandReceived(const std::string& command) { |
(...skipping 27 matching lines...) Expand all Loading... |
168 | 157 |
169 void BadClockBlockingPage::NotifyDenyCertificate() { | 158 void BadClockBlockingPage::NotifyDenyCertificate() { |
170 // It's possible that callback_ may not exist if the user clicks "Proceed" | 159 // It's possible that callback_ may not exist if the user clicks "Proceed" |
171 // followed by pressing the back button before the interstitial is hidden. | 160 // followed by pressing the back button before the interstitial is hidden. |
172 // In that case the certificate will still be treated as allowed. | 161 // In that case the certificate will still be treated as allowed. |
173 if (callback_.is_null()) | 162 if (callback_.is_null()) |
174 return; | 163 return; |
175 | 164 |
176 base::ResetAndReturn(&callback_).Run(false); | 165 base::ResetAndReturn(&callback_).Run(false); |
177 } | 166 } |
OLD | NEW |