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-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // long enough to be after startup, but still get results back quickly. | 35 // long enough to be after startup, but still get results back quickly. |
36 // Ideally, instead of this timer, we'd do something like "check if the | 36 // Ideally, instead of this timer, we'd do something like "check if the |
37 // browser is starting up, and if so, come back later", but there is currently | 37 // browser is starting up, and if so, come back later", but there is currently |
38 // no function to do this. | 38 // no function to do this. |
39 static const int kStartFetchDelayMS = 7000; | 39 static const int kStartFetchDelayMS = 7000; |
40 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 40 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
41 fetcher_factory_.NewRunnableMethod( | 41 fetcher_factory_.NewRunnableMethod( |
42 &IntranetRedirectDetector::FinishSleep), | 42 &IntranetRedirectDetector::FinishSleep), |
43 kStartFetchDelayMS); | 43 kStartFetchDelayMS); |
44 | 44 |
45 net::NetworkChangeNotifier::AddObserver(this); | 45 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
46 } | 46 } |
47 | 47 |
48 IntranetRedirectDetector::~IntranetRedirectDetector() { | 48 IntranetRedirectDetector::~IntranetRedirectDetector() { |
49 net::NetworkChangeNotifier::RemoveObserver(this); | 49 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
50 STLDeleteElements(&fetchers_); | 50 STLDeleteElements(&fetchers_); |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 GURL IntranetRedirectDetector::RedirectOrigin() { | 54 GURL IntranetRedirectDetector::RedirectOrigin() { |
55 const IntranetRedirectDetector* const detector = | 55 const IntranetRedirectDetector* const detector = |
56 g_browser_process->intranet_redirect_detector(); | 56 g_browser_process->intranet_redirect_detector(); |
57 return detector ? detector->redirect_origin_ : GURL(); | 57 return detector ? detector->redirect_origin_ : GURL(); |
58 } | 58 } |
59 | 59 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // the same thread. So just use the heuristic that any all-lowercase a-z | 196 // the same thread. So just use the heuristic that any all-lowercase a-z |
197 // hostname with the right number of characters is likely from the detector | 197 // hostname with the right number of characters is likely from the detector |
198 // (and thus should be blocked). | 198 // (and thus should be blocked). |
199 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && | 199 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && |
200 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == | 200 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == |
201 std::string::npos)) ? | 201 std::string::npos)) ? |
202 net::ERR_NAME_NOT_RESOLVED : | 202 net::ERR_NAME_NOT_RESOLVED : |
203 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, | 203 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, |
204 os_error); | 204 os_error); |
205 } | 205 } |
OLD | NEW |