| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/ssl/captive_portal_blocking_page.h" | 5 #include "chrome/browser/ssl/captive_portal_blocking_page.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 class CaptivePortalBlockingPageForTesting : public CaptivePortalBlockingPage { | 62 class CaptivePortalBlockingPageForTesting : public CaptivePortalBlockingPage { |
| 63 public: | 63 public: |
| 64 CaptivePortalBlockingPageForTesting( | 64 CaptivePortalBlockingPageForTesting( |
| 65 content::WebContents* web_contents, | 65 content::WebContents* web_contents, |
| 66 const GURL& request_url, | 66 const GURL& request_url, |
| 67 const GURL& login_url, | 67 const GURL& login_url, |
| 68 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 68 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
| 69 const net::SSLInfo& ssl_info, | 69 const net::SSLInfo& ssl_info, |
| 70 const base::Callback<void(bool)>& callback, | 70 const base::Callback<void(content::CertificateRequestResultType)>& |
| 71 callback, |
| 71 bool is_wifi, | 72 bool is_wifi, |
| 72 const std::string& wifi_ssid) | 73 const std::string& wifi_ssid) |
| 73 : CaptivePortalBlockingPage(web_contents, | 74 : CaptivePortalBlockingPage(web_contents, |
| 74 request_url, | 75 request_url, |
| 75 login_url, | 76 login_url, |
| 76 std::move(ssl_cert_reporter), | 77 std::move(ssl_cert_reporter), |
| 77 ssl_info, | 78 ssl_info, |
| 78 callback), | 79 callback), |
| 79 is_wifi_(is_wifi), | 80 is_wifi_(is_wifi), |
| 80 wifi_ssid_(wifi_ssid) {} | 81 wifi_ssid_(wifi_ssid) {} |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 content::WebContents* contents = | 134 content::WebContents* contents = |
| 134 browser()->tab_strip_model()->GetActiveWebContents(); | 135 browser()->tab_strip_model()->GetActiveWebContents(); |
| 135 DCHECK(contents); | 136 DCHECK(contents); |
| 136 net::SSLInfo ssl_info; | 137 net::SSLInfo ssl_info; |
| 137 ssl_info.cert = | 138 ssl_info.cert = |
| 138 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); | 139 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); |
| 139 // Blocking page is owned by the interstitial. | 140 // Blocking page is owned by the interstitial. |
| 140 CaptivePortalBlockingPage* blocking_page = | 141 CaptivePortalBlockingPage* blocking_page = |
| 141 new CaptivePortalBlockingPageForTesting( | 142 new CaptivePortalBlockingPageForTesting( |
| 142 contents, GURL(kBrokenSSL), login_url, std::move(ssl_cert_reporter), | 143 contents, GURL(kBrokenSSL), login_url, std::move(ssl_cert_reporter), |
| 143 ssl_info, base::Callback<void(bool)>(), is_wifi_connection, | 144 ssl_info, |
| 144 wifi_ssid); | 145 base::Callback<void(content::CertificateRequestResultType)>(), |
| 146 is_wifi_connection, wifi_ssid); |
| 145 blocking_page->Show(); | 147 blocking_page->Show(); |
| 146 | 148 |
| 147 WaitForInterstitialAttach(contents); | 149 WaitForInterstitialAttach(contents); |
| 148 EXPECT_TRUE( | 150 EXPECT_TRUE( |
| 149 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); | 151 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); |
| 150 EXPECT_EQ(expect_wifi == EXPECT_WIFI_YES, | 152 EXPECT_EQ(expect_wifi == EXPECT_WIFI_YES, |
| 151 IsInterstitialDisplayingText(contents->GetInterstitialPage(), | 153 IsInterstitialDisplayingText(contents->GetInterstitialPage(), |
| 152 "Wi-Fi")); | 154 "Wi-Fi")); |
| 153 if (!wifi_ssid.empty()) { | 155 if (!wifi_ssid.empty()) { |
| 154 EXPECT_EQ(expect_wifi_ssid == EXPECT_WIFI_SSID_YES, | 156 EXPECT_EQ(expect_wifi_ssid == EXPECT_WIFI_SSID_YES, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 protected: | 313 protected: |
| 312 // SecurityInterstitialIDNTest implementation | 314 // SecurityInterstitialIDNTest implementation |
| 313 SecurityInterstitialPage* CreateInterstitial( | 315 SecurityInterstitialPage* CreateInterstitial( |
| 314 content::WebContents* contents, | 316 content::WebContents* contents, |
| 315 const GURL& request_url) const override { | 317 const GURL& request_url) const override { |
| 316 net::SSLInfo empty_ssl_info; | 318 net::SSLInfo empty_ssl_info; |
| 317 // Blocking page is owned by the interstitial. | 319 // Blocking page is owned by the interstitial. |
| 318 CaptivePortalBlockingPage* blocking_page = | 320 CaptivePortalBlockingPage* blocking_page = |
| 319 new CaptivePortalBlockingPageForTesting( | 321 new CaptivePortalBlockingPageForTesting( |
| 320 contents, GURL(kBrokenSSL), request_url, nullptr, empty_ssl_info, | 322 contents, GURL(kBrokenSSL), request_url, nullptr, empty_ssl_info, |
| 321 base::Callback<void(bool)>(), false, ""); | 323 base::Callback<void(content::CertificateRequestResultType)>(), |
| 324 false, ""); |
| 322 return blocking_page; | 325 return blocking_page; |
| 323 } | 326 } |
| 324 }; | 327 }; |
| 325 | 328 |
| 326 // Test that an IDN login domain is decoded properly. | 329 // Test that an IDN login domain is decoded properly. |
| 327 IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest, | 330 IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest, |
| 328 ShowLoginIDNIfPortalRedirectsDetectionURL) { | 331 ShowLoginIDNIfPortalRedirectsDetectionURL) { |
| 329 EXPECT_TRUE(VerifyIDNDecoded()); | 332 EXPECT_TRUE(VerifyIDNDecoded()); |
| 330 } | 333 } |
| OLD | NEW |