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

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, add login scenario to browser tests and fix race. 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 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
mmenke 2014/11/26 18:57:48 nit: Remove blank line
meacer 2014/12/08 22:29:50 Done.
63 load_time_data->SetString("iconClass", "icon-offline");
64 load_time_data->SetString("type", "CAPTIVE_PORTAL");
65 load_time_data->SetBoolean("overridable", false);
66
67 load_time_data->SetString(
68 "primaryButtonText",
69 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE));
70 load_time_data->SetString("tabTitle",
71 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_TITLE));
72 load_time_data->SetString(
73 "primaryParagraph",
74 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH));
75 load_time_data->SetString("heading",
76 l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_HEADING));
77
78 // Fill the empty strings to avoid getting debug warnings.
79 load_time_data->SetString("openDetails", base::string16());
80 load_time_data->SetString("closeDetails", base::string16());
81 load_time_data->SetString("explanationParagraph", base::string16());
82 load_time_data->SetString("finalParagraph", base::string16());
mmenke 2014/11/26 18:57:48 If you us jscontent=blah rather than i18n-values="
meacer 2014/12/08 22:29:50 We'll be refactoring the interstitials further in
83 }
84
85 void CaptivePortalBlockingPage::CommandReceived(const std::string& command) {
86 // The response has quotes around it.
87 if (command == std::string("\"") + kOpenLoginPageCommand + "\"") {
88 RecordUMA(OPEN_LOGIN_PAGE);
89 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
90 CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true);
91 #endif
92 }
93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698