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.
5 #ifndef CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_
6 #define CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/interstitials/security_interstitial_page.h"
16 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
17 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag.
28 class CertReportHelper
;
29 class SSLCertReporter
;
31 // This class is responsible for showing/hiding the interstitial page that is
32 // shown when a captive portal triggers an SSL error.
33 // It deletes itself when the interstitial page is closed.
35 // This class should only be used on the UI thread because its implementation
36 // uses captive_portal::CaptivePortalService, which can only be accessed on the
37 // UI thread. Only used when ENABLE_CAPTIVE_PORTAL_DETECTION is true.
38 class CaptivePortalBlockingPage
: public SecurityInterstitialPage
{
40 // Interstitial type, for testing.
41 static const void* const kTypeForTesting
;
43 CaptivePortalBlockingPage(content::WebContents
* web_contents
,
44 const GURL
& request_url
,
45 const GURL
& login_url
,
46 scoped_ptr
<SSLCertReporter
> ssl_cert_reporter
,
47 const net::SSLInfo
& ssl_info
,
48 const base::Callback
<void(bool)>& callback
);
49 ~CaptivePortalBlockingPage() override
;
51 // InterstitialPageDelegate method:
52 const void* GetTypeForTesting() const override
;
55 // Returns true if the connection is a Wi-Fi connection. Virtual for tests.
56 virtual bool IsWifiConnection() const;
57 // Returns the SSID of the connected Wi-Fi network, if any. Virtual for tests.
58 virtual std::string
GetWiFiSSID() const;
60 // SecurityInterstitialPage methods:
61 bool ShouldCreateNewNavigation() const override
;
62 void PopulateInterstitialStrings(
63 base::DictionaryValue
* load_time_data
) override
;
65 // InterstitialPageDelegate method:
66 void CommandReceived(const std::string
& command
) override
;
67 void OnProceed() override
;
68 void OnDontProceed() override
;
71 // URL of the login page, opened when the user clicks the "Connect" button.
72 const GURL login_url_
;
73 scoped_ptr
<CertReportHelper
> cert_report_helper_
;
74 base::Callback
<void(bool)> callback_
;
76 DISALLOW_COPY_AND_ASSIGN(CaptivePortalBlockingPage
);
79 #endif // CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_