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

Unified 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: Remove unnecessary change Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/captive_portal_blocking_page.cc
diff --git a/chrome/browser/ssl/captive_portal_blocking_page.cc b/chrome/browser/ssl/captive_portal_blocking_page.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6989fd8d34bfbfb3814b14246c9e6b225ee7f143
--- /dev/null
+++ b/chrome/browser/ssl/captive_portal_blocking_page.cc
@@ -0,0 +1,86 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ssl/captive_portal_blocking_page.h"
+
+#include "base/metrics/histogram.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/web_contents.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
+#include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
+#endif
+
+namespace {
+
+// Events for UMA.
+enum CaptivePortalBlockingPageEvent {
+ SHOW_ALL,
+ OPEN_LOGIN_PAGE,
+ CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT
+};
+
+void RecordUMA(CaptivePortalBlockingPageEvent event) {
+ UMA_HISTOGRAM_ENUMERATION("interstitial.captive_portal",
+ event,
+ CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT);
+}
+
+} // namespace
+
+CaptivePortalBlockingPage::CaptivePortalBlockingPage(
+ content::WebContents* web_contents,
+ const GURL& request_url)
+ : SecurityInterstitialPage(web_contents, request_url) {
+ RecordUMA(SHOW_ALL);
+}
+
+CaptivePortalBlockingPage::~CaptivePortalBlockingPage() {
+}
+
+SecurityInterstitialPage::Type CaptivePortalBlockingPage::GetTypeForTesting()
+ 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.
+ return SecurityInterstitialPage::CAPTIVE_PORTAL;
+}
+
+bool CaptivePortalBlockingPage::ShouldCreateNewNavigation() const {
+ return true;
+}
+
+void CaptivePortalBlockingPage::PopulateLoadTimeData(
+ base::DictionaryValue* load_time_data) {
+
+ load_time_data->SetString("iconClass", "icon-offline");
+ load_time_data->SetString("type", "CAPTIVE_PORTAL");
+ load_time_data->SetBoolean("overridable", false);
+
+ load_time_data->SetString(
+ "primaryButtonText",
+ l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE));
+ load_time_data->SetString("tabTitle",
+ l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_TITLE));
+ load_time_data->SetString(
+ "primaryParagraph",
+ l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH));
+ load_time_data->SetString("heading",
+ l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_HEADING));
+
+ // Fill the empty strings to avoid getting debug warnings.
+ load_time_data->SetString("openDetails", base::string16());
+ load_time_data->SetString("closeDetails", base::string16());
+ load_time_data->SetString("explanationParagraph", base::string16());
+ load_time_data->SetString("finalParagraph", base::string16());
+}
+
+void CaptivePortalBlockingPage::CommandReceived(const std::string& command) {
+ // There is only one event on this page (Open login tab).
+ RecordUMA(OPEN_LOGIN_PAGE);
+#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
+ CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true);
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698