Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/net/chrome_network_delegate.h

Issue 10911283: Implement 'Do Not Track' header (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/net/chrome_network_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 18 matching lines...) Expand all
29 namespace policy { 29 namespace policy {
30 class URLBlacklistManager; 30 class URLBlacklistManager;
31 } 31 }
32 32
33 // ChromeNetworkDelegate is the central point from within the chrome code to 33 // ChromeNetworkDelegate is the central point from within the chrome code to
34 // add hooks into the network stack. 34 // add hooks into the network stack.
35 class ChromeNetworkDelegate : public net::NetworkDelegate { 35 class ChromeNetworkDelegate : public net::NetworkDelegate {
36 public: 36 public:
37 // If |profile| is NULL, events will be broadcasted to all profiles, 37 // If |profile| is NULL, events will be broadcasted to all profiles,
38 // otherwise they will only be sent to the specified profile. 38 // otherwise they will only be sent to the specified profile.
39 // |enable_referrers| should be initialized on the UI thread (see below) 39 // |enable_referrers| and |enable_do_not_track| should be initialized on the
40 // beforehand. This object's owner is responsible for cleaning it up at 40 // UI thread (see below) beforehand. This object's owner is responsible for
41 // shutdown. If |cookie_settings| is NULL, all cookies are enabled, 41 // cleaning it up at shutdown. |enable_do_not_track| can be NULL.
42 // otherwise, the settings are enforced on all observed network requests. 42 // If |cookie_settings| is NULL, all cookies are enabled, otherwise, the
43 // settings are enforced on all observed network requests.
43 ChromeNetworkDelegate( 44 ChromeNetworkDelegate(
44 extensions::EventRouterForwarder* event_router, 45 extensions::EventRouterForwarder* event_router,
45 ExtensionInfoMap* extension_info_map, 46 ExtensionInfoMap* extension_info_map,
46 const policy::URLBlacklistManager* url_blacklist_manager, 47 const policy::URLBlacklistManager* url_blacklist_manager,
47 const ManagedModeURLFilter* managed_mode_url_filter, 48 const ManagedModeURLFilter* managed_mode_url_filter,
48 void* profile, 49 void* profile,
49 CookieSettings* cookie_settings, 50 CookieSettings* cookie_settings,
50 BooleanPrefMember* enable_referrers, 51 BooleanPrefMember* enable_referrers,
52 BooleanPrefMember* enable_do_not_track,
51 chrome_browser_net::LoadTimeStats* load_time_stats); 53 chrome_browser_net::LoadTimeStats* load_time_stats);
52 virtual ~ChromeNetworkDelegate(); 54 virtual ~ChromeNetworkDelegate();
53 55
54 // Causes |OnCanThrottleRequest| to always return false, for all 56 // Causes |OnCanThrottleRequest| to always return false, for all
55 // instances of this object. 57 // instances of this object.
56 static void NeverThrottleRequests(); 58 static void NeverThrottleRequests();
57 59
58 // Binds |enable_referrers| to |pref_service| and moves it to the IO thread. 60 // Binds the pref members to |pref_service| and moves them to the IO thread.
61 // |enable_do_not_track| can be NULL.
59 // This method should be called on the UI thread. 62 // This method should be called on the UI thread.
60 static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers, 63 static void InitializePrefsOnUIThread(BooleanPrefMember* enable_referrers,
61 PrefService* pref_service); 64 BooleanPrefMember* enable_do_not_track,
65 PrefService* pref_service);
62 66
63 // When called, all file:// URLs will now be accessible. If this is not 67 // When called, all file:// URLs will now be accessible. If this is not
64 // called, then some platforms restrict access to file:// paths. 68 // called, then some platforms restrict access to file:// paths.
65 static void AllowAccessToAllFiles(); 69 static void AllowAccessToAllFiles();
66 70
67 private: 71 private:
68 friend class ChromeNetworkDelegateTest; 72 friend class ChromeNetworkDelegateTest;
69 73
70 // NetworkDelegate implementation. 74 // NetworkDelegate implementation.
71 virtual int OnBeforeURLRequest(net::URLRequest* request, 75 virtual int OnBeforeURLRequest(net::URLRequest* request,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 RequestWaitState state) OVERRIDE; 116 RequestWaitState state) OVERRIDE;
113 117
114 scoped_refptr<extensions::EventRouterForwarder> event_router_; 118 scoped_refptr<extensions::EventRouterForwarder> event_router_;
115 void* profile_; 119 void* profile_;
116 scoped_refptr<CookieSettings> cookie_settings_; 120 scoped_refptr<CookieSettings> cookie_settings_;
117 121
118 scoped_refptr<ExtensionInfoMap> extension_info_map_; 122 scoped_refptr<ExtensionInfoMap> extension_info_map_;
119 123
120 // Weak, owned by our owner. 124 // Weak, owned by our owner.
121 BooleanPrefMember* enable_referrers_; 125 BooleanPrefMember* enable_referrers_;
126 BooleanPrefMember* enable_do_not_track_;
122 127
123 // Weak, owned by our owner. 128 // Weak, owned by our owner.
124 const policy::URLBlacklistManager* url_blacklist_manager_; 129 const policy::URLBlacklistManager* url_blacklist_manager_;
125 130
126 // Weak pointer. The owner of this object needs to make sure that the 131 // Weak pointer. The owner of this object needs to make sure that the
127 // |managed_mode_url_filter_| outlives it. 132 // |managed_mode_url_filter_| outlives it.
128 const ManagedModeURLFilter* managed_mode_url_filter_; 133 const ManagedModeURLFilter* managed_mode_url_filter_;
129 134
130 // When true, allow access to all file:// URLs. 135 // When true, allow access to all file:// URLs.
131 static bool g_allow_file_access_; 136 static bool g_allow_file_access_;
132 137
133 // True if OnCanThrottleRequest should always return false. 138 // True if OnCanThrottleRequest should always return false.
134 // 139 //
135 // Note: This needs to be static as the instance of 140 // Note: This needs to be static as the instance of
136 // ChromeNetworkDelegate used may change over time, and we need to 141 // ChromeNetworkDelegate used may change over time, and we need to
137 // set this variable once at start-up time. It is effectively 142 // set this variable once at start-up time. It is effectively
138 // static anyway since it is based on a command-line flag. 143 // static anyway since it is based on a command-line flag.
139 static bool g_never_throttle_requests_; 144 static bool g_never_throttle_requests_;
140 145
141 // Pointer to IOThread global, should outlive ChromeNetworkDelegate. 146 // Pointer to IOThread global, should outlive ChromeNetworkDelegate.
142 chrome_browser_net::LoadTimeStats* load_time_stats_; 147 chrome_browser_net::LoadTimeStats* load_time_stats_;
143 148
144 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); 149 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate);
145 }; 150 };
146 151
147 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_ 152 #endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/net/chrome_network_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698