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 #ifndef COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_DETECTOR_H_ | 5 #ifndef COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_DETECTOR_H_ |
6 #define COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_DETECTOR_H_ | 6 #define COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_DETECTOR_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 // The test URL. When connected to the Internet, it should return a | 43 // The test URL. When connected to the Internet, it should return a |
44 // blank page with a 204 status code. When behind a captive portal, | 44 // blank page with a 204 status code. When behind a captive portal, |
45 // requests for this URL should get an HTTP redirect or a login | 45 // requests for this URL should get an HTTP redirect or a login |
46 // page. When neither is true, no server should respond to requests | 46 // page. When neither is true, no server should respond to requests |
47 // for this URL. | 47 // for this URL. |
48 static const char kDefaultURL[]; | 48 static const char kDefaultURL[]; |
49 | 49 |
50 explicit CaptivePortalDetector( | 50 explicit CaptivePortalDetector( |
51 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 51 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
52 virtual ~CaptivePortalDetector(); | 52 ~CaptivePortalDetector() override; |
53 | 53 |
54 // Triggers a check for a captive portal. After completion, runs the | 54 // Triggers a check for a captive portal. After completion, runs the |
55 // |callback|. | 55 // |callback|. |
56 void DetectCaptivePortal(const GURL& url, const DetectionCallback& callback); | 56 void DetectCaptivePortal(const GURL& url, const DetectionCallback& callback); |
57 | 57 |
58 // Cancels captive portal check. | 58 // Cancels captive portal check. |
59 void Cancel(); | 59 void Cancel(); |
60 | 60 |
61 private: | 61 private: |
62 friend class CaptivePortalDetectorTestBase; | 62 friend class CaptivePortalDetectorTestBase; |
63 | 63 |
64 // net::URLFetcherDelegate: | 64 // net::URLFetcherDelegate: |
65 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 65 void OnURLFetchComplete(const net::URLFetcher* source) override; |
66 | 66 |
67 // Takes a net::URLFetcher that has finished trying to retrieve the | 67 // Takes a net::URLFetcher that has finished trying to retrieve the |
68 // test URL, and fills a Results struct based on its result. If the | 68 // test URL, and fills a Results struct based on its result. If the |
69 // response is a 503 with a Retry-After header, |retry_after| field | 69 // response is a 503 with a Retry-After header, |retry_after| field |
70 // of |results| is populated accordingly. Otherwise, it's set to | 70 // of |results| is populated accordingly. Otherwise, it's set to |
71 // base::TimeDelta(). | 71 // base::TimeDelta(). |
72 void GetCaptivePortalResultFromResponse(const net::URLFetcher* url_fetcher, | 72 void GetCaptivePortalResultFromResponse(const net::URLFetcher* url_fetcher, |
73 Results* results) const; | 73 Results* results) const; |
74 | 74 |
75 // Returns the current time. Used only when determining time until a | 75 // Returns the current time. Used only when determining time until a |
(...skipping 22 matching lines...) Expand all Loading... |
98 | 98 |
99 // Test time used by unit tests. | 99 // Test time used by unit tests. |
100 base::Time time_for_testing_; | 100 base::Time time_for_testing_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(CaptivePortalDetector); | 102 DISALLOW_COPY_AND_ASSIGN(CaptivePortalDetector); |
103 }; | 103 }; |
104 | 104 |
105 } // namespace captive_portal | 105 } // namespace captive_portal |
106 | 106 |
107 #endif // COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_DETECTOR_H_ | 107 #endif // COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_DETECTOR_H_ |
OLD | NEW |