OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const base::Callback<void(bool)>& callback) | 116 const base::Callback<void(bool)>& callback) |
117 : SecurityInterstitialPage(web_contents, request_url), | 117 : SecurityInterstitialPage(web_contents, request_url), |
118 callback_(callback), | 118 callback_(callback), |
119 ssl_info_(ssl_info), | 119 ssl_info_(ssl_info), |
120 overridable_(IsOverridable( | 120 overridable_(IsOverridable( |
121 options_mask, | 121 options_mask, |
122 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 122 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
123 expired_but_previously_allowed_( | 123 expired_but_previously_allowed_( |
124 (options_mask & SSLErrorUI::EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), | 124 (options_mask & SSLErrorUI::EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), |
125 controller_(new ChromeControllerClient(web_contents)) { | 125 controller_(new ChromeControllerClient(web_contents)) { |
126 // Get the language and override prefs for the SSLErrorUI. | 126 // Override prefs for the SSLErrorUI. |
127 std::string languages; | |
128 Profile* profile = | 127 Profile* profile = |
129 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 128 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
130 if (profile) { | 129 if (profile && |
131 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 130 !profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed)) { |
132 if (!profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed)) { | 131 options_mask |= SSLErrorUI::HARD_OVERRIDE_DISABLED; |
133 options_mask |= SSLErrorUI::HARD_OVERRIDE_DISABLED; | |
134 } | |
135 } | 132 } |
136 if (overridable_) | 133 if (overridable_) |
137 options_mask |= SSLErrorUI::SOFT_OVERRIDE_ENABLED; | 134 options_mask |= SSLErrorUI::SOFT_OVERRIDE_ENABLED; |
138 else | 135 else |
139 options_mask &= ~SSLErrorUI::SOFT_OVERRIDE_ENABLED; | 136 options_mask &= ~SSLErrorUI::SOFT_OVERRIDE_ENABLED; |
140 | 137 |
141 // Set up the metrics helper for the SSLErrorUI. | 138 // Set up the metrics helper for the SSLErrorUI. |
142 security_interstitials::MetricsHelper::ReportDetails reporting_info; | 139 security_interstitials::MetricsHelper::ReportDetails reporting_info; |
143 reporting_info.metric_prefix = | 140 reporting_info.metric_prefix = |
144 overridable_ ? "ssl_overridable" : "ssl_nonoverridable"; | 141 overridable_ ? "ssl_overridable" : "ssl_nonoverridable"; |
145 reporting_info.rappor_prefix = kSSLRapporPrefix; | 142 reporting_info.rappor_prefix = kSSLRapporPrefix; |
146 reporting_info.rappor_report_type = rappor::UMA_RAPPOR_TYPE; | 143 reporting_info.rappor_report_type = rappor::UMA_RAPPOR_TYPE; |
147 ChromeMetricsHelper* chrome_metrics_helper = | 144 ChromeMetricsHelper* chrome_metrics_helper = |
148 new ChromeMetricsHelper(web_contents, request_url, reporting_info, | 145 new ChromeMetricsHelper(web_contents, request_url, reporting_info, |
149 GetSamplingEventName(overridable_, cert_error)); | 146 GetSamplingEventName(overridable_, cert_error)); |
150 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(overridable_); | 147 chrome_metrics_helper->StartRecordingCaptivePortalMetrics(overridable_); |
151 controller_->set_metrics_helper(make_scoped_ptr(chrome_metrics_helper)); | 148 controller_->set_metrics_helper(make_scoped_ptr(chrome_metrics_helper)); |
152 | 149 |
153 cert_report_helper_.reset(new CertReportHelper( | 150 cert_report_helper_.reset(new CertReportHelper( |
154 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, | 151 std::move(ssl_cert_reporter), web_contents, request_url, ssl_info, |
155 certificate_reporting::ErrorReport::INTERSTITIAL_SSL, overridable_, | 152 certificate_reporting::ErrorReport::INTERSTITIAL_SSL, overridable_, |
156 controller_->metrics_helper())); | 153 controller_->metrics_helper())); |
157 | 154 |
158 ssl_error_ui_.reset(new SSLErrorUI(request_url, cert_error, ssl_info, | 155 ssl_error_ui_.reset(new SSLErrorUI(request_url, cert_error, ssl_info, |
159 options_mask, time_triggered, languages, | 156 options_mask, time_triggered, |
160 controller_.get())); | 157 controller_.get())); |
161 | 158 |
162 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 159 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
163 // it leaks memory, so don't create it here. | 160 // it leaks memory, so don't create it here. |
164 } | 161 } |
165 | 162 |
166 bool SSLBlockingPage::ShouldCreateNewNavigation() const { | 163 bool SSLBlockingPage::ShouldCreateNewNavigation() const { |
167 return true; | 164 return true; |
168 } | 165 } |
169 | 166 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 274 |
278 // static | 275 // static |
279 bool SSLBlockingPage::IsOverridable(int options_mask, | 276 bool SSLBlockingPage::IsOverridable(int options_mask, |
280 const Profile* const profile) { | 277 const Profile* const profile) { |
281 const bool is_overridable = | 278 const bool is_overridable = |
282 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && | 279 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && |
283 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT) && | 280 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT) && |
284 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 281 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
285 return is_overridable; | 282 return is_overridable; |
286 } | 283 } |
OLD | NEW |