Chromium Code Reviews| 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 |
| +} |