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/intranet_redirect_detector.h" | 5 #include "chrome/browser/intranet_redirect_detector.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/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 87 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
88 net::LOAD_DO_NOT_SAVE_COOKIES | | 88 net::LOAD_DO_NOT_SAVE_COOKIES | |
89 net::LOAD_DO_NOT_SEND_COOKIES); | 89 net::LOAD_DO_NOT_SEND_COOKIES); |
90 fetcher->SetRequestContext(g_browser_process->system_request_context()); | 90 fetcher->SetRequestContext(g_browser_process->system_request_context()); |
91 fetcher->Start(); | 91 fetcher->Start(); |
92 fetchers_.insert(fetcher); | 92 fetchers_.insert(fetcher); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 void IntranetRedirectDetector::OnURLFetchComplete( | 96 void IntranetRedirectDetector::OnURLFetchComplete( |
97 const content::URLFetcher* source) { | 97 const net::URLFetcher* source) { |
98 // Delete the fetcher on this function's exit. | 98 // Delete the fetcher on this function's exit. |
99 Fetchers::iterator fetcher = fetchers_.find( | 99 Fetchers::iterator fetcher = fetchers_.find( |
100 const_cast<content::URLFetcher*>(source)); | 100 const_cast<net::URLFetcher*>(source)); |
101 DCHECK(fetcher != fetchers_.end()); | 101 DCHECK(fetcher != fetchers_.end()); |
102 scoped_ptr<content::URLFetcher> clean_up_fetcher(*fetcher); | 102 scoped_ptr<net::URLFetcher> clean_up_fetcher(*fetcher); |
103 fetchers_.erase(fetcher); | 103 fetchers_.erase(fetcher); |
104 | 104 |
105 // If any two fetches result in the same domain/host, we set the redirect | 105 // If any two fetches result in the same domain/host, we set the redirect |
106 // origin to that; otherwise we set it to nothing. | 106 // origin to that; otherwise we set it to nothing. |
107 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) { | 107 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) { |
108 if ((resulting_origins_.empty()) || | 108 if ((resulting_origins_.empty()) || |
109 ((resulting_origins_.size() == 1) && | 109 ((resulting_origins_.size() == 1) && |
110 resulting_origins_.front().is_valid())) { | 110 resulting_origins_.front().is_valid())) { |
111 resulting_origins_.push_back(GURL()); | 111 resulting_origins_.push_back(GURL()); |
112 return; | 112 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // the same thread. So just use the heuristic that any all-lowercase a-z | 173 // the same thread. So just use the heuristic that any all-lowercase a-z |
174 // hostname with the right number of characters is likely from the detector | 174 // hostname with the right number of characters is likely from the detector |
175 // (and thus should be blocked). | 175 // (and thus should be blocked). |
176 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && | 176 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && |
177 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == | 177 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == |
178 std::string::npos)) ? | 178 std::string::npos)) ? |
179 net::ERR_NAME_NOT_RESOLVED : | 179 net::ERR_NAME_NOT_RESOLVED : |
180 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, | 180 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, |
181 os_error); | 181 os_error); |
182 } | 182 } |
OLD | NEW |