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 <string> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "net/base/network_delegate.h" | 13 #include "net/base/network_delegate.h" |
14 #include "net/url_request/url_request.h" | |
Joao da Silva
2012/10/22 21:14:20
nit: net::URLRequest can be forward declared in th
Sergiu
2012/10/30 01:08:11
It as it is already forward declared in network_de
| |
12 | 15 |
13 class CookieSettings; | 16 class CookieSettings; |
14 class ExtensionInfoMap; | 17 class ExtensionInfoMap; |
15 class ManagedModeURLFilter; | 18 class ManagedModeURLFilter; |
16 class PrefService; | 19 class PrefService; |
17 template<class T> class PrefMember; | 20 template<class T> class PrefMember; |
18 | 21 |
19 typedef PrefMember<bool> BooleanPrefMember; | 22 typedef PrefMember<bool> BooleanPrefMember; |
20 | 23 |
21 namespace chrome_browser_net { | 24 namespace chrome_browser_net { |
(...skipping 21 matching lines...) Expand all Loading... | |
43 // settings are enforced on all observed network requests. | 46 // settings are enforced on all observed network requests. |
44 ChromeNetworkDelegate( | 47 ChromeNetworkDelegate( |
45 extensions::EventRouterForwarder* event_router, | 48 extensions::EventRouterForwarder* event_router, |
46 ExtensionInfoMap* extension_info_map, | 49 ExtensionInfoMap* extension_info_map, |
47 const policy::URLBlacklistManager* url_blacklist_manager, | 50 const policy::URLBlacklistManager* url_blacklist_manager, |
48 const ManagedModeURLFilter* managed_mode_url_filter, | 51 const ManagedModeURLFilter* managed_mode_url_filter, |
49 void* profile, | 52 void* profile, |
50 CookieSettings* cookie_settings, | 53 CookieSettings* cookie_settings, |
51 BooleanPrefMember* enable_referrers, | 54 BooleanPrefMember* enable_referrers, |
52 BooleanPrefMember* enable_do_not_track, | 55 BooleanPrefMember* enable_do_not_track, |
56 BooleanPrefMember* force_google_safesearch, | |
53 chrome_browser_net::LoadTimeStats* load_time_stats); | 57 chrome_browser_net::LoadTimeStats* load_time_stats); |
54 virtual ~ChromeNetworkDelegate(); | 58 virtual ~ChromeNetworkDelegate(); |
55 | 59 |
56 // Causes |OnCanThrottleRequest| to always return false, for all | 60 // Causes |OnCanThrottleRequest| to always return false, for all |
57 // instances of this object. | 61 // instances of this object. |
58 static void NeverThrottleRequests(); | 62 static void NeverThrottleRequests(); |
59 | 63 |
60 // Binds the pref members to |pref_service| and moves them to the IO thread. | 64 // Binds the pref members to |pref_service| and moves them to the IO thread. |
61 // |enable_do_not_track| can be NULL. | 65 // |enable_do_not_track| can be NULL. |
62 // This method should be called on the UI thread. | 66 // This method should be called on the UI thread. |
63 static void InitializePrefsOnUIThread(BooleanPrefMember* enable_referrers, | 67 static void InitializePrefsOnUIThread( |
64 BooleanPrefMember* enable_do_not_track, | 68 BooleanPrefMember* enable_referrers, |
65 PrefService* pref_service); | 69 BooleanPrefMember* enable_do_not_track, |
70 BooleanPrefMember* force_google_safesearch, | |
71 PrefService* pref_service); | |
66 | 72 |
67 // When called, all file:// URLs will now be accessible. If this is not | 73 // When called, all file:// URLs will now be accessible. If this is not |
68 // called, then some platforms restrict access to file:// paths. | 74 // called, then some platforms restrict access to file:// paths. |
69 static void AllowAccessToAllFiles(); | 75 static void AllowAccessToAllFiles(); |
70 | 76 |
77 // Examines |old_request| and if it is a request to Google Web Search | |
78 // it enforces that the SafeSearch query parameters are set to active | |
79 // Sets the query part of |new_url| with the new value of the parameters. | |
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 |