OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 #if defined(OS_WIN) | 229 #if defined(OS_WIN) |
230 #pragma warning(disable: 4748) | 230 #pragma warning(disable: 4748) |
231 #pragma optimize("", off) | 231 #pragma optimize("", off) |
232 #endif | 232 #endif |
233 | 233 |
234 #if defined(OS_WIN) | 234 #if defined(OS_WIN) |
235 #pragma optimize("", on) | 235 #pragma optimize("", on) |
236 #pragma warning(default: 4748) | 236 #pragma warning(default: 4748) |
237 #endif | 237 #endif |
238 | 238 |
239 // Relationship of resource being authenticated with the top level page. | |
240 enum HttpAuthResourceType { | |
241 HTTP_AUTH_RESOURCE_TOP, // Top-level page itself | |
242 HTTP_AUTH_RESOURCE_SAME_DOMAIN, // Sub-content from same domain | |
243 HTTP_AUTH_RESOURCE_BLOCKED_CROSS, // Blocked Sub-content from cross domain | |
244 HTTP_AUTH_RESOURCE_ALLOWED_CROSS, // Allowed Sub-content per command line | |
245 HTTP_AUTH_RESOURCE_LAST | |
246 }; | |
247 | |
248 HttpAuthResourceType HttpAuthResourceTypeOf(net::URLRequest* request) { | |
249 // Use the same critera as for cookies to determine the sub-resource type | |
250 // that is requesting to be authenticated. | |
251 if (!request->first_party_for_cookies().is_valid()) | |
252 return HTTP_AUTH_RESOURCE_TOP; | |
253 | |
254 if (net::RegistryControlledDomainService::SameDomainOrHost( | |
255 request->first_party_for_cookies(), request->url())) | |
256 return HTTP_AUTH_RESOURCE_SAME_DOMAIN; | |
257 | |
258 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
259 switches::kAllowCrossOriginAuthPrompt)) | |
260 return HTTP_AUTH_RESOURCE_ALLOWED_CROSS; | |
261 | |
262 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; | |
263 } | |
264 | |
265 } // namespace | 239 } // namespace |
266 | 240 |
267 ResourceDispatcherHost::ResourceDispatcherHost( | 241 ResourceDispatcherHost::ResourceDispatcherHost( |
268 const ResourceQueue::DelegateSet& resource_queue_delegates) | 242 const ResourceQueue::DelegateSet& resource_queue_delegates) |
269 : ALLOW_THIS_IN_INITIALIZER_LIST( | 243 : ALLOW_THIS_IN_INITIALIZER_LIST( |
270 download_file_manager_(new DownloadFileManager(this))), | 244 download_file_manager_(new DownloadFileManager(this))), |
271 download_request_limiter_(new DownloadRequestLimiter()), | 245 download_request_limiter_(new DownloadRequestLimiter()), |
272 ALLOW_THIS_IN_INITIALIZER_LIST( | 246 ALLOW_THIS_IN_INITIALIZER_LIST( |
273 save_file_manager_(new SaveFileManager(this))), | 247 save_file_manager_(new SaveFileManager(this))), |
274 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), | 248 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), |
275 webkit_thread_(new WebKitThread), | 249 webkit_thread_(new WebKitThread), |
276 request_id_(-1), | 250 request_id_(-1), |
277 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), | 251 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), |
278 is_shutdown_(false), | 252 is_shutdown_(false), |
279 max_outstanding_requests_cost_per_process_( | 253 max_outstanding_requests_cost_per_process_( |
280 kMaxOutstandingRequestsCostPerProcess), | 254 kMaxOutstandingRequestsCostPerProcess), |
281 filter_(NULL), | 255 filter_(NULL), |
282 observer_(NULL) { | 256 observer_(NULL), |
| 257 allow_cross_origin_auth_prompt_(false) { |
283 resource_queue_.Initialize(resource_queue_delegates); | 258 resource_queue_.Initialize(resource_queue_delegates); |
284 } | 259 } |
285 | 260 |
286 ResourceDispatcherHost::~ResourceDispatcherHost() { | 261 ResourceDispatcherHost::~ResourceDispatcherHost() { |
287 AsyncResourceHandler::GlobalCleanup(); | 262 AsyncResourceHandler::GlobalCleanup(); |
288 STLDeleteValues(&pending_requests_); | 263 STLDeleteValues(&pending_requests_); |
289 } | 264 } |
290 | 265 |
291 void ResourceDispatcherHost::Initialize() { | 266 void ResourceDispatcherHost::Initialize() { |
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 return is_prefetch_enabled_; | 1990 return is_prefetch_enabled_; |
2016 } | 1991 } |
2017 | 1992 |
2018 // static | 1993 // static |
2019 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1994 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
2020 is_prefetch_enabled_ = value; | 1995 is_prefetch_enabled_ = value; |
2021 } | 1996 } |
2022 | 1997 |
2023 // static | 1998 // static |
2024 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1999 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| 2000 |
| 2001 ResourceDispatcherHost::HttpAuthResourceType |
| 2002 ResourceDispatcherHost::HttpAuthResourceTypeOf(net::URLRequest* request) { |
| 2003 // Use the same critera as for cookies to determine the sub-resource type |
| 2004 // that is requesting to be authenticated. |
| 2005 if (!request->first_party_for_cookies().is_valid()) |
| 2006 return HTTP_AUTH_RESOURCE_TOP; |
| 2007 |
| 2008 if (net::RegistryControlledDomainService::SameDomainOrHost( |
| 2009 request->first_party_for_cookies(), request->url())) |
| 2010 return HTTP_AUTH_RESOURCE_SAME_DOMAIN; |
| 2011 |
| 2012 if (allow_cross_origin_auth_prompt()) |
| 2013 return HTTP_AUTH_RESOURCE_ALLOWED_CROSS; |
| 2014 |
| 2015 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; |
| 2016 } |
| 2017 |
| 2018 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { |
| 2019 return allow_cross_origin_auth_prompt_; |
| 2020 } |
| 2021 |
| 2022 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { |
| 2023 allow_cross_origin_auth_prompt_ = value; |
| 2024 } |
| 2025 |
| 2026 |
OLD | NEW |