| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_ | 5 #ifndef CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_ |
| 6 #define CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_ | 6 #define CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/interstitials/security_interstitial_page.h" | 13 #include "chrome/browser/interstitials/security_interstitial_page.h" |
| 14 #include "content/public/browser/certificate_request_result_type.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 17 #if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 17 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag. | 18 #error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag. |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class WebContents; | 22 class WebContents; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace net { | 25 namespace net { |
| 25 class SSLInfo; | 26 class SSLInfo; |
| 26 } | 27 } |
| 27 | 28 |
| 28 class CertReportHelper; | 29 class CertReportHelper; |
| 29 class SSLCertReporter; | 30 class SSLCertReporter; |
| 30 | 31 |
| 31 // This class is responsible for showing/hiding the interstitial page that is | 32 // This class is responsible for showing/hiding the interstitial page that is |
| 32 // shown when a captive portal triggers an SSL error. | 33 // shown when a captive portal triggers an SSL error. |
| 33 // It deletes itself when the interstitial page is closed. | 34 // It deletes itself when the interstitial page is closed. |
| 34 // | 35 // |
| 35 // This class should only be used on the UI thread because its implementation | 36 // 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 // uses captive_portal::CaptivePortalService, which can only be accessed on the |
| 37 // UI thread. Only used when ENABLE_CAPTIVE_PORTAL_DETECTION is true. | 38 // UI thread. Only used when ENABLE_CAPTIVE_PORTAL_DETECTION is true. |
| 38 class CaptivePortalBlockingPage : public SecurityInterstitialPage { | 39 class CaptivePortalBlockingPage : public SecurityInterstitialPage { |
| 39 public: | 40 public: |
| 40 // Interstitial type, for testing. | 41 // Interstitial type, for testing. |
| 41 static const void* const kTypeForTesting; | 42 static const void* const kTypeForTesting; |
| 42 | 43 |
| 43 CaptivePortalBlockingPage(content::WebContents* web_contents, | 44 CaptivePortalBlockingPage( |
| 44 const GURL& request_url, | 45 content::WebContents* web_contents, |
| 45 const GURL& login_url, | 46 const GURL& request_url, |
| 46 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 47 const GURL& login_url, |
| 47 const net::SSLInfo& ssl_info, | 48 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
| 48 const base::Callback<void(bool)>& callback); | 49 const net::SSLInfo& ssl_info, |
| 50 const base::Callback<void(content::CertificateRequestResultType)>& |
| 51 callback); |
| 49 ~CaptivePortalBlockingPage() override; | 52 ~CaptivePortalBlockingPage() override; |
| 50 | 53 |
| 51 // InterstitialPageDelegate method: | 54 // InterstitialPageDelegate method: |
| 52 const void* GetTypeForTesting() const override; | 55 const void* GetTypeForTesting() const override; |
| 53 | 56 |
| 54 protected: | 57 protected: |
| 55 // Returns true if the connection is a Wi-Fi connection. Virtual for tests. | 58 // Returns true if the connection is a Wi-Fi connection. Virtual for tests. |
| 56 virtual bool IsWifiConnection() const; | 59 virtual bool IsWifiConnection() const; |
| 57 // Returns the SSID of the connected Wi-Fi network, if any. Virtual for tests. | 60 // Returns the SSID of the connected Wi-Fi network, if any. Virtual for tests. |
| 58 virtual std::string GetWiFiSSID() const; | 61 virtual std::string GetWiFiSSID() const; |
| 59 | 62 |
| 60 // SecurityInterstitialPage methods: | 63 // SecurityInterstitialPage methods: |
| 61 bool ShouldCreateNewNavigation() const override; | 64 bool ShouldCreateNewNavigation() const override; |
| 62 void PopulateInterstitialStrings( | 65 void PopulateInterstitialStrings( |
| 63 base::DictionaryValue* load_time_data) override; | 66 base::DictionaryValue* load_time_data) override; |
| 64 void AfterShow() override {} | 67 void AfterShow() override {} |
| 65 | 68 |
| 66 // InterstitialPageDelegate method: | 69 // InterstitialPageDelegate method: |
| 67 void CommandReceived(const std::string& command) override; | 70 void CommandReceived(const std::string& command) override; |
| 68 void OnProceed() override; | 71 void OnProceed() override; |
| 69 void OnDontProceed() override; | 72 void OnDontProceed() override; |
| 70 | 73 |
| 71 private: | 74 private: |
| 72 // URL of the login page, opened when the user clicks the "Connect" button. | 75 // URL of the login page, opened when the user clicks the "Connect" button. |
| 73 const GURL login_url_; | 76 const GURL login_url_; |
| 74 std::unique_ptr<CertReportHelper> cert_report_helper_; | 77 std::unique_ptr<CertReportHelper> cert_report_helper_; |
| 75 base::Callback<void(bool)> callback_; | 78 base::Callback<void(content::CertificateRequestResultType)> callback_; |
| 76 | 79 |
| 77 DISALLOW_COPY_AND_ASSIGN(CaptivePortalBlockingPage); | 80 DISALLOW_COPY_AND_ASSIGN(CaptivePortalBlockingPage); |
| 78 }; | 81 }; |
| 79 | 82 |
| 80 #endif // CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_ | 83 #endif // CHROME_BROWSER_SSL_CAPTIVE_PORTAL_BLOCKING_PAGE_H_ |
| OLD | NEW |