OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/captive_portal_blocking_page.h" | 5 #include "chrome/browser/ssl/captive_portal_blocking_page.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 14 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ssl/cert_report_helper.h" | 16 #include "chrome/browser/ssl/cert_report_helper.h" |
17 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 17 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "components/captive_portal/captive_portal_detector.h" | 19 #include "components/captive_portal/captive_portal_detector.h" |
20 #include "components/certificate_reporting/error_reporter.h" | 20 #include "components/certificate_reporting/error_reporter.h" |
| 21 #include "components/security_interstitials/core/controller_client.h" |
21 #include "components/url_formatter/url_formatter.h" | 22 #include "components/url_formatter/url_formatter.h" |
22 #include "components/wifi/wifi_service.h" | 23 #include "components/wifi/wifi_service.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
25 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
26 #include "net/base/network_change_notifier.h" | 27 #include "net/base/network_change_notifier.h" |
27 #include "net/base/network_interfaces.h" | 28 #include "net/base/network_interfaces.h" |
28 #include "net/ssl/ssl_info.h" | 29 #include "net/ssl/ssl_info.h" |
29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
30 | 31 |
| 32 using security_interstitials::ControllerClient; |
| 33 |
31 namespace { | 34 namespace { |
32 | 35 |
33 // Events for UMA. | 36 // Events for UMA. |
34 enum CaptivePortalBlockingPageEvent { | 37 enum CaptivePortalBlockingPageEvent { |
35 SHOW_ALL, | 38 SHOW_ALL, |
36 OPEN_LOGIN_PAGE, | 39 OPEN_LOGIN_PAGE, |
37 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT | 40 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT |
38 }; | 41 }; |
39 | 42 |
40 void RecordUMA(CaptivePortalBlockingPageEvent event) { | 43 void RecordUMA(CaptivePortalBlockingPageEvent event) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 load_time_data->SetString("primaryParagraph", paragraph); | 179 load_time_data->SetString("primaryParagraph", paragraph); |
177 // Explicitly specify other expected fields to empty. | 180 // Explicitly specify other expected fields to empty. |
178 load_time_data->SetString("openDetails", base::string16()); | 181 load_time_data->SetString("openDetails", base::string16()); |
179 load_time_data->SetString("closeDetails", base::string16()); | 182 load_time_data->SetString("closeDetails", base::string16()); |
180 load_time_data->SetString("explanationParagraph", base::string16()); | 183 load_time_data->SetString("explanationParagraph", base::string16()); |
181 load_time_data->SetString("finalParagraph", base::string16()); | 184 load_time_data->SetString("finalParagraph", base::string16()); |
182 | 185 |
183 if (cert_report_helper_) | 186 if (cert_report_helper_) |
184 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); | 187 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); |
185 else | 188 else |
186 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, false); | 189 load_time_data->SetBoolean(security_interstitials::kDisplayCheckBox, false); |
187 } | 190 } |
188 | 191 |
189 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) { | 192 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) { |
190 if (command == "\"pageLoadComplete\"") { | 193 if (command == "\"pageLoadComplete\"") { |
191 // content::WaitForRenderFrameReady sends this message when the page | 194 // content::WaitForRenderFrameReady sends this message when the page |
192 // load completes. Ignore it. | 195 // load completes. Ignore it. |
193 return; | 196 return; |
194 } | 197 } |
195 int command_num = 0; | 198 int command_num = 0; |
196 bool command_is_num = base::StringToInt(command, &command_num); | 199 bool command_is_num = base::StringToInt(command, &command_num); |
197 DCHECK(command_is_num) << command; | 200 DCHECK(command_is_num) << command; |
198 // Any command other than "open the login page" is ignored. | 201 // Any command other than "open the login page" is ignored. |
199 if (command_num == CMD_OPEN_LOGIN) { | 202 if (command_num == ControllerClient::CMD_OPEN_LOGIN) { |
200 RecordUMA(OPEN_LOGIN_PAGE); | 203 RecordUMA(OPEN_LOGIN_PAGE); |
201 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true); | 204 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true); |
202 } | 205 } |
203 } | 206 } |
204 | 207 |
205 void CaptivePortalBlockingPage::OnProceed() { | 208 void CaptivePortalBlockingPage::OnProceed() { |
206 if (cert_report_helper_) { | 209 if (cert_report_helper_) { |
207 // Finish collecting information about invalid certificates, if the | 210 // Finish collecting information about invalid certificates, if the |
208 // user opted in to. | 211 // user opted in to. |
209 cert_report_helper_->FinishCertCollection( | 212 cert_report_helper_->FinishCertCollection( |
210 certificate_reporting::ErrorReport::USER_PROCEEDED); | 213 certificate_reporting::ErrorReport::USER_PROCEEDED); |
211 } | 214 } |
212 } | 215 } |
213 | 216 |
214 void CaptivePortalBlockingPage::OnDontProceed() { | 217 void CaptivePortalBlockingPage::OnDontProceed() { |
215 if (cert_report_helper_) { | 218 if (cert_report_helper_) { |
216 // Finish collecting information about invalid certificates, if the | 219 // Finish collecting information about invalid certificates, if the |
217 // user opted in to. | 220 // user opted in to. |
218 cert_report_helper_->FinishCertCollection( | 221 cert_report_helper_->FinishCertCollection( |
219 certificate_reporting::ErrorReport::USER_DID_NOT_PROCEED); | 222 certificate_reporting::ErrorReport::USER_DID_NOT_PROCEED); |
220 } | 223 } |
221 | 224 |
222 // Need to explicity deny the certificate via the callback, otherwise memory | 225 // Need to explicity deny the certificate via the callback, otherwise memory |
223 // is leaked. | 226 // is leaked. |
224 if (!callback_.is_null()) { | 227 if (!callback_.is_null()) { |
225 callback_.Run(false); | 228 callback_.Run(false); |
226 callback_.Reset(); | 229 callback_.Reset(); |
227 } | 230 } |
228 } | 231 } |
OLD | NEW |