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> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
" |
17 #include "net/base/network_delegate.h" | 17 #include "net/base/network_delegate.h" |
18 | 18 |
| 19 class ChromeExtensionsNetworkDelegate; |
19 class ClientHints; | 20 class ClientHints; |
20 class CookieSettings; | 21 class CookieSettings; |
21 class PrefService; | 22 class PrefService; |
22 template<class T> class PrefMember; | 23 template<class T> class PrefMember; |
23 | 24 |
24 typedef PrefMember<bool> BooleanPrefMember; | 25 typedef PrefMember<bool> BooleanPrefMember; |
25 | 26 |
26 namespace base { | 27 namespace base { |
27 class Value; | 28 class Value; |
28 } | 29 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // add hooks into the network stack. | 62 // add hooks into the network stack. |
62 class ChromeNetworkDelegate : public net::NetworkDelegate { | 63 class ChromeNetworkDelegate : public net::NetworkDelegate { |
63 public: | 64 public: |
64 // |enable_referrers| (and all of the other optional PrefMembers) should be | 65 // |enable_referrers| (and all of the other optional PrefMembers) should be |
65 // initialized on the UI thread (see below) beforehand. This object's owner is | 66 // initialized on the UI thread (see below) beforehand. This object's owner is |
66 // responsible for cleaning them up at shutdown. | 67 // responsible for cleaning them up at shutdown. |
67 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, | 68 ChromeNetworkDelegate(extensions::EventRouterForwarder* event_router, |
68 BooleanPrefMember* enable_referrers); | 69 BooleanPrefMember* enable_referrers); |
69 virtual ~ChromeNetworkDelegate(); | 70 virtual ~ChromeNetworkDelegate(); |
70 | 71 |
71 // Not inlined because we assign a scoped_refptr, which requires us to include | 72 // Pass through to ChromeExtensionsNetworkDelegate::set_extension_info_map(). |
72 // the header file. | |
73 void set_extension_info_map(extensions::InfoMap* extension_info_map); | 73 void set_extension_info_map(extensions::InfoMap* extension_info_map); |
74 | 74 |
| 75 #if defined(ENABLE_CONFIGURATION_POLICY) |
75 void set_url_blacklist_manager( | 76 void set_url_blacklist_manager( |
76 const policy::URLBlacklistManager* url_blacklist_manager) { | 77 const policy::URLBlacklistManager* url_blacklist_manager) { |
77 url_blacklist_manager_ = url_blacklist_manager; | 78 url_blacklist_manager_ = url_blacklist_manager; |
78 } | 79 } |
| 80 #endif |
79 | 81 |
80 // If |profile| is NULL or not set, events will be broadcast to all profiles, | 82 // If |profile| is NULL or not set, events will be broadcast to all profiles, |
81 // otherwise they will only be sent to the specified profile. | 83 // otherwise they will only be sent to the specified profile. |
82 void set_profile(void* profile) { | 84 // Also pass through to ChromeExtensionsNetworkDelegate::set_profile(). |
83 profile_ = profile; | 85 void set_profile(void* profile); |
84 } | |
85 | 86 |
86 // |profile_path| is used to locate the "Downloads" folder on Chrome OS. If it | 87 // |profile_path| is used to locate the "Downloads" folder on Chrome OS. If it |
87 // is set, the location of the Downloads folder for the profile is added to | 88 // is set, the location of the Downloads folder for the profile is added to |
88 // the whitelist for accesses via file: scheme. | 89 // the whitelist for accesses via file: scheme. |
89 void set_profile_path(const base::FilePath& profile_path) { | 90 void set_profile_path(const base::FilePath& profile_path) { |
90 profile_path_ = profile_path; | 91 profile_path_ = profile_path; |
91 } | 92 } |
92 | 93 |
93 // If |cookie_settings| is NULL or not set, all cookies are enabled, | 94 // If |cookie_settings| is NULL or not set, all cookies are enabled, |
94 // otherwise the settings are enforced on all observed network requests. | 95 // otherwise the settings are enforced on all observed network requests. |
95 // Not inlined because we assign a scoped_refptr, which requires us to include | 96 // Not inlined because we assign a scoped_refptr, which requires us to include |
96 // the header file. Here we just forward-declare it. | 97 // the header file. Here we just forward-declare it. |
97 void set_cookie_settings(CookieSettings* cookie_settings); | 98 void set_cookie_settings(CookieSettings* cookie_settings); |
98 | 99 |
99 // Causes requested URLs to be fed to |predictor| via ConnectInterceptor. | 100 // Causes requested URLs to be fed to |predictor| via ConnectInterceptor. |
100 void set_predictor(chrome_browser_net::Predictor* predictor); | 101 void set_predictor(chrome_browser_net::Predictor* predictor); |
101 | 102 |
102 void set_enable_do_not_track(BooleanPrefMember* enable_do_not_track) { | 103 void set_enable_do_not_track(BooleanPrefMember* enable_do_not_track) { |
103 enable_do_not_track_ = enable_do_not_track; | 104 enable_do_not_track_ = enable_do_not_track; |
104 } | 105 } |
105 | 106 |
106 void set_force_google_safe_search( | 107 void set_force_google_safe_search( |
107 BooleanPrefMember* force_google_safe_search) { | 108 BooleanPrefMember* force_google_safe_search) { |
108 force_google_safe_search_ = force_google_safe_search; | 109 force_google_safe_search_ = force_google_safe_search; |
109 } | 110 } |
110 | 111 |
111 void set_domain_reliability_monitor( | 112 void set_domain_reliability_monitor( |
112 domain_reliability::DomainReliabilityMonitor* | 113 domain_reliability::DomainReliabilityMonitor* monitor) { |
113 domain_reliability_monitor) { | 114 domain_reliability_monitor_ = monitor; |
114 domain_reliability_monitor_ = domain_reliability_monitor; | |
115 } | 115 } |
116 | 116 |
117 void set_prerender_tracker(prerender::PrerenderTracker* prerender_tracker) { | 117 void set_prerender_tracker(prerender::PrerenderTracker* prerender_tracker) { |
118 prerender_tracker_ = prerender_tracker; | 118 prerender_tracker_ = prerender_tracker; |
119 } | 119 } |
120 | 120 |
121 void set_data_reduction_proxy_params( | 121 void set_data_reduction_proxy_params( |
122 data_reduction_proxy::DataReductionProxyParams* params) { | 122 data_reduction_proxy::DataReductionProxyParams* params) { |
123 data_reduction_proxy_params_ = params; | 123 data_reduction_proxy_params_ = params; |
124 } | 124 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 const GURL& first_party_for_cookies) const OVERRIDE; | 198 const GURL& first_party_for_cookies) const OVERRIDE; |
199 virtual int OnBeforeSocketStreamConnect( | 199 virtual int OnBeforeSocketStreamConnect( |
200 net::SocketStream* stream, | 200 net::SocketStream* stream, |
201 const net::CompletionCallback& callback) OVERRIDE; | 201 const net::CompletionCallback& callback) OVERRIDE; |
202 | 202 |
203 void AccumulateContentLength( | 203 void AccumulateContentLength( |
204 int64 received_payload_byte_count, | 204 int64 received_payload_byte_count, |
205 int64 original_payload_byte_count, | 205 int64 original_payload_byte_count, |
206 data_reduction_proxy::DataReductionProxyRequestType request_type); | 206 data_reduction_proxy::DataReductionProxyRequestType request_type); |
207 | 207 |
208 scoped_refptr<extensions::EventRouterForwarder> event_router_; | 208 scoped_ptr<ChromeExtensionsNetworkDelegate> extensions_delegate_; |
| 209 |
209 void* profile_; | 210 void* profile_; |
210 base::FilePath profile_path_; | 211 base::FilePath profile_path_; |
211 scoped_refptr<CookieSettings> cookie_settings_; | 212 scoped_refptr<CookieSettings> cookie_settings_; |
212 | 213 |
213 scoped_refptr<extensions::InfoMap> extension_info_map_; | |
214 | |
215 scoped_ptr<chrome_browser_net::ConnectInterceptor> connect_interceptor_; | 214 scoped_ptr<chrome_browser_net::ConnectInterceptor> connect_interceptor_; |
216 | 215 |
217 // Weak, owned by our owner. | 216 // Weak, owned by our owner. |
218 BooleanPrefMember* enable_referrers_; | 217 BooleanPrefMember* enable_referrers_; |
219 BooleanPrefMember* enable_do_not_track_; | 218 BooleanPrefMember* enable_do_not_track_; |
220 BooleanPrefMember* force_google_safe_search_; | 219 BooleanPrefMember* force_google_safe_search_; |
221 | 220 |
222 // Weak, owned by our owner. | 221 // Weak, owned by our owner. |
| 222 #if defined(ENABLE_CONFIGURATION_POLICY) |
223 const policy::URLBlacklistManager* url_blacklist_manager_; | 223 const policy::URLBlacklistManager* url_blacklist_manager_; |
| 224 #endif |
224 domain_reliability::DomainReliabilityMonitor* domain_reliability_monitor_; | 225 domain_reliability::DomainReliabilityMonitor* domain_reliability_monitor_; |
225 | 226 |
226 // When true, allow access to all file:// URLs. | 227 // When true, allow access to all file:// URLs. |
227 static bool g_allow_file_access_; | 228 static bool g_allow_file_access_; |
228 | 229 |
229 // True if OnCanThrottleRequest should always return false. | 230 // True if OnCanThrottleRequest should always return false. |
230 // | 231 // |
231 // Note: This needs to be static as the instance of | 232 // Note: This needs to be static as the instance of |
232 // ChromeNetworkDelegate used may change over time, and we need to | 233 // ChromeNetworkDelegate used may change over time, and we need to |
233 // set this variable once at start-up time. It is effectively | 234 // set this variable once at start-up time. It is effectively |
(...skipping 12 matching lines...) Expand all Loading... |
246 bool first_request_; | 247 bool first_request_; |
247 | 248 |
248 prerender::PrerenderTracker* prerender_tracker_; | 249 prerender::PrerenderTracker* prerender_tracker_; |
249 | 250 |
250 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; | 251 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; |
251 | 252 |
252 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 253 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
253 }; | 254 }; |
254 | 255 |
255 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 256 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |