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

Side by Side Diff: ios/chrome/browser/ssl/ios_ssl_blocking_page.mm

Issue 2303413002: Simplify security_interstitials::ControllerClient and other related classes (Closed)
Patch Set: Rebase 2 Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ssl/ios_ssl_blocking_page.h" 5 #include "ios/chrome/browser/ssl/ios_ssl_blocking_page.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (overridable) { 58 if (overridable) {
59 UMA_HISTOGRAM_ENUMERATION( 59 UMA_HISTOGRAM_ENUMERATION(
60 "interstitial.ssl.expiration_and_decision.overridable", event, 60 "interstitial.ssl.expiration_and_decision.overridable", event,
61 END_OF_SSL_EXPIRATION_AND_DECISION); 61 END_OF_SSL_EXPIRATION_AND_DECISION);
62 } else { 62 } else {
63 UMA_HISTOGRAM_ENUMERATION( 63 UMA_HISTOGRAM_ENUMERATION(
64 "interstitial.ssl.expiration_and_decision.nonoverridable", event, 64 "interstitial.ssl.expiration_and_decision.nonoverridable", event,
65 END_OF_SSL_EXPIRATION_AND_DECISION); 65 END_OF_SSL_EXPIRATION_AND_DECISION);
66 } 66 }
67 } 67 }
68
69 IOSChromeMetricsHelper* CreateMetricsHelper(web::WebState* web_state,
70 const GURL& request_url,
71 bool overridable) {
72 // Set up the metrics helper for the SSLErrorUI.
73 security_interstitials::MetricsHelper::ReportDetails reporting_info;
74 reporting_info.metric_prefix =
75 overridable ? "ssl_overridable" : "ssl_nonoverridable";
76 reporting_info.rappor_prefix = kSSLRapporPrefix;
77 reporting_info.deprecated_rappor_prefix = kDeprecatedSSLRapporPrefix;
78 reporting_info.rappor_report_type = rappor::LOW_FREQUENCY_UMA_RAPPOR_TYPE;
79 reporting_info.deprecated_rappor_report_type = rappor::UMA_RAPPOR_TYPE;
80 return new IOSChromeMetricsHelper(web_state, request_url, reporting_info);
81 }
82
68 } // namespace 83 } // namespace
69 84
70 // Note that we always create a navigation entry with SSL errors. 85 // Note that we always create a navigation entry with SSL errors.
71 // No error happening loading a sub-resource triggers an interstitial so far. 86 // No error happening loading a sub-resource triggers an interstitial so far.
72 IOSSSLBlockingPage::IOSSSLBlockingPage( 87 IOSSSLBlockingPage::IOSSSLBlockingPage(
73 web::WebState* web_state, 88 web::WebState* web_state,
74 int cert_error, 89 int cert_error,
75 const net::SSLInfo& ssl_info, 90 const net::SSLInfo& ssl_info,
76 const GURL& request_url, 91 const GURL& request_url,
77 int options_mask, 92 int options_mask,
78 const base::Time& time_triggered, 93 const base::Time& time_triggered,
79 const base::Callback<void(bool)>& callback) 94 const base::Callback<void(bool)>& callback)
80 : IOSSecurityInterstitialPage(web_state, request_url), 95 : IOSSecurityInterstitialPage(web_state, request_url),
81 callback_(callback), 96 callback_(callback),
82 ssl_info_(ssl_info), 97 ssl_info_(ssl_info),
83 overridable_(IsOverridable(options_mask)), 98 overridable_(IsOverridable(options_mask)),
84 expired_but_previously_allowed_( 99 expired_but_previously_allowed_(
85 (options_mask & SSLErrorUI::EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), 100 (options_mask & SSLErrorUI::EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0),
86 controller_(new IOSChromeControllerClient(web_state)) { 101 controller_(new IOSChromeControllerClient(
102 web_state,
103 base::WrapUnique(CreateMetricsHelper(web_state,
104 request_url,
105 IsOverridable(options_mask))))) {
87 // Override prefs for the SSLErrorUI. 106 // Override prefs for the SSLErrorUI.
88 if (overridable_) 107 if (overridable_)
89 options_mask |= SSLErrorUI::SOFT_OVERRIDE_ENABLED; 108 options_mask |= SSLErrorUI::SOFT_OVERRIDE_ENABLED;
90 else 109 else
91 options_mask &= ~SSLErrorUI::SOFT_OVERRIDE_ENABLED; 110 options_mask &= ~SSLErrorUI::SOFT_OVERRIDE_ENABLED;
92 111
93 // Set up the metrics helper for the SSLErrorUI.
94 security_interstitials::MetricsHelper::ReportDetails reporting_info;
95 reporting_info.metric_prefix =
96 overridable_ ? "ssl_overridable" : "ssl_nonoverridable";
97 reporting_info.rappor_prefix = kSSLRapporPrefix;
98 reporting_info.deprecated_rappor_prefix = kDeprecatedSSLRapporPrefix;
99 reporting_info.rappor_report_type = rappor::LOW_FREQUENCY_UMA_RAPPOR_TYPE;
100 reporting_info.deprecated_rappor_report_type = rappor::UMA_RAPPOR_TYPE;
101 IOSChromeMetricsHelper* ios_chrome_metrics_helper =
102 new IOSChromeMetricsHelper(web_state, request_url, reporting_info);
103 controller_->set_metrics_helper(base::WrapUnique(ios_chrome_metrics_helper));
104
105 ssl_error_ui_.reset(new SSLErrorUI(request_url, cert_error, ssl_info, 112 ssl_error_ui_.reset(new SSLErrorUI(request_url, cert_error, ssl_info,
106 options_mask, time_triggered, 113 options_mask, time_triggered,
107 controller_.get())); 114 controller_.get()));
108 115
109 // Creating an interstitial without showing (e.g. from chrome://interstitials) 116 // Creating an interstitial without showing (e.g. from chrome://interstitials)
110 // it leaks memory, so don't create it here. 117 // it leaks memory, so don't create it here.
111 } 118 }
112 119
113 bool IOSSSLBlockingPage::ShouldCreateNewNavigation() const { 120 bool IOSSSLBlockingPage::ShouldCreateNewNavigation() const {
114 return true; 121 return true;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // In that case the certificate will still be treated as allowed. 211 // In that case the certificate will still be treated as allowed.
205 if (callback_.is_null()) 212 if (callback_.is_null())
206 return; 213 return;
207 214
208 callback_.Run(false); 215 callback_.Run(false);
209 callback_.Reset(); 216 callback_.Reset();
210 } 217 }
211 218
212 // static 219 // static
213 bool IOSSSLBlockingPage::IsOverridable(int options_mask) { 220 bool IOSSSLBlockingPage::IsOverridable(int options_mask) {
214 const bool is_overridable = 221 return (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) &&
215 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && 222 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT);
216 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT);
217 return is_overridable;
218 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698