OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ssl/captive_portal_blocking_page.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "base/values.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "content/public/browser/web_contents.h" | |
12 #include "grit/generated_resources.h" | |
13 #include "ui/base/l10n/l10n_util.h" | |
14 | |
15 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
16 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | |
17 #endif | |
18 | |
19 namespace { | |
20 | |
21 // Events for UMA. | |
22 enum CaptivePortalBlockingPageEvent { | |
23 SHOW_ALL, | |
24 OPEN_LOGIN_PAGE, | |
25 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT | |
26 }; | |
27 | |
28 void RecordUMA(CaptivePortalBlockingPageEvent event) { | |
29 UMA_HISTOGRAM_ENUMERATION("interstitial.captive_portal", | |
30 event, | |
31 CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT); | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 CaptivePortalBlockingPage::CaptivePortalBlockingPage( | |
37 content::WebContents* web_contents, | |
38 const GURL& request_url) | |
39 : SecurityInterstitialPage(web_contents, request_url) { | |
40 RecordUMA(SHOW_ALL); | |
41 } | |
42 | |
43 CaptivePortalBlockingPage::~CaptivePortalBlockingPage() { | |
44 } | |
45 | |
46 SecurityInterstitialPage::Type CaptivePortalBlockingPage::GetTypeForTesting() | |
47 const { | |
mmenke
2014/10/30 19:28:01
nit: const should go on same line as close paren,
meacer
2014/11/06 21:21:55
Done.
| |
48 return SecurityInterstitialPage::CAPTIVE_PORTAL; | |
49 } | |
50 | |
51 bool CaptivePortalBlockingPage::ShouldCreateNewNavigation() const { | |
52 return true; | |
53 } | |
54 | |
55 void CaptivePortalBlockingPage::PopulateLoadTimeData( | |
56 base::DictionaryValue* load_time_data) { | |
57 | |
58 load_time_data->SetString("iconClass", "icon-offline"); | |
59 load_time_data->SetString("type", "CAPTIVE_PORTAL"); | |
60 load_time_data->SetBoolean("overridable", false); | |
61 | |
62 load_time_data->SetString( | |
63 "primaryButtonText", | |
64 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE)); | |
65 load_time_data->SetString("tabTitle", | |
66 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_TITLE)); | |
67 load_time_data->SetString( | |
68 "primaryParagraph", | |
69 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH)); | |
70 load_time_data->SetString("heading", | |
71 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_HEADING)); | |
72 | |
73 // Fill the empty strings to avoid getting debug warnings. | |
74 load_time_data->SetString("openDetails", base::string16()); | |
75 load_time_data->SetString("closeDetails", base::string16()); | |
76 load_time_data->SetString("explanationParagraph", base::string16()); | |
77 load_time_data->SetString("finalParagraph", base::string16()); | |
78 } | |
79 | |
80 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) { | |
81 // There is only one event on this page (Open login tab). | |
82 RecordUMA(OPEN_LOGIN_PAGE); | |
83 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
mmenke
2014/10/30 19:28:01
Can we just not include this file when it's not en
| |
84 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true); | |
85 #endif | |
86 } | |
OLD | NEW |