OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "content/common/notification_service.h" | |
16 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
17 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
18 #include "net/base/registry_controlled_domain.h" | 17 #include "net/base/registry_controlled_domain.h" |
19 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
20 #include "net/url_request/url_request_status.h" | 19 #include "net/url_request/url_request_status.h" |
21 | 20 |
22 const size_t IntranetRedirectDetector::kNumCharsInHostnames = 10; | 21 const size_t IntranetRedirectDetector::kNumCharsInHostnames = 10; |
23 | 22 |
24 IntranetRedirectDetector::IntranetRedirectDetector() | 23 IntranetRedirectDetector::IntranetRedirectDetector() |
25 : redirect_origin_(g_browser_process->local_state()->GetString( | 24 : redirect_origin_(g_browser_process->local_state()->GetString( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // 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 |
175 // 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 |
176 // (and thus should be blocked). | 175 // (and thus should be blocked). |
177 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && | 176 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && |
178 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == | 177 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == |
179 std::string::npos)) ? | 178 std::string::npos)) ? |
180 net::ERR_NAME_NOT_RESOLVED : | 179 net::ERR_NAME_NOT_RESOLVED : |
181 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, | 180 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, |
182 os_error); | 181 os_error); |
183 } | 182 } |
OLD | NEW |