Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / ssl / captive_portal_blocking_page.h
blob1432d2f22a721a7691ad7b9fff757e753189cf11
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_
8 #include <string>
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"
14 #include "url/gurl.h"
16 namespace content{
17 class WebContents;
20 namespace net {
21 class SSLInfo;
24 class CertReportHelper;
25 class SSLCertReporter;
27 // This class is responsible for showing/hiding the interstitial page that is
28 // shown when a captive portal triggers an SSL error.
29 // It deletes itself when the interstitial page is closed.
31 // This class should only be used on the UI thread because its implementation
32 // uses captive_portal::CaptivePortalService, which can only be accessed on the
33 // UI thread. Only used when ENABLE_CAPTIVE_PORTAL_DETECTION is true.
34 class CaptivePortalBlockingPage : public SecurityInterstitialPage {
35 public:
36 // Interstitial type, for testing.
37 static const void* kTypeForTesting;
39 class Delegate {
40 public:
41 virtual ~Delegate() {}
43 // Returns true if the connection is a Wi-Fi connection.
44 virtual bool IsWifiConnection() const = 0;
45 // Returns the SSID of the connected Wi-Fi network, if any.
46 virtual std::string GetWiFiSSID() const = 0;
49 CaptivePortalBlockingPage(content::WebContents* web_contents,
50 const GURL& request_url,
51 const GURL& login_url,
52 scoped_ptr<SSLCertReporter> ssl_cert_reporter,
53 const net::SSLInfo& ssl_info,
54 const base::Callback<void(bool)>& callback);
55 ~CaptivePortalBlockingPage() override;
57 // SecurityInterstitialPage method:
58 const void* GetTypeForTesting() const override;
60 // Should only be used for testing and chrome://interstitials page.
61 void SetDelegate(Delegate* delegate) { delegate_.reset(delegate); }
63 protected:
64 // SecurityInterstitialPage methods:
65 void PopulateInterstitialStrings(
66 base::DictionaryValue* load_time_data) override;
67 bool ShouldCreateNewNavigation() const override;
69 // InterstitialPageDelegate method:
70 void CommandReceived(const std::string& command) override;
71 void OnProceed() override;
72 void OnDontProceed() override;
74 private:
75 // URL of the login page, opened when the user clicks the "Connect" button.
76 GURL login_url_;
77 scoped_ptr<Delegate> delegate_;
78 scoped_ptr<CertReportHelper> cert_report_helper_;
79 base::Callback<void(bool)> callback_;
81 DISALLOW_COPY_AND_ASSIGN(CaptivePortalBlockingPage);
84 #endif // CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_