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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "net/base/network_delegate.h" | 12 #include "net/base/network_delegate.h" |
13 | 13 |
14 class CookieSettings; | 14 class CookieSettings; |
15 class ExtensionEventRouterForwarder; | 15 class ExtensionEventRouterForwarder; |
16 class ExtensionInfoMap; | 16 class ExtensionInfoMap; |
17 class PrefService; | 17 class PrefService; |
18 template<class T> class PrefMember; | 18 template<class T> class PrefMember; |
19 | 19 |
20 typedef PrefMember<bool> BooleanPrefMember; | 20 typedef PrefMember<bool> BooleanPrefMember; |
21 | 21 |
| 22 namespace chrome_browser_net { |
| 23 class ResourcePrefetchPredictorObserver; |
| 24 } |
| 25 |
| 26 namespace predictors { |
| 27 class ResourcePrefetchPredictor; |
| 28 } |
| 29 |
22 namespace policy { | 30 namespace policy { |
23 class URLBlacklistManager; | 31 class URLBlacklistManager; |
24 } | 32 } |
25 | 33 |
26 // ChromeNetworkDelegate is the central point from within the chrome code to | 34 // ChromeNetworkDelegate is the central point from within the chrome code to |
27 // add hooks into the network stack. | 35 // add hooks into the network stack. |
28 class ChromeNetworkDelegate : public net::NetworkDelegate { | 36 class ChromeNetworkDelegate : public net::NetworkDelegate { |
29 public: | 37 public: |
30 // If |profile| is NULL, events will be broadcasted to all profiles, | 38 // If |profile| is NULL, events will be broadcasted to all profiles, |
31 // otherwise they will only be sent to the specified profile. | 39 // otherwise they will only be sent to the specified profile. |
32 // |enable_referrers| should be initialized on the UI thread (see below) | 40 // |enable_referrers| should be initialized on the UI thread (see below) |
33 // beforehand. This object's owner is responsible for cleaning it up at | 41 // beforehand. This object's owner is responsible for cleaning it up at |
34 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, | 42 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, |
35 // otherwise, the settings are enforced on all observed network requests. | 43 // otherwise, the settings are enforced on all observed network requests. |
36 ChromeNetworkDelegate( | 44 ChromeNetworkDelegate( |
37 ExtensionEventRouterForwarder* event_router, | 45 ExtensionEventRouterForwarder* event_router, |
38 ExtensionInfoMap* extension_info_map, | 46 ExtensionInfoMap* extension_info_map, |
39 const policy::URLBlacklistManager* url_blacklist_manager, | 47 const policy::URLBlacklistManager* url_blacklist_manager, |
40 void* profile, | 48 void* profile, |
41 CookieSettings* cookie_settings, | 49 CookieSettings* cookie_settings, |
| 50 scoped_refptr<predictors::ResourcePrefetchPredictor> |
| 51 resource_prefetch_predictor, |
42 BooleanPrefMember* enable_referrers); | 52 BooleanPrefMember* enable_referrers); |
43 virtual ~ChromeNetworkDelegate(); | 53 virtual ~ChromeNetworkDelegate(); |
44 | 54 |
45 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. | 55 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. |
46 // This method should be called on the UI thread. | 56 // This method should be called on the UI thread. |
47 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, | 57 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, |
48 PrefService* pref_service); | 58 PrefService* pref_service); |
49 | 59 |
50 // When called, all file:// URLs will now be accessible. If this is not | 60 // When called, all file:// URLs will now be accessible. If this is not |
51 // called, then some platforms restrict access to file:// paths. | 61 // called, then some platforms restrict access to file:// paths. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 net::CookieOptions* options) OVERRIDE; | 98 net::CookieOptions* options) OVERRIDE; |
89 virtual bool OnCanAccessFile(const net::URLRequest& request, | 99 virtual bool OnCanAccessFile(const net::URLRequest& request, |
90 const FilePath& path) const OVERRIDE; | 100 const FilePath& path) const OVERRIDE; |
91 | 101 |
92 scoped_refptr<ExtensionEventRouterForwarder> event_router_; | 102 scoped_refptr<ExtensionEventRouterForwarder> event_router_; |
93 void* profile_; | 103 void* profile_; |
94 scoped_refptr<CookieSettings> cookie_settings_; | 104 scoped_refptr<CookieSettings> cookie_settings_; |
95 | 105 |
96 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 106 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
97 | 107 |
| 108 scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> |
| 109 resource_prefetch_predictor_observer_; |
| 110 |
98 // Weak, owned by our owner. | 111 // Weak, owned by our owner. |
99 BooleanPrefMember* enable_referrers_; | 112 BooleanPrefMember* enable_referrers_; |
100 | 113 |
101 // Weak, owned by our owner. | 114 // Weak, owned by our owner. |
102 const policy::URLBlacklistManager* url_blacklist_manager_; | 115 const policy::URLBlacklistManager* url_blacklist_manager_; |
103 | 116 |
104 // When true, allow access to all file:// URLs. | 117 // When true, allow access to all file:// URLs. |
105 static bool g_allow_file_access_; | 118 static bool g_allow_file_access_; |
106 | 119 |
107 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); | 120 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); |
108 }; | 121 }; |
109 | 122 |
110 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ | 123 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ |
OLD | NEW |