OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 | 893 |
894 // Sets up the captive portal service for the given profile so that | 894 // Sets up the captive portal service for the given profile so that |
895 // all checks go to |test_url|. Also disables all timers. | 895 // all checks go to |test_url|. Also disables all timers. |
896 void SetUpCaptivePortalService(Profile* profile, const GURL& test_url); | 896 void SetUpCaptivePortalService(Profile* profile, const GURL& test_url); |
897 | 897 |
898 // Returns true if |browser|'s profile is currently running a captive portal | 898 // Returns true if |browser|'s profile is currently running a captive portal |
899 // check. | 899 // check. |
900 bool CheckPending(Browser* browser); | 900 bool CheckPending(Browser* browser); |
901 | 901 |
902 // Returns the type of the interstitial being shown. | 902 // Returns the type of the interstitial being shown. |
903 const void* GetInterstitialType(WebContents* contents) const; | 903 content::InterstitialPageDelegate::TypeID GetInterstitialType( |
| 904 WebContents* contents) const; |
904 | 905 |
905 // Returns the CaptivePortalTabReloader::State of |web_contents|. | 906 // Returns the CaptivePortalTabReloader::State of |web_contents|. |
906 CaptivePortalTabReloader::State GetStateOfTabReloader( | 907 CaptivePortalTabReloader::State GetStateOfTabReloader( |
907 WebContents* web_contents) const; | 908 WebContents* web_contents) const; |
908 | 909 |
909 // Returns the CaptivePortalTabReloader::State of the indicated tab. | 910 // Returns the CaptivePortalTabReloader::State of the indicated tab. |
910 CaptivePortalTabReloader::State GetStateOfTabReloaderAt(Browser* browser, | 911 CaptivePortalTabReloader::State GetStateOfTabReloaderAt(Browser* browser, |
911 int index) const; | 912 int index) const; |
912 | 913 |
913 // Returns the number of tabs with the given state, across all profiles. | 914 // Returns the number of tabs with the given state, across all profiles. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 } | 1136 } |
1136 | 1137 |
1137 bool CaptivePortalBrowserTest::CheckPending(Browser* browser) { | 1138 bool CaptivePortalBrowserTest::CheckPending(Browser* browser) { |
1138 CaptivePortalService* captive_portal_service = | 1139 CaptivePortalService* captive_portal_service = |
1139 CaptivePortalServiceFactory::GetForProfile(browser->profile()); | 1140 CaptivePortalServiceFactory::GetForProfile(browser->profile()); |
1140 | 1141 |
1141 return captive_portal_service->DetectionInProgress() || | 1142 return captive_portal_service->DetectionInProgress() || |
1142 captive_portal_service->TimerRunning(); | 1143 captive_portal_service->TimerRunning(); |
1143 } | 1144 } |
1144 | 1145 |
1145 const void* CaptivePortalBrowserTest::GetInterstitialType( | 1146 content::InterstitialPageDelegate::TypeID |
1146 WebContents* contents) const { | 1147 CaptivePortalBrowserTest::GetInterstitialType(WebContents* contents) const { |
1147 if (!contents->ShowingInterstitialPage()) | 1148 if (!contents->ShowingInterstitialPage()) |
1148 return nullptr; | 1149 return nullptr; |
1149 SecurityInterstitialPage* blocking_page = | 1150 return contents->GetInterstitialPage() |
1150 static_cast<SecurityInterstitialPage*>( | 1151 ->GetDelegateForTesting() |
1151 contents->GetInterstitialPage()->GetDelegateForTesting()); | 1152 ->GetTypeForTesting(); |
1152 return blocking_page->GetTypeForTesting(); | |
1153 } | 1153 } |
1154 | 1154 |
1155 CaptivePortalTabReloader::State CaptivePortalBrowserTest::GetStateOfTabReloader( | 1155 CaptivePortalTabReloader::State CaptivePortalBrowserTest::GetStateOfTabReloader( |
1156 WebContents* web_contents) const { | 1156 WebContents* web_contents) const { |
1157 return GetTabReloader(web_contents)->state(); | 1157 return GetTabReloader(web_contents)->state(); |
1158 } | 1158 } |
1159 | 1159 |
1160 CaptivePortalTabReloader::State | 1160 CaptivePortalTabReloader::State |
1161 CaptivePortalBrowserTest::GetStateOfTabReloaderAt(Browser* browser, | 1161 CaptivePortalBrowserTest::GetStateOfTabReloaderAt(Browser* browser, |
1162 int index) const { | 1162 int index) const { |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2730 | 2730 |
2731 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, | 2731 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, |
2732 GetStateOfTabReloaderAt(browser(), broken_tab_index)); | 2732 GetStateOfTabReloaderAt(browser(), broken_tab_index)); |
2733 | 2733 |
2734 WaitForInterstitialAttach(broken_tab_contents); | 2734 WaitForInterstitialAttach(broken_tab_contents); |
2735 portal_observer.WaitForResults(1); | 2735 portal_observer.WaitForResults(1); |
2736 | 2736 |
2737 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2737 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2738 GetInterstitialType(broken_tab_contents)); | 2738 GetInterstitialType(broken_tab_contents)); |
2739 } | 2739 } |
OLD | NEW |