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_NET_CHROME_NETWORK_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 6 #define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
7 | 7 |
8 #include <set> | |
Joao da Silva
2012/10/19 10:00:38
Not used
Sergiu
2012/10/19 12:00:18
Done.
| |
9 #include <string> | |
10 | |
8 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
11 #include "net/base/network_delegate.h" | 14 #include "net/base/network_delegate.h" |
15 #include "net/url_request/url_request.h" | |
12 | 16 |
13 class CookieSettings; | 17 class CookieSettings; |
14 class ExtensionInfoMap; | 18 class ExtensionInfoMap; |
15 class ManagedModeURLFilter; | 19 class ManagedModeURLFilter; |
16 class PrefService; | 20 class PrefService; |
17 template<class T> class PrefMember; | 21 template<class T> class PrefMember; |
18 | 22 |
19 typedef PrefMember<bool> BooleanPrefMember; | 23 typedef PrefMember<bool> BooleanPrefMember; |
20 | 24 |
21 namespace chrome_browser_net { | 25 namespace chrome_browser_net { |
(...skipping 21 matching lines...) Expand all Loading... | |
43 // settings are enforced on all observed network requests. | 47 // settings are enforced on all observed network requests. |
44 ChromeNetworkDelegate( | 48 ChromeNetworkDelegate( |
45 extensions::EventRouterForwarder* event_router, | 49 extensions::EventRouterForwarder* event_router, |
46 ExtensionInfoMap* extension_info_map, | 50 ExtensionInfoMap* extension_info_map, |
47 const policy::URLBlacklistManager* url_blacklist_manager, | 51 const policy::URLBlacklistManager* url_blacklist_manager, |
48 const ManagedModeURLFilter* managed_mode_url_filter, | 52 const ManagedModeURLFilter* managed_mode_url_filter, |
49 void* profile, | 53 void* profile, |
50 CookieSettings* cookie_settings, | 54 CookieSettings* cookie_settings, |
51 BooleanPrefMember* enable_referrers, | 55 BooleanPrefMember* enable_referrers, |
52 BooleanPrefMember* enable_do_not_track, | 56 BooleanPrefMember* enable_do_not_track, |
57 BooleanPrefMember* force_google_safesearch, | |
53 chrome_browser_net::LoadTimeStats* load_time_stats); | 58 chrome_browser_net::LoadTimeStats* load_time_stats); |
54 virtual ~ChromeNetworkDelegate(); | 59 virtual ~ChromeNetworkDelegate(); |
55 | 60 |
56 // Causes |OnCanThrottleRequest| to always return false, for all | 61 // Causes |OnCanThrottleRequest| to always return false, for all |
57 // instances of this object. | 62 // instances of this object. |
58 static void NeverThrottleRequests(); | 63 static void NeverThrottleRequests(); |
59 | 64 |
60 // Binds the pref members to |pref_service| and moves them to the IO thread. | 65 // Binds the pref members to |pref_service| and moves them to the IO thread. |
61 // |enable_do_not_track| can be NULL. | 66 // |enable_do_not_track| can be NULL. |
62 // This method should be called on the UI thread. | 67 // This method should be called on the UI thread. |
63 static void InitializePrefsOnUIThread(BooleanPrefMember* enable_referrers, | 68 static void InitializePrefsOnUIThread( |
64 BooleanPrefMember* enable_do_not_track, | 69 BooleanPrefMember* enable_referrers, |
65 PrefService* pref_service); | 70 BooleanPrefMember* enable_do_not_track, |
71 BooleanPrefMember* force_google_safesearch, | |
72 PrefService* pref_service); | |
66 | 73 |
67 // When called, all file:// URLs will now be accessible. If this is not | 74 // When called, all file:// URLs will now be accessible. If this is not |
68 // called, then some platforms restrict access to file:// paths. | 75 // called, then some platforms restrict access to file:// paths. |
69 static void AllowAccessToAllFiles(); | 76 static void AllowAccessToAllFiles(); |
70 | 77 |
78 // Checks whether a request url should be overwritten with the SafeSearch | |
79 // parameters. | |
battre
2012/10/19 09:02:35
This description is not accurate. The operation is
Sergiu
2012/10/19 12:00:18
Done.
| |
80 static void ForceGoogleSafeSearch(net::URLRequest* old_request, | |
81 GURL* new_url); | |
82 | |
71 private: | 83 private: |
72 friend class ChromeNetworkDelegateTest; | 84 friend class ChromeNetworkDelegateTest; |
73 | 85 |
74 // NetworkDelegate implementation. | 86 // NetworkDelegate implementation. |
75 virtual int OnBeforeURLRequest(net::URLRequest* request, | 87 virtual int OnBeforeURLRequest(net::URLRequest* request, |
76 const net::CompletionCallback& callback, | 88 const net::CompletionCallback& callback, |
77 GURL* new_url) OVERRIDE; | 89 GURL* new_url) OVERRIDE; |
78 virtual int OnBeforeSendHeaders(net::URLRequest* request, | 90 virtual int OnBeforeSendHeaders(net::URLRequest* request, |
79 const net::CompletionCallback& callback, | 91 const net::CompletionCallback& callback, |
80 net::HttpRequestHeaders* headers) OVERRIDE; | 92 net::HttpRequestHeaders* headers) OVERRIDE; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 | 129 |
118 scoped_refptr<extensions::EventRouterForwarder> event_router_; | 130 scoped_refptr<extensions::EventRouterForwarder> event_router_; |
119 void* profile_; | 131 void* profile_; |
120 scoped_refptr<CookieSettings> cookie_settings_; | 132 scoped_refptr<CookieSettings> cookie_settings_; |
121 | 133 |
122 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 134 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
123 | 135 |
124 // Weak, owned by our owner. | 136 // Weak, owned by our owner. |
125 BooleanPrefMember* enable_referrers_; | 137 BooleanPrefMember* enable_referrers_; |
126 BooleanPrefMember* enable_do_not_track_; | 138 BooleanPrefMember* enable_do_not_track_; |
139 BooleanPrefMember* force_google_safesearch_; | |
127 | 140 |
128 // Weak, owned by our owner. | 141 // Weak, owned by our owner. |
129 const policy::URLBlacklistManager* url_blacklist_manager_; | 142 const policy::URLBlacklistManager* url_blacklist_manager_; |
130 | 143 |
131 // Weak pointer. The owner of this object needs to make sure that the | 144 // Weak pointer. The owner of this object needs to make sure that the |
132 // |managed_mode_url_filter_| outlives it. | 145 // |managed_mode_url_filter_| outlives it. |
133 const ManagedModeURLFilter* managed_mode_url_filter_; | 146 const ManagedModeURLFilter* managed_mode_url_filter_; |
134 | 147 |
135 // When true, allow access to all file:// URLs. | 148 // When true, allow access to all file:// URLs. |
136 static bool g_allow_file_access_; | 149 static bool g_allow_file_access_; |
137 | 150 |
138 // True if OnCanThrottleRequest should always return false. | 151 // True if OnCanThrottleRequest should always return false. |
139 // | 152 // |
140 // Note: This needs to be static as the instance of | 153 // Note: This needs to be static as the instance of |
141 // ChromeNetworkDelegate used may change over time, and we need to | 154 // ChromeNetworkDelegate used may change over time, and we need to |
142 // set this variable once at start-up time. It is effectively | 155 // set this variable once at start-up time. It is effectively |
143 // static anyway since it is based on a command-line flag. | 156 // static anyway since it is based on a command-line flag. |
144 static bool g_never_throttle_requests_; | 157 static bool g_never_throttle_requests_; |
145 | 158 |
146 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. | 159 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. |
147 chrome_browser_net::LoadTimeStats* load_time_stats_; | 160 chrome_browser_net::LoadTimeStats* load_time_stats_; |
148 | 161 |
149 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 162 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
150 }; | 163 }; |
151 | 164 |
152 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 165 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |