Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / ssl / captive_portal_blocking_page.h
blob613bcf30e81e60469940920938cedac85141b25b
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 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
17 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag.
18 #endif
20 namespace content {
21 class WebContents;
24 namespace net {
25 class SSLInfo;
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 {
39 public:
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;
54 protected:
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;
70 private:
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_