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

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

Powered by Google App Engine
This is Rietveld 408576698