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> |
| 8 |
7 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
8 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/interstitials/chrome_controller_client.h" | 12 #include "chrome/browser/interstitials/chrome_controller_client.h" |
11 #include "chrome/browser/interstitials/chrome_metrics_helper.h" | 13 #include "chrome/browser/interstitials/chrome_metrics_helper.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/renderer_preferences_util.h" | 15 #include "chrome/browser/renderer_preferences_util.h" |
14 #include "chrome/browser/ssl/cert_report_helper.h" | 16 #include "chrome/browser/ssl/cert_report_helper.h" |
15 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 17 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
16 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 72 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
71 | 73 |
72 // Set up the metrics helper for the BadClockUI. | 74 // Set up the metrics helper for the BadClockUI. |
73 security_interstitials::MetricsHelper::ReportDetails reporting_info; | 75 security_interstitials::MetricsHelper::ReportDetails reporting_info; |
74 reporting_info.metric_prefix = kMetricsName; | 76 reporting_info.metric_prefix = kMetricsName; |
75 ChromeMetricsHelper* chrome_metrics_helper = new ChromeMetricsHelper( | 77 ChromeMetricsHelper* chrome_metrics_helper = new ChromeMetricsHelper( |
76 web_contents, request_url, reporting_info, kMetricsName); | 78 web_contents, request_url, reporting_info, kMetricsName); |
77 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(false); | 79 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(false); |
78 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper( | 80 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper( |
79 chrome_metrics_helper); | 81 chrome_metrics_helper); |
80 controller_->set_metrics_helper(metrics_helper.Pass()); | 82 controller_->set_metrics_helper(std::move(metrics_helper)); |
81 | 83 |
82 cert_report_helper_.reset(new CertReportHelper( | 84 cert_report_helper_.reset(new CertReportHelper( |
83 ssl_cert_reporter.Pass(), web_contents, request_url, ssl_info, | 85 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, |
84 certificate_reporting::ErrorReport::INTERSTITIAL_CLOCK, | 86 certificate_reporting::ErrorReport::INTERSTITIAL_CLOCK, |
85 false /* overridable */, controller_->metrics_helper())); | 87 false /* overridable */, controller_->metrics_helper())); |
86 | 88 |
87 bad_clock_ui_.reset(new security_interstitials::BadClockUI( | 89 bad_clock_ui_.reset(new security_interstitials::BadClockUI( |
88 request_url, cert_error, ssl_info, time_triggered, languages, | 90 request_url, cert_error, ssl_info, time_triggered, languages, |
89 controller_.get())); | 91 controller_.get())); |
90 } | 92 } |
91 | 93 |
92 BadClockBlockingPage::~BadClockBlockingPage() { | 94 BadClockBlockingPage::~BadClockBlockingPage() { |
93 if (!callback_.is_null()) { | 95 if (!callback_.is_null()) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 sct_id, sct_and_status.status)); | 133 sct_id, sct_and_status.status)); |
132 } | 134 } |
133 | 135 |
134 entry->GetSSL() = | 136 entry->GetSSL() = |
135 content::SSLStatus(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, | 137 content::SSLStatus(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, |
136 sct_ids, ssl_info_); | 138 sct_ids, ssl_info_); |
137 } | 139 } |
138 | 140 |
139 void BadClockBlockingPage::SetSSLCertReporterForTesting( | 141 void BadClockBlockingPage::SetSSLCertReporterForTesting( |
140 scoped_ptr<SSLCertReporter> ssl_cert_reporter) { | 142 scoped_ptr<SSLCertReporter> ssl_cert_reporter) { |
141 cert_report_helper_->SetSSLCertReporterForTesting(ssl_cert_reporter.Pass()); | 143 cert_report_helper_->SetSSLCertReporterForTesting( |
| 144 std::move(ssl_cert_reporter)); |
142 } | 145 } |
143 | 146 |
144 // This handles the commands sent from the interstitial JavaScript. | 147 // This handles the commands sent from the interstitial JavaScript. |
145 void BadClockBlockingPage::CommandReceived(const std::string& command) { | 148 void BadClockBlockingPage::CommandReceived(const std::string& command) { |
146 if (command == "\"pageLoadComplete\"") { | 149 if (command == "\"pageLoadComplete\"") { |
147 // content::WaitForRenderFrameReady sends this message when the page | 150 // content::WaitForRenderFrameReady sends this message when the page |
148 // load completes. Ignore it. | 151 // load completes. Ignore it. |
149 return; | 152 return; |
150 } | 153 } |
151 | 154 |
(...skipping 21 matching lines...) Expand all Loading... |
173 | 176 |
174 void BadClockBlockingPage::NotifyDenyCertificate() { | 177 void BadClockBlockingPage::NotifyDenyCertificate() { |
175 // It's possible that callback_ may not exist if the user clicks "Proceed" | 178 // It's possible that callback_ may not exist if the user clicks "Proceed" |
176 // followed by pressing the back button before the interstitial is hidden. | 179 // followed by pressing the back button before the interstitial is hidden. |
177 // In that case the certificate will still be treated as allowed. | 180 // In that case the certificate will still be treated as allowed. |
178 if (callback_.is_null()) | 181 if (callback_.is_null()) |
179 return; | 182 return; |
180 | 183 |
181 base::ResetAndReturn(&callback_).Run(false); | 184 base::ResetAndReturn(&callback_).Run(false); |
182 } | 185 } |
OLD | NEW |