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 "components/captive_portal/captive_portal_detector.h" | 5 #include "components/captive_portal/captive_portal_detector.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 void CaptivePortalDetector::DetectCaptivePortal( | 27 void CaptivePortalDetector::DetectCaptivePortal( |
28 const GURL& url, | 28 const GURL& url, |
29 const DetectionCallback& detection_callback) { | 29 const DetectionCallback& detection_callback) { |
30 DCHECK(CalledOnValidThread()); | 30 DCHECK(CalledOnValidThread()); |
31 DCHECK(!FetchingURL()); | 31 DCHECK(!FetchingURL()); |
32 DCHECK(detection_callback_.is_null()); | 32 DCHECK(detection_callback_.is_null()); |
33 | 33 |
34 detection_callback_ = detection_callback; | 34 detection_callback_ = detection_callback; |
35 | 35 |
36 // The first 0 means this can use a TestURLFetcherFactory in unit tests. | 36 // The first 0 means this can use a TestURLFetcherFactory in unit tests. |
37 url_fetcher_.reset(net::URLFetcher::Create(0, | 37 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); |
38 url, | |
39 net::URLFetcher::GET, | |
40 this)); | |
41 url_fetcher_->SetAutomaticallyRetryOn5xx(false); | 38 url_fetcher_->SetAutomaticallyRetryOn5xx(false); |
42 url_fetcher_->SetRequestContext(request_context_.get()); | 39 url_fetcher_->SetRequestContext(request_context_.get()); |
43 | 40 |
44 // Can't safely use net::LOAD_DISABLE_CERT_REVOCATION_CHECKING here, | 41 // Can't safely use net::LOAD_DISABLE_CERT_REVOCATION_CHECKING here, |
45 // since then the connection may be reused without checking the cert. | 42 // since then the connection may be reused without checking the cert. |
46 url_fetcher_->SetLoadFlags( | 43 url_fetcher_->SetLoadFlags( |
47 net::LOAD_BYPASS_CACHE | | 44 net::LOAD_BYPASS_CACHE | |
48 net::LOAD_DO_NOT_SAVE_COOKIES | | 45 net::LOAD_DO_NOT_SAVE_COOKIES | |
49 net::LOAD_DO_NOT_SEND_COOKIES | | 46 net::LOAD_DO_NOT_SEND_COOKIES | |
50 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 47 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return base::Time::Now(); | 133 return base::Time::Now(); |
137 else | 134 else |
138 return time_for_testing_; | 135 return time_for_testing_; |
139 } | 136 } |
140 | 137 |
141 bool CaptivePortalDetector::FetchingURL() const { | 138 bool CaptivePortalDetector::FetchingURL() const { |
142 return url_fetcher_.get() != NULL; | 139 return url_fetcher_.get() != NULL; |
143 } | 140 } |
144 | 141 |
145 } // namespace captive_portal | 142 } // namespace captive_portal |
OLD | NEW |