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 #ifndef CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
6 #define CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 6 #define CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/public/common/url_fetcher_delegate.h" | |
15 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/common/url_fetcher_delegate.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "net/base/host_resolver_proc.h" | 18 #include "net/base/host_resolver_proc.h" |
19 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
20 | 20 |
21 class PrefService; | 21 class PrefService; |
22 | 22 |
23 // This object is responsible for determining whether the user is on a network | 23 // This object is responsible for determining whether the user is on a network |
24 // that redirects requests for intranet hostnames to another site, and if so, | 24 // that redirects requests for intranet hostnames to another site, and if so, |
25 // tracking what that site is (including across restarts via a pref). For | 25 // tracking what that site is (including across restarts via a pref). For |
26 // example, the user's ISP might convert a request for "http://query/" into a | 26 // example, the user's ISP might convert a request for "http://query/" into a |
(...skipping 26 matching lines...) Expand all Loading... |
53 // is in place. | 53 // is in place. |
54 static GURL RedirectOrigin(); | 54 static GURL RedirectOrigin(); |
55 | 55 |
56 static void RegisterPrefs(PrefService* prefs); | 56 static void RegisterPrefs(PrefService* prefs); |
57 | 57 |
58 // The number of characters the fetcher will use for its randomly-generated | 58 // The number of characters the fetcher will use for its randomly-generated |
59 // hostnames. | 59 // hostnames. |
60 static const size_t kNumCharsInHostnames; | 60 static const size_t kNumCharsInHostnames; |
61 | 61 |
62 private: | 62 private: |
63 typedef std::set<content::URLFetcher*> Fetchers; | 63 typedef std::set<net::URLFetcher*> Fetchers; |
64 | 64 |
65 // Called when the seven second startup sleep or the one second network | 65 // Called when the seven second startup sleep or the one second network |
66 // switch sleep has finished. Runs any pending fetch. | 66 // switch sleep has finished. Runs any pending fetch. |
67 void FinishSleep(); | 67 void FinishSleep(); |
68 | 68 |
69 // content::URLFetcherDelegate | 69 // content::URLFetcherDelegate |
70 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 70 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
71 | 71 |
72 // NetworkChangeNotifier::IPAddressObserver | 72 // NetworkChangeNotifier::IPAddressObserver |
73 virtual void OnIPAddressChanged() OVERRIDE; | 73 virtual void OnIPAddressChanged() OVERRIDE; |
74 | 74 |
75 GURL redirect_origin_; | 75 GURL redirect_origin_; |
76 base::WeakPtrFactory<IntranetRedirectDetector> weak_factory_; | 76 base::WeakPtrFactory<IntranetRedirectDetector> weak_factory_; |
77 Fetchers fetchers_; | 77 Fetchers fetchers_; |
78 std::vector<GURL> resulting_origins_; | 78 std::vector<GURL> resulting_origins_; |
79 bool in_sleep_; // True if we're in the seven-second "no fetching" period | 79 bool in_sleep_; // True if we're in the seven-second "no fetching" period |
80 // that begins at browser start, or the one-second "no | 80 // that begins at browser start, or the one-second "no |
(...skipping 12 matching lines...) Expand all Loading... |
93 net::AddressFamily address_family, | 93 net::AddressFamily address_family, |
94 net::HostResolverFlags host_resolver_flags, | 94 net::HostResolverFlags host_resolver_flags, |
95 net::AddressList* addrlist, | 95 net::AddressList* addrlist, |
96 int* os_error) OVERRIDE; | 96 int* os_error) OVERRIDE; |
97 | 97 |
98 private: | 98 private: |
99 virtual ~IntranetRedirectHostResolverProc() {} | 99 virtual ~IntranetRedirectHostResolverProc() {} |
100 }; | 100 }; |
101 | 101 |
102 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 102 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
OLD | NEW |