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 "chrome/common/pref_names.h" | |
18 #include "components/prefs/pref_service.h" | |
19 #include "components/security_interstitials/core/bad_clock_ui.h" | 17 #include "components/security_interstitials/core/bad_clock_ui.h" |
20 #include "components/security_interstitials/core/controller_client.h" | 18 #include "components/security_interstitials/core/controller_client.h" |
21 #include "components/security_interstitials/core/metrics_helper.h" | 19 #include "components/security_interstitials/core/metrics_helper.h" |
22 #include "content/public/browser/cert_store.h" | 20 #include "content/public/browser/cert_store.h" |
23 #include "content/public/browser/interstitial_page.h" | 21 #include "content/public/browser/interstitial_page.h" |
24 #include "content/public/browser/interstitial_page_delegate.h" | 22 #include "content/public/browser/interstitial_page_delegate.h" |
25 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
27 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
28 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
(...skipping 28 matching lines...) Expand all Loading... |
57 const GURL& request_url, | 55 const GURL& request_url, |
58 const base::Time& time_triggered, | 56 const base::Time& time_triggered, |
59 ssl_errors::ClockState clock_state, | 57 ssl_errors::ClockState clock_state, |
60 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 58 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
61 const base::Callback<void(bool)>& callback) | 59 const base::Callback<void(bool)>& callback) |
62 : SecurityInterstitialPage(web_contents, request_url), | 60 : SecurityInterstitialPage(web_contents, request_url), |
63 callback_(callback), | 61 callback_(callback), |
64 ssl_info_(ssl_info), | 62 ssl_info_(ssl_info), |
65 time_triggered_(time_triggered), | 63 time_triggered_(time_triggered), |
66 controller_(new ChromeControllerClient(web_contents)) { | 64 controller_(new ChromeControllerClient(web_contents)) { |
67 // Get the language for the BadClockUI. | |
68 std::string languages; | |
69 Profile* profile = | |
70 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
71 if (profile) | |
72 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | |
73 | 65 |
74 // Set up the metrics helper for the BadClockUI. | 66 // Set up the metrics helper for the BadClockUI. |
75 security_interstitials::MetricsHelper::ReportDetails reporting_info; | 67 security_interstitials::MetricsHelper::ReportDetails reporting_info; |
76 reporting_info.metric_prefix = kMetricsName; | 68 reporting_info.metric_prefix = kMetricsName; |
77 ChromeMetricsHelper* chrome_metrics_helper = new ChromeMetricsHelper( | 69 ChromeMetricsHelper* chrome_metrics_helper = new ChromeMetricsHelper( |
78 web_contents, request_url, reporting_info, kMetricsName); | 70 web_contents, request_url, reporting_info, kMetricsName); |
79 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(false); | 71 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(false); |
80 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper( | 72 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper( |
81 chrome_metrics_helper); | 73 chrome_metrics_helper); |
82 controller_->set_metrics_helper(std::move(metrics_helper)); | 74 controller_->set_metrics_helper(std::move(metrics_helper)); |
83 | 75 |
84 cert_report_helper_.reset(new CertReportHelper( | 76 cert_report_helper_.reset(new CertReportHelper( |
85 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, | 77 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, |
86 certificate_reporting::ErrorReport::INTERSTITIAL_CLOCK, | 78 certificate_reporting::ErrorReport::INTERSTITIAL_CLOCK, |
87 false /* overridable */, controller_->metrics_helper())); | 79 false /* overridable */, controller_->metrics_helper())); |
88 | 80 |
89 bad_clock_ui_.reset(new security_interstitials::BadClockUI( | 81 bad_clock_ui_.reset(new security_interstitials::BadClockUI( |
90 request_url, cert_error, ssl_info, time_triggered, clock_state, languages, | 82 request_url, cert_error, ssl_info, time_triggered, clock_state, |
91 controller_.get())); | 83 controller_.get())); |
92 } | 84 } |
93 | 85 |
94 BadClockBlockingPage::~BadClockBlockingPage() { | 86 BadClockBlockingPage::~BadClockBlockingPage() { |
95 if (!callback_.is_null()) { | 87 if (!callback_.is_null()) { |
96 // Deny when the page is closed. | 88 // Deny when the page is closed. |
97 NotifyDenyCertificate(); | 89 NotifyDenyCertificate(); |
98 } | 90 } |
99 } | 91 } |
100 | 92 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 168 |
177 void BadClockBlockingPage::NotifyDenyCertificate() { | 169 void BadClockBlockingPage::NotifyDenyCertificate() { |
178 // It's possible that callback_ may not exist if the user clicks "Proceed" | 170 // It's possible that callback_ may not exist if the user clicks "Proceed" |
179 // followed by pressing the back button before the interstitial is hidden. | 171 // followed by pressing the back button before the interstitial is hidden. |
180 // In that case the certificate will still be treated as allowed. | 172 // In that case the certificate will still be treated as allowed. |
181 if (callback_.is_null()) | 173 if (callback_.is_null()) |
182 return; | 174 return; |
183 | 175 |
184 base::ResetAndReturn(&callback_).Run(false); | 176 base::ResetAndReturn(&callback_).Run(false); |
185 } | 177 } |
OLD | NEW |