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"
20 // This class is responsible for showing/hiding the interstitial page that is
21 // shown when a captive portal triggers an SSL error.
22 // It deletes itself when the interstitial page is closed.
24 // This class should only be used on the UI thread because its implementation
25 // uses captive_portal::CaptivePortalService, which can only be accessed on the
26 // UI thread. Only used when ENABLE_CAPTIVE_PORTAL_DETECTION is true.
27 class CaptivePortalBlockingPage
: public SecurityInterstitialPage
{
29 // Interstitial type, for testing.
30 static const void* kTypeForTesting
;
34 virtual ~Delegate() {}
36 // Returns true if the connection is a Wi-Fi connection.
37 virtual bool IsWifiConnection() const = 0;
38 // Returns the SSID of the connected Wi-Fi network, if any.
39 virtual std::string
GetWiFiSSID() const = 0;
42 CaptivePortalBlockingPage(content::WebContents
* web_contents
,
43 const GURL
& request_url
,
44 const GURL
& login_url
,
45 const base::Callback
<void(bool)>& callback
);
46 ~CaptivePortalBlockingPage() override
;
48 // SecurityInterstitialPage method:
49 const void* GetTypeForTesting() const override
;
51 void SetDelegateForTesting(Delegate
* delegate
) { delegate_
.reset(delegate
); }
54 // SecurityInterstitialPage methods:
55 void PopulateInterstitialStrings(
56 base::DictionaryValue
* load_time_data
) override
;
57 bool ShouldCreateNewNavigation() const override
;
59 // InterstitialPageDelegate method:
60 void CommandReceived(const std::string
& command
) override
;
63 // URL of the login page, opened when the user clicks the "Connect" button.
65 scoped_ptr
<Delegate
> delegate_
;
66 base::Callback
<void(bool)> callback_
;
68 DISALLOW_COPY_AND_ASSIGN(CaptivePortalBlockingPage
);
71 #endif // CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_