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

Side by Side Diff: chrome/browser/ssl/captive_portal_blocking_page.cc

Issue 318213002: Add custom interstitial for captive portals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Expand browser tests Created 6 years 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 | Annotate | Revision Log
OLDNEW
(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 const char kOpenLoginPageCommand[] = "openLoginPage";
35
36 } // namespace
37
38 // static
39 const void* CaptivePortalBlockingPage::kTypeForTesting =
40 &CaptivePortalBlockingPage::kTypeForTesting;
41
42 CaptivePortalBlockingPage::CaptivePortalBlockingPage(
43 content::WebContents* web_contents,
44 const GURL& request_url)
45 : SecurityInterstitialPage(web_contents, request_url) {
mmenke 2014/12/09 22:42:26 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) NOTRE
meacer 2014/12/10 22:48:02 Done.
46 RecordUMA(SHOW_ALL);
47 }
48
49 CaptivePortalBlockingPage::~CaptivePortalBlockingPage() {
50 }
51
52 const void* CaptivePortalBlockingPage::GetTypeForTesting() const {
53 return CaptivePortalBlockingPage::kTypeForTesting;
54 }
55
56 bool CaptivePortalBlockingPage::ShouldCreateNewNavigation() const {
57 return true;
58 }
59
60 void CaptivePortalBlockingPage::PopulateInterstitialStrings(
61 base::DictionaryValue* load_time_data) {
62 load_time_data->SetString("iconClass", "icon-offline");
63 load_time_data->SetString("type", "CAPTIVE_PORTAL");
64 load_time_data->SetBoolean("overridable", false);
65
66 load_time_data->SetString(
67 "primaryButtonText",
68 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE));
69 load_time_data->SetString("tabTitle",
70 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_TITLE));
71 load_time_data->SetString(
72 "primaryParagraph",
73 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH));
74 load_time_data->SetString("heading",
75 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_HEADING));
76
77 // Fill the empty strings to avoid getting debug warnings.
78 load_time_data->SetString("openDetails", base::string16());
79 load_time_data->SetString("closeDetails", base::string16());
80 load_time_data->SetString("explanationParagraph", base::string16());
81 load_time_data->SetString("finalParagraph", base::string16());
82 }
83
84 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) {
85 // The response has quotes around it.
86 if (command == std::string("\"") + kOpenLoginPageCommand + "\"") {
87 RecordUMA(OPEN_LOGIN_PAGE);
88 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
89 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true);
90 #endif
91 }
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698