blob: f48358527d39f6c9a6b88c8080cf5e6a9415e56a [file] [log] [blame]
[email protected]9045b8822012-01-13 20:35:351// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ac039522010-06-15 16:39:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/net/chrome_network_delegate.h"
6
7#include "base/logging.h"
[email protected]c5aa8262012-08-21 11:19:548#include "chrome/browser/api/prefs/pref_member.h"
[email protected]6baff0b52012-03-06 01:30:189#include "chrome/browser/browser_process.h"
[email protected]9c8ae8c2012-03-09 13:13:3510#include "chrome/browser/content_settings/cookie_settings.h"
11#include "chrome/browser/content_settings/tab_specific_content_settings.h"
[email protected]8523ba52011-05-22 19:00:5812#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
[email protected]aa84a7e2012-03-15 21:29:0613#include "chrome/browser/extensions/api/proxy/proxy_api.h"
[email protected]2b33dcd02012-03-18 01:34:1614#include "chrome/browser/extensions/api/web_request/web_request_api.h"
[email protected]5a38dfd2012-07-23 23:22:1015#include "chrome/browser/extensions/event_router_forwarder.h"
[email protected]c357acb42011-06-09 20:52:4216#include "chrome/browser/extensions/extension_info_map.h"
[email protected]6baff0b52012-03-06 01:30:1817#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]a9e0d1412012-08-20 22:13:0118#include "chrome/browser/net/load_time_stats.h"
[email protected]6baff0b52012-03-06 01:30:1819#include "chrome/browser/profiles/profile_manager.h"
[email protected]8523ba52011-05-22 19:00:5820#include "chrome/browser/task_manager/task_manager.h"
[email protected]0a8db0d2011-04-13 15:15:4021#include "chrome/common/pref_names.h"
[email protected]a1d4ab072012-06-07 13:21:1522#include "chrome/common/url_constants.h"
[email protected]c38831a12011-10-28 12:44:4923#include "content/public/browser/browser_thread.h"
[email protected]9c1662b2012-03-06 15:44:3324#include "content/public/browser/render_view_host.h"
[email protected]9c8ae8c2012-03-09 13:13:3525#include "content/public/browser/resource_request_info.h"
[email protected]82b42302011-04-20 16:28:1626#include "net/base/host_port_pair.h"
[email protected]8202d0c2011-02-23 08:31:1427#include "net/base/net_errors.h"
[email protected]6a5f77c32011-09-04 19:19:5928#include "net/base/net_log.h"
[email protected]5b9bc352012-07-18 13:13:3429#include "net/cookies/canonical_cookie.h"
30#include "net/cookies/cookie_options.h"
[email protected]ac039522010-06-15 16:39:4431#include "net/http/http_request_headers.h"
[email protected]48944382011-04-23 13:28:1632#include "net/http/http_response_headers.h"
[email protected]aa28181e2012-06-13 00:53:5833#include "net/socket_stream/socket_stream.h"
[email protected]d05ef99c2011-02-01 21:38:1634#include "net/url_request/url_request.h"
35
[email protected]e9c41d22012-08-17 00:08:1536#if !defined(OS_ANDROID)
37#include "chrome/browser/managed_mode_url_filter.h"
38#endif
39
[email protected]4c219e22012-05-05 19:41:0440#if defined(OS_CHROMEOS)
41#include "base/chromeos/chromeos_version.h"
42#endif
43
[email protected]3e598ff12011-09-06 11:22:3444#if defined(ENABLE_CONFIGURATION_POLICY)
45#include "chrome/browser/policy/url_blacklist_manager.h"
46#endif
47
[email protected]631bb742011-11-02 11:29:3948using content::BrowserThread;
[email protected]eaabba22012-03-07 15:02:1149using content::RenderViewHost;
[email protected]ea114722012-03-12 01:11:2550using content::ResourceRequestInfo;
[email protected]631bb742011-11-02 11:29:3951
[email protected]4c219e22012-05-05 19:41:0452// By default we don't allow access to all file:// urls on ChromeOS but we do on
53// other platforms.
54#if defined(OS_CHROMEOS)
55bool ChromeNetworkDelegate::g_allow_file_access_ = false;
56#else
57bool ChromeNetworkDelegate::g_allow_file_access_ = true;
58#endif
59
[email protected]c4a7df82012-08-09 22:48:4660// This remains false unless the --disable-extensions-http-throttling
61// flag is passed to the browser.
62bool ChromeNetworkDelegate::g_never_throttle_requests_ = false;
63
[email protected]d05ef99c2011-02-01 21:38:1664namespace {
65
[email protected]8202d0c2011-02-23 08:31:1466// If the |request| failed due to problems with a proxy, forward the error to
67// the proxy extension API.
[email protected]0651b812011-02-24 00:22:5068void ForwardProxyErrors(net::URLRequest* request,
[email protected]5a38dfd2012-07-23 23:22:1069 extensions::EventRouterForwarder* event_router,
[email protected]673514522011-07-13 18:17:1870 void* profile) {
[email protected]8202d0c2011-02-23 08:31:1471 if (request->status().status() == net::URLRequestStatus::FAILED) {
[email protected]d0cc35b2011-09-08 12:02:0572 switch (request->status().error()) {
[email protected]8202d0c2011-02-23 08:31:1473 case net::ERR_PROXY_AUTH_UNSUPPORTED:
74 case net::ERR_PROXY_CONNECTION_FAILED:
75 case net::ERR_TUNNEL_CONNECTION_FAILED:
[email protected]c454fe672012-03-12 21:18:0176 extensions::ProxyEventRouter::GetInstance()->OnProxyError(
[email protected]d0cc35b2011-09-08 12:02:0577 event_router, profile, request->status().error());
[email protected]8202d0c2011-02-23 08:31:1478 }
79 }
80}
81
[email protected]6baff0b52012-03-06 01:30:1882enum RequestStatus { REQUEST_STARTED, REQUEST_DONE };
83
84// Notifies the ExtensionProcessManager that a request has started or stopped
85// for a particular RenderView.
86void NotifyEPMRequestStatus(RequestStatus status,
87 void* profile_id,
88 int process_id,
89 int render_view_id) {
90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
91 Profile* profile = reinterpret_cast<Profile*>(profile_id);
92 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
93 return;
94
[email protected]e5775a52012-03-17 04:59:5795 ExtensionProcessManager* extension_process_manager =
96 profile->GetExtensionProcessManager();
97 // This may be NULL in unit tests.
98 if (!extension_process_manager)
99 return;
100
[email protected]6baff0b52012-03-06 01:30:18101 // Will be NULL if the request was not issued on behalf of a renderer (e.g. a
102 // system-level request).
[email protected]d3e898e2012-03-14 03:45:08103 RenderViewHost* render_view_host =
104 RenderViewHost::FromID(process_id, render_view_id);
[email protected]e5775a52012-03-17 04:59:57105 if (render_view_host) {
[email protected]6baff0b52012-03-06 01:30:18106 if (status == REQUEST_STARTED) {
[email protected]d3e898e2012-03-14 03:45:08107 extension_process_manager->OnNetworkRequestStarted(render_view_host);
[email protected]6baff0b52012-03-06 01:30:18108 } else if (status == REQUEST_DONE) {
[email protected]d3e898e2012-03-14 03:45:08109 extension_process_manager->OnNetworkRequestDone(render_view_host);
[email protected]6baff0b52012-03-06 01:30:18110 } else {
111 NOTREACHED();
112 }
113 }
114}
115
116void ForwardRequestStatus(
117 RequestStatus status, net::URLRequest* request, void* profile_id) {
[email protected]ea114722012-03-12 01:11:25118 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
119 if (!info)
120 return;
121
[email protected]6baff0b52012-03-06 01:30:18122 int process_id, render_view_id;
[email protected]ea114722012-03-12 01:11:25123 if (info->GetAssociatedRenderView(&process_id, &render_view_id)) {
[email protected]6baff0b52012-03-06 01:30:18124 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
125 base::Bind(&NotifyEPMRequestStatus,
126 status, profile_id, process_id, render_view_id));
127 }
128}
129
[email protected]d05ef99c2011-02-01 21:38:16130} // namespace
[email protected]ac039522010-06-15 16:39:44131
[email protected]0651b812011-02-24 00:22:50132ChromeNetworkDelegate::ChromeNetworkDelegate(
[email protected]5a38dfd2012-07-23 23:22:10133 extensions::EventRouterForwarder* event_router,
[email protected]c357acb42011-06-09 20:52:42134 ExtensionInfoMap* extension_info_map,
[email protected]6a5f77c32011-09-04 19:19:59135 const policy::URLBlacklistManager* url_blacklist_manager,
[email protected]e9c41d22012-08-17 00:08:15136 const ManagedModeURLFilter* managed_mode_url_filter,
[email protected]673514522011-07-13 18:17:18137 void* profile,
[email protected]9c8ae8c2012-03-09 13:13:35138 CookieSettings* cookie_settings,
[email protected]5a07c192012-07-30 20:18:22139 BooleanPrefMember* enable_referrers,
[email protected]a9e0d1412012-08-20 22:13:01140 chrome_browser_net::LoadTimeStats* load_time_stats)
[email protected]3ce02412011-03-01 12:01:15141 : event_router_(event_router),
[email protected]673514522011-07-13 18:17:18142 profile_(profile),
[email protected]9c8ae8c2012-03-09 13:13:35143 cookie_settings_(cookie_settings),
[email protected]c357acb42011-06-09 20:52:42144 extension_info_map_(extension_info_map),
[email protected]6a5f77c32011-09-04 19:19:59145 enable_referrers_(enable_referrers),
[email protected]5a07c192012-07-30 20:18:22146 url_blacklist_manager_(url_blacklist_manager),
[email protected]e9c41d22012-08-17 00:08:15147 managed_mode_url_filter_(managed_mode_url_filter),
[email protected]a9e0d1412012-08-20 22:13:01148 load_time_stats_(load_time_stats) {
[email protected]4b50cb52011-03-10 00:29:37149 DCHECK(event_router);
[email protected]0a8db0d2011-04-13 15:15:40150 DCHECK(enable_referrers);
[email protected]9c8ae8c2012-03-09 13:13:35151 DCHECK(!profile || cookie_settings);
[email protected]0651b812011-02-24 00:22:50152}
153
[email protected]ac039522010-06-15 16:39:44154ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
155
[email protected]c4a7df82012-08-09 22:48:46156// static
[email protected]a1d4ab072012-06-07 13:21:15157void ChromeNetworkDelegate::NeverThrottleRequests() {
[email protected]c4a7df82012-08-09 22:48:46158 g_never_throttle_requests_ = true;
[email protected]a1d4ab072012-06-07 13:21:15159}
160
[email protected]0a8db0d2011-04-13 15:15:40161// static
162void ChromeNetworkDelegate::InitializeReferrersEnabled(
163 BooleanPrefMember* enable_referrers,
164 PrefService* pref_service) {
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
166 enable_referrers->Init(prefs::kEnableReferrers, pref_service, NULL);
167 enable_referrers->MoveToThread(BrowserThread::IO);
168}
169
[email protected]4c219e22012-05-05 19:41:04170// static
171void ChromeNetworkDelegate::AllowAccessToAllFiles() {
172 g_allow_file_access_ = true;
173}
174
[email protected]4875ba12011-03-30 22:31:51175int ChromeNetworkDelegate::OnBeforeURLRequest(
[email protected]4c76d7c2011-04-15 19:14:12176 net::URLRequest* request,
[email protected]084262c2011-12-01 21:12:47177 const net::CompletionCallback& callback,
[email protected]4c76d7c2011-04-15 19:14:12178 GURL* new_url) {
[email protected]3e598ff12011-09-06 11:22:34179#if defined(ENABLE_CONFIGURATION_POLICY)
[email protected]6a5f77c32011-09-04 19:19:59180 // TODO(joaodasilva): This prevents extensions from seeing URLs that are
181 // blocked. However, an extension might redirect the request to another URL,
182 // which is not blocked.
183 if (url_blacklist_manager_ &&
184 url_blacklist_manager_->IsURLBlocked(request->url())) {
185 // URL access blocked by policy.
[email protected]6a5f77c32011-09-04 19:19:59186 request->net_log().AddEvent(
[email protected]2fa08912012-06-14 20:56:26187 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
188 net::NetLog::StringCallback("url",
189 &request->url().possibly_invalid_spec()));
[email protected]6a5f77c32011-09-04 19:19:59190 return net::ERR_NETWORK_ACCESS_DENIED;
191 }
[email protected]3e598ff12011-09-06 11:22:34192#endif
[email protected]6a5f77c32011-09-04 19:19:59193
[email protected]e9c41d22012-08-17 00:08:15194#if !defined(OS_ANDROID)
195 if (managed_mode_url_filter_ &&
196 !managed_mode_url_filter_->IsURLWhitelisted(request->url())) {
197 // Block for now.
198 return net::ERR_NETWORK_ACCESS_DENIED;
199 }
200#endif
201
[email protected]6baff0b52012-03-06 01:30:18202 ForwardRequestStatus(REQUEST_STARTED, request, profile_);
203
[email protected]0a8db0d2011-04-13 15:15:40204 if (!enable_referrers_->GetValue())
205 request->set_referrer(std::string());
[email protected]05cc4e72011-03-08 21:29:48206 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
[email protected]673514522011-07-13 18:17:18207 profile_, extension_info_map_.get(), request, callback, new_url);
[email protected]d05ef99c2011-02-01 21:38:16208}
209
[email protected]4875ba12011-03-30 22:31:51210int ChromeNetworkDelegate::OnBeforeSendHeaders(
[email protected]636eccd2011-06-28 12:28:01211 net::URLRequest* request,
[email protected]084262c2011-12-01 21:12:47212 const net::CompletionCallback& callback,
[email protected]4c76d7c2011-04-15 19:14:12213 net::HttpRequestHeaders* headers) {
[email protected]4875ba12011-03-30 22:31:51214 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeSendHeaders(
[email protected]673514522011-07-13 18:17:18215 profile_, extension_info_map_.get(), request, callback, headers);
[email protected]ac039522010-06-15 16:39:44216}
[email protected]8202d0c2011-02-23 08:31:14217
[email protected]5796dc942011-07-14 19:26:10218void ChromeNetworkDelegate::OnSendHeaders(
219 net::URLRequest* request,
[email protected]783573b2011-05-13 11:05:15220 const net::HttpRequestHeaders& headers) {
[email protected]5796dc942011-07-14 19:26:10221 ExtensionWebRequestEventRouter::GetInstance()->OnSendHeaders(
222 profile_, extension_info_map_.get(), request, headers);
[email protected]82b42302011-04-20 16:28:16223}
224
[email protected]ea8141e2011-10-05 13:12:51225int ChromeNetworkDelegate::OnHeadersReceived(
226 net::URLRequest* request,
[email protected]084262c2011-12-01 21:12:47227 const net::CompletionCallback& callback,
[email protected]ea8141e2011-10-05 13:12:51228 net::HttpResponseHeaders* original_response_headers,
229 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
230 return ExtensionWebRequestEventRouter::GetInstance()->OnHeadersReceived(
231 profile_, extension_info_map_.get(), request, callback,
232 original_response_headers, override_response_headers);
233}
234
[email protected]31b2e5f2011-04-20 16:58:32235void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
236 const GURL& new_location) {
237 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect(
[email protected]673514522011-07-13 18:17:18238 profile_, extension_info_map_.get(), request, new_location);
[email protected]31b2e5f2011-04-20 16:58:32239}
240
241
[email protected]8202d0c2011-02-23 08:31:14242void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
[email protected]62fecae2011-04-21 11:08:24243 ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted(
[email protected]673514522011-07-13 18:17:18244 profile_, extension_info_map_.get(), request);
245 ForwardProxyErrors(request, event_router_.get(), profile_);
[email protected]8202d0c2011-02-23 08:31:14246}
247
[email protected]8523ba52011-05-22 19:00:58248void ChromeNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
249 int bytes_read) {
[email protected]44879ed2012-04-06 01:11:02250#if defined(ENABLE_TASK_MANAGER)
[email protected]8523ba52011-05-22 19:00:58251 TaskManager::GetInstance()->model()->NotifyBytesRead(request, bytes_read);
[email protected]44879ed2012-04-06 01:11:02252#endif // defined(ENABLE_TASK_MANAGER)
[email protected]8523ba52011-05-22 19:00:58253}
254
[email protected]9045b8822012-01-13 20:35:35255void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
256 bool started) {
[email protected]a83dd332011-07-13 10:41:01257 if (request->status().status() == net::URLRequestStatus::SUCCESS ||
258 request->status().status() == net::URLRequestStatus::HANDLED_EXTERNALLY) {
[email protected]48944382011-04-23 13:28:16259 bool is_redirect = request->response_headers() &&
260 net::HttpResponseHeaders::IsRedirectResponseCode(
261 request->response_headers()->response_code());
262 if (!is_redirect) {
263 ExtensionWebRequestEventRouter::GetInstance()->OnCompleted(
[email protected]673514522011-07-13 18:17:18264 profile_, extension_info_map_.get(), request);
[email protected]48944382011-04-23 13:28:16265 }
[email protected]a83dd332011-07-13 10:41:01266 } else if (request->status().status() == net::URLRequestStatus::FAILED ||
267 request->status().status() == net::URLRequestStatus::CANCELED) {
[email protected]05b6ab42011-04-23 13:46:04268 ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred(
[email protected]9045b8822012-01-13 20:35:35269 profile_, extension_info_map_.get(), request, started);
[email protected]a83dd332011-07-13 10:41:01270 } else {
271 NOTREACHED();
[email protected]48944382011-04-23 13:28:16272 }
[email protected]673514522011-07-13 18:17:18273 ForwardProxyErrors(request, event_router_.get(), profile_);
[email protected]6baff0b52012-03-06 01:30:18274
275 ForwardRequestStatus(REQUEST_DONE, request, profile_);
[email protected]8202d0c2011-02-23 08:31:14276}
[email protected]4b50cb52011-03-10 00:29:37277
[email protected]4875ba12011-03-30 22:31:51278void ChromeNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
279 ExtensionWebRequestEventRouter::GetInstance()->OnURLRequestDestroyed(
[email protected]673514522011-07-13 18:17:18280 profile_, request);
[email protected]4875ba12011-03-30 22:31:51281}
282
[email protected]82a37672011-05-03 12:02:41283void ChromeNetworkDelegate::OnPACScriptError(int line_number,
284 const string16& error) {
[email protected]c454fe672012-03-12 21:18:01285 extensions::ProxyEventRouter::GetInstance()->OnPACScriptError(
[email protected]673514522011-07-13 18:17:18286 event_router_.get(), profile_, line_number, error);
[email protected]82a37672011-05-03 12:02:41287}
[email protected]7efc582d2011-08-03 20:46:35288
[email protected]c2911d72011-10-03 22:16:36289net::NetworkDelegate::AuthRequiredResponse
290ChromeNetworkDelegate::OnAuthRequired(
[email protected]7efc582d2011-08-03 20:46:35291 net::URLRequest* request,
[email protected]c2911d72011-10-03 22:16:36292 const net::AuthChallengeInfo& auth_info,
293 const AuthCallback& callback,
294 net::AuthCredentials* credentials) {
[email protected]90449ab2011-10-11 15:36:45295 return ExtensionWebRequestEventRouter::GetInstance()->OnAuthRequired(
296 profile_, extension_info_map_.get(), request, auth_info,
297 callback, credentials);
[email protected]7efc582d2011-08-03 20:46:35298}
[email protected]9c8ae8c2012-03-09 13:13:35299
[email protected]4c219e22012-05-05 19:41:04300bool ChromeNetworkDelegate::OnCanGetCookies(
301 const net::URLRequest& request,
[email protected]9c8ae8c2012-03-09 13:13:35302 const net::CookieList& cookie_list) {
303 // NULL during tests, or when we're running in the system context.
304 if (!cookie_settings_)
305 return true;
306
307 bool allow = cookie_settings_->IsReadingCookieAllowed(
[email protected]4c219e22012-05-05 19:41:04308 request.url(), request.first_party_for_cookies());
[email protected]9c8ae8c2012-03-09 13:13:35309
310 int render_process_id = -1;
311 int render_view_id = -1;
312 if (content::ResourceRequestInfo::GetRenderViewForRequest(
[email protected]4c219e22012-05-05 19:41:04313 &request, &render_process_id, &render_view_id)) {
[email protected]9c8ae8c2012-03-09 13:13:35314 BrowserThread::PostTask(
315 BrowserThread::UI, FROM_HERE,
316 base::Bind(&TabSpecificContentSettings::CookiesRead,
317 render_process_id, render_view_id,
[email protected]4c219e22012-05-05 19:41:04318 request.url(), request.first_party_for_cookies(),
[email protected]fd473d12012-04-05 11:38:43319 cookie_list, !allow));
[email protected]9c8ae8c2012-03-09 13:13:35320 }
321
322 return allow;
323}
324
[email protected]4c219e22012-05-05 19:41:04325bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
326 const std::string& cookie_line,
327 net::CookieOptions* options) {
[email protected]9c8ae8c2012-03-09 13:13:35328 // NULL during tests, or when we're running in the system context.
329 if (!cookie_settings_)
330 return true;
331
332 bool allow = cookie_settings_->IsSettingCookieAllowed(
[email protected]4c219e22012-05-05 19:41:04333 request.url(), request.first_party_for_cookies());
[email protected]9c8ae8c2012-03-09 13:13:35334
[email protected]9c8ae8c2012-03-09 13:13:35335 int render_process_id = -1;
336 int render_view_id = -1;
337 if (content::ResourceRequestInfo::GetRenderViewForRequest(
[email protected]4c219e22012-05-05 19:41:04338 &request, &render_process_id, &render_view_id)) {
[email protected]9c8ae8c2012-03-09 13:13:35339 BrowserThread::PostTask(
340 BrowserThread::UI, FROM_HERE,
341 base::Bind(&TabSpecificContentSettings::CookieChanged,
342 render_process_id, render_view_id,
[email protected]4c219e22012-05-05 19:41:04343 request.url(), request.first_party_for_cookies(),
[email protected]fd473d12012-04-05 11:38:43344 cookie_line, *options, !allow));
[email protected]9c8ae8c2012-03-09 13:13:35345 }
346
347 return allow;
348}
[email protected]4c219e22012-05-05 19:41:04349
350bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
351 const FilePath& path) const {
352 if (g_allow_file_access_)
353 return true;
354
355#if defined(OS_CHROMEOS)
356 // ChromeOS uses a whitelist to only allow access to files residing in the
357 // list of directories below.
358 static const char* const kLocalAccessWhiteList[] = {
359 "/home/chronos/user/Downloads",
360 "/home/chronos/user/log",
361 "/media",
362 "/opt/oem",
363 "/usr/share/chromeos-assets",
364 "/tmp",
365 "/var/log",
366 };
367
368 // If we're running Chrome for ChromeOS on Linux, we want to allow file
369 // access.
370 if (!base::chromeos::IsRunningOnChromeOS())
371 return true;
372
373 for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) {
374 const FilePath white_listed_path(kLocalAccessWhiteList[i]);
375 // FilePath::operator== should probably handle trailing separators.
376 if (white_listed_path == path.StripTrailingSeparators() ||
377 white_listed_path.IsParent(path)) {
378 return true;
379 }
380 }
381 return false;
382#else
383 return true;
384#endif // defined(OS_CHROMEOS)
385}
[email protected]a1d4ab072012-06-07 13:21:15386
387bool ChromeNetworkDelegate::OnCanThrottleRequest(
388 const net::URLRequest& request) const {
[email protected]c4a7df82012-08-09 22:48:46389 if (g_never_throttle_requests_) {
[email protected]a1d4ab072012-06-07 13:21:15390 return false;
391 }
392
[email protected]c4a7df82012-08-09 22:48:46393 return request.first_party_for_cookies().scheme() ==
[email protected]a1d4ab072012-06-07 13:21:15394 chrome::kExtensionScheme;
395}
[email protected]aa28181e2012-06-13 00:53:58396
397int ChromeNetworkDelegate::OnBeforeSocketStreamConnect(
398 net::SocketStream* socket,
399 const net::CompletionCallback& callback) {
400#if defined(ENABLE_CONFIGURATION_POLICY)
401 if (url_blacklist_manager_ &&
402 url_blacklist_manager_->IsURLBlocked(socket->url())) {
403 // URL access blocked by policy.
[email protected]aa28181e2012-06-13 00:53:58404 socket->net_log()->AddEvent(
[email protected]2fa08912012-06-14 20:56:26405 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
406 net::NetLog::StringCallback("url",
407 &socket->url().possibly_invalid_spec()));
[email protected]aa28181e2012-06-13 00:53:58408 return net::ERR_NETWORK_ACCESS_DENIED;
409 }
410#endif
411 return net::OK;
412}
[email protected]5a07c192012-07-30 20:18:22413
[email protected]a9e0d1412012-08-20 22:13:01414void ChromeNetworkDelegate::OnRequestWaitStateChange(
[email protected]5a07c192012-07-30 20:18:22415 const net::URLRequest& request,
[email protected]a9e0d1412012-08-20 22:13:01416 RequestWaitState state) {
417 if (load_time_stats_)
418 load_time_stats_->OnRequestWaitStateChange(request, state);
[email protected]5a07c192012-07-30 20:18:22419}