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_util.h" | 11 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 14 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "components/captive_portal/captive_portal_detector.h" | 17 #include "components/captive_portal/captive_portal_detector.h" |
17 #include "components/wifi/wifi_service.h" | 18 #include "components/wifi/wifi_service.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
21 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 | 24 |
24 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 25 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
25 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag. | 26 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag. |
26 #endif | 27 #endif |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // Events for UMA. | 31 // Events for UMA. |
31 enum CaptivePortalBlockingPageEvent { | 32 enum CaptivePortalBlockingPageEvent { |
32 SHOW_ALL, | 33 SHOW_ALL, |
33 OPEN_LOGIN_PAGE, | 34 OPEN_LOGIN_PAGE, |
34 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT | 35 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT |
35 }; | 36 }; |
36 | 37 |
37 const char kOpenLoginPageCommand[] = "openLoginPage"; | |
38 | |
39 void RecordUMA(CaptivePortalBlockingPageEvent event) { | 38 void RecordUMA(CaptivePortalBlockingPageEvent event) { |
40 UMA_HISTOGRAM_ENUMERATION("interstitial.captive_portal", | 39 UMA_HISTOGRAM_ENUMERATION("interstitial.captive_portal", |
41 event, | 40 event, |
42 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT); | 41 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT); |
43 } | 42 } |
44 | 43 |
45 class ConnectionInfoDelegate : public CaptivePortalBlockingPage::Delegate { | 44 class ConnectionInfoDelegate : public CaptivePortalBlockingPage::Delegate { |
46 public: | 45 public: |
47 ConnectionInfoDelegate() {} | 46 ConnectionInfoDelegate() {} |
48 ~ConnectionInfoDelegate() override {} | 47 ~ConnectionInfoDelegate() override {} |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 } | 184 } |
186 | 185 |
187 // Fill the empty strings to avoid getting debug warnings. | 186 // Fill the empty strings to avoid getting debug warnings. |
188 load_time_data->SetString("openDetails", base::string16()); | 187 load_time_data->SetString("openDetails", base::string16()); |
189 load_time_data->SetString("closeDetails", base::string16()); | 188 load_time_data->SetString("closeDetails", base::string16()); |
190 load_time_data->SetString("explanationParagraph", base::string16()); | 189 load_time_data->SetString("explanationParagraph", base::string16()); |
191 load_time_data->SetString("finalParagraph", base::string16()); | 190 load_time_data->SetString("finalParagraph", base::string16()); |
192 } | 191 } |
193 | 192 |
194 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) { | 193 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) { |
195 // The response has quotes around it. | 194 int cmd = 0; |
196 if (command == std::string("\"") + kOpenLoginPageCommand + "\"") { | 195 bool retval = base::StringToInt(command, &cmd); |
meacer
2015/03/06 18:29:22
|command| has quotes around it (e.g. "1"), need to
meacer
2015/03/07 01:00:04
Correction: |command| shouldn't normally have quot
felt
2015/03/07 04:02:39
Done.
| |
196 DCHECK(retval); | |
197 | |
198 if (cmd == CMD_OPEN_LOGIN) { | |
197 RecordUMA(OPEN_LOGIN_PAGE); | 199 RecordUMA(OPEN_LOGIN_PAGE); |
198 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true); | 200 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true); |
199 } | 201 } |
200 } | 202 } |
OLD | NEW |