Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/ssl/bad_clock_blocking_page.cc

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

Powered by Google App Engine
This is Rietveld 408576698