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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
29 | 29 |
30 using content::InterstitialPageDelegate; | 30 using content::InterstitialPageDelegate; |
31 using content::NavigationController; | 31 using content::NavigationController; |
32 using content::NavigationEntry; | 32 using content::NavigationEntry; |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 const char kMetricsName[] = "bad_clock"; | 36 const char kMetricsName[] = "bad_clock"; |
37 | 37 |
| 38 std::unique_ptr<ChromeMetricsHelper> CreateMetricsHelper( |
| 39 content::WebContents* web_contents, |
| 40 const GURL& request_url) { |
| 41 // Set up the metrics helper for the BadClockUI. |
| 42 security_interstitials::MetricsHelper::ReportDetails reporting_info; |
| 43 reporting_info.metric_prefix = kMetricsName; |
| 44 std::unique_ptr<ChromeMetricsHelper> metrics_helper = |
| 45 base::MakeUnique<ChromeMetricsHelper>(web_contents, request_url, |
| 46 reporting_info, kMetricsName); |
| 47 metrics_helper.get()->StartRecordingCaptivePortalMetrics(false); |
| 48 return metrics_helper; |
| 49 } |
| 50 |
38 } // namespace | 51 } // namespace |
39 | 52 |
40 // static | 53 // static |
41 InterstitialPageDelegate::TypeID BadClockBlockingPage::kTypeForTesting = | 54 InterstitialPageDelegate::TypeID BadClockBlockingPage::kTypeForTesting = |
42 &BadClockBlockingPage::kTypeForTesting; | 55 &BadClockBlockingPage::kTypeForTesting; |
43 | 56 |
44 // Note that we always create a navigation entry with SSL errors. | 57 // Note that we always create a navigation entry with SSL errors. |
45 // No error happening loading a sub-resource triggers an interstitial so far. | 58 // No error happening loading a sub-resource triggers an interstitial so far. |
46 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 59 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
47 // it leaks memory, so don't create it here. | 60 // it leaks memory, so don't create it here. |
48 BadClockBlockingPage::BadClockBlockingPage( | 61 BadClockBlockingPage::BadClockBlockingPage( |
49 content::WebContents* web_contents, | 62 content::WebContents* web_contents, |
50 int cert_error, | 63 int cert_error, |
51 const net::SSLInfo& ssl_info, | 64 const net::SSLInfo& ssl_info, |
52 const GURL& request_url, | 65 const GURL& request_url, |
53 const base::Time& time_triggered, | 66 const base::Time& time_triggered, |
54 ssl_errors::ClockState clock_state, | 67 ssl_errors::ClockState clock_state, |
55 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 68 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
56 const base::Callback<void(content::CertificateRequestResultType)>& callback) | 69 const base::Callback<void(content::CertificateRequestResultType)>& callback) |
57 : SecurityInterstitialPage(web_contents, request_url), | 70 : SecurityInterstitialPage(web_contents, |
| 71 request_url, |
| 72 CreateMetricsHelper(web_contents, request_url)), |
58 callback_(callback), | 73 callback_(callback), |
59 ssl_info_(ssl_info), | 74 ssl_info_(ssl_info), |
60 time_triggered_(time_triggered) { | 75 time_triggered_(time_triggered) { |
61 // Set up the metrics helper for the BadClockUI. | |
62 security_interstitials::MetricsHelper::ReportDetails reporting_info; | |
63 reporting_info.metric_prefix = kMetricsName; | |
64 ChromeMetricsHelper* chrome_metrics_helper = new ChromeMetricsHelper( | |
65 web_contents, request_url, reporting_info, kMetricsName); | |
66 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(false); | |
67 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper( | |
68 chrome_metrics_helper); | |
69 controller()->set_metrics_helper(std::move(metrics_helper)); | |
70 | |
71 cert_report_helper_.reset(new CertReportHelper( | 76 cert_report_helper_.reset(new CertReportHelper( |
72 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, | 77 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, |
73 certificate_reporting::ErrorReport::INTERSTITIAL_CLOCK, | 78 certificate_reporting::ErrorReport::INTERSTITIAL_CLOCK, |
74 false /* overridable */, controller()->metrics_helper())); | 79 false /* overridable */, controller()->metrics_helper())); |
75 | 80 |
76 bad_clock_ui_.reset(new security_interstitials::BadClockUI( | 81 bad_clock_ui_.reset(new security_interstitials::BadClockUI( |
77 request_url, cert_error, ssl_info, time_triggered, clock_state, | 82 request_url, cert_error, ssl_info, time_triggered, clock_state, |
78 controller())); | 83 controller())); |
79 } | 84 } |
80 | 85 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 void BadClockBlockingPage::NotifyDenyCertificate() { | 149 void BadClockBlockingPage::NotifyDenyCertificate() { |
145 // It's possible that callback_ may not exist if the user clicks "Proceed" | 150 // It's possible that callback_ may not exist if the user clicks "Proceed" |
146 // followed by pressing the back button before the interstitial is hidden. | 151 // followed by pressing the back button before the interstitial is hidden. |
147 // In that case the certificate will still be treated as allowed. | 152 // In that case the certificate will still be treated as allowed. |
148 if (callback_.is_null()) | 153 if (callback_.is_null()) |
149 return; | 154 return; |
150 | 155 |
151 base::ResetAndReturn(&callback_) | 156 base::ResetAndReturn(&callback_) |
152 .Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); | 157 .Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); |
153 } | 158 } |
OLD | NEW |