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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return; | 74 return; |
75 | 75 |
76 DCHECK(fetchers_.empty() && resulting_origins_.empty()); | 76 DCHECK(fetchers_.empty() && resulting_origins_.empty()); |
77 | 77 |
78 // Start three fetchers on random hostnames. | 78 // Start three fetchers on random hostnames. |
79 for (size_t i = 0; i < 3; ++i) { | 79 for (size_t i = 0; i < 3; ++i) { |
80 std::string url_string("http://"); | 80 std::string url_string("http://"); |
81 for (size_t j = 0; j < kNumCharsInHostnames; ++j) | 81 for (size_t j = 0; j < kNumCharsInHostnames; ++j) |
82 url_string += ('a' + base::RandInt(0, 'z' - 'a')); | 82 url_string += ('a' + base::RandInt(0, 'z' - 'a')); |
83 GURL random_url(url_string + '/'); | 83 GURL random_url(url_string + '/'); |
84 content::URLFetcher* fetcher = content::URLFetcher::Create( | 84 net::URLFetcher* fetcher = content::URLFetcher::Create( |
85 random_url, content::URLFetcher::HEAD, this); | 85 random_url, net::URLFetcher::HEAD, this); |
86 // We don't want these fetches to affect existing state in the profile. | 86 // We don't want these fetches to affect existing state in the profile. |
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 |
(...skipping 77 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 |