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

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: mmenke comments 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) {
46 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
47 NOTREACHED();
48 #endif
49 RecordUMA(SHOW_ALL);
50 }
51
52 CaptivePortalBlockingPage::~CaptivePortalBlockingPage() {
53 }
54
55 const void* CaptivePortalBlockingPage::GetTypeForTesting() const {
56 return CaptivePortalBlockingPage::kTypeForTesting;
57 }
58
59 bool CaptivePortalBlockingPage::ShouldCreateNewNavigation() const {
60 return true;
61 }
62
63 void CaptivePortalBlockingPage::PopulateInterstitialStrings(
64 base::DictionaryValue* load_time_data) {
65 load_time_data->SetString("iconClass", "icon-offline");
66 load_time_data->SetString("type", "CAPTIVE_PORTAL");
67 load_time_data->SetBoolean("overridable", false);
68
69 load_time_data->SetString(
70 "primaryButtonText",
71 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE));
72 load_time_data->SetString("tabTitle",
73 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_TITLE));
74 load_time_data->SetString(
75 "primaryParagraph",
76 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH));
77 load_time_data->SetString("heading",
78 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_HEADING));
79
80 // Fill the empty strings to avoid getting debug warnings.
81 load_time_data->SetString("openDetails", base::string16());
82 load_time_data->SetString("closeDetails", base::string16());
83 load_time_data->SetString("explanationParagraph", base::string16());
84 load_time_data->SetString("finalParagraph", base::string16());
85 }
86
87 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) {
88 // The response has quotes around it.
89 if (command == std::string("\"") + kOpenLoginPageCommand + "\"") {
90 RecordUMA(OPEN_LOGIN_PAGE);
91 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
92 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true);
93 #endif
94 }
95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698