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 "chrome/browser/captive_portal/captive_portal_service.h" | 5 #include "chrome/browser/captive_portal/captive_portal_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EnableCaptivePortalDetection(true); | 164 EnableCaptivePortalDetection(true); |
165 } | 165 } |
166 | 166 |
167 // Sets the captive portal checking preference. | 167 // Sets the captive portal checking preference. |
168 void EnableCaptivePortalDetection(bool enabled) { | 168 void EnableCaptivePortalDetection(bool enabled) { |
169 profile()->GetPrefs()->SetBoolean(prefs::kAlternateErrorPagesEnabled, | 169 profile()->GetPrefs()->SetBoolean(prefs::kAlternateErrorPagesEnabled, |
170 enabled); | 170 enabled); |
171 } | 171 } |
172 | 172 |
173 // Calls the corresponding CaptivePortalService function. | 173 // Calls the corresponding CaptivePortalService function. |
174 void OnURLFetchComplete(content::URLFetcher* fetcher) { | 174 void OnURLFetchComplete(net::URLFetcher* fetcher) { |
175 service()->OnURLFetchComplete(fetcher); | 175 service()->OnURLFetchComplete(fetcher); |
176 } | 176 } |
177 | 177 |
178 // Triggers a captive portal check, then simulates the URL request | 178 // Triggers a captive portal check, then simulates the URL request |
179 // returning with the specified |net_error| and |status_code|. If |net_error| | 179 // returning with the specified |net_error| and |status_code|. If |net_error| |
180 // is not OK, |status_code| is ignored. Expects the CaptivePortalService to | 180 // is not OK, |status_code| is ignored. Expects the CaptivePortalService to |
181 // return |expected_result|. | 181 // return |expected_result|. |
182 // | 182 // |
183 // |expected_delay_secs| is the expected value of GetTimeUntilNextRequest(). | 183 // |expected_delay_secs| is the expected value of GetTimeUntilNextRequest(). |
184 // The function makes sure the value is as expected, and then simulates | 184 // The function makes sure the value is as expected, and then simulates |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 614 |
615 RunTest(RESULT_NO_RESPONSE, | 615 RunTest(RESULT_NO_RESPONSE, |
616 net::OK, | 616 net::OK, |
617 503, | 617 503, |
618 0, | 618 0, |
619 "HTTP/1.1 503 OK\nRetry-After: Christmas\n\n"); | 619 "HTTP/1.1 503 OK\nRetry-After: Christmas\n\n"); |
620 EXPECT_EQ(base::TimeDelta::FromSeconds(100), GetTimeUntilNextRequest()); | 620 EXPECT_EQ(base::TimeDelta::FromSeconds(100), GetTimeUntilNextRequest()); |
621 } | 621 } |
622 | 622 |
623 } // namespace captive_portal | 623 } // namespace captive_portal |
OLD | NEW |