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 // 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/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 // validating the entry if present. | 521 // validating the entry if present. |
522 if (request->get_upload() != NULL) | 522 if (request->get_upload() != NULL) |
523 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE; | 523 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE; |
524 else | 524 else |
525 extra_load_flags |= net::LOAD_PREFERRING_CACHE; | 525 extra_load_flags |= net::LOAD_PREFERRING_CACHE; |
526 } else { | 526 } else { |
527 extra_load_flags |= net::LOAD_DISABLE_CACHE; | 527 extra_load_flags |= net::LOAD_DISABLE_CACHE; |
528 } | 528 } |
529 request->SetLoadFlags(request->load_flags() | extra_load_flags); | 529 request->SetLoadFlags(request->load_flags() | extra_load_flags); |
530 | 530 |
531 // We treat a download as a main frame load, and thus update the policy URL on | |
532 // redirects. | |
533 // | |
534 // TODO(davidben): Is this correct? If this came from a | |
535 // ViewHostMsg_DownloadUrl in a frame, should it have first-party URL set | |
536 // appropriately? | |
537 request->set_first_party_url_policy( | |
538 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | |
davidben
2014/07/17 22:03:55
This is from download_resource_handler. Given that
mmenke
2014/07/18 15:18:36
They don't get first party URLs? What if we don't
davidben
2014/07/18 16:14:58
Sorry, that was unclear. There's two codepaths for
| |
539 | |
531 // Check if the renderer is permitted to request the requested URL. | 540 // Check if the renderer is permitted to request the requested URL. |
532 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> | 541 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> |
533 CanRequestURL(child_id, url)) { | 542 CanRequestURL(child_id, url)) { |
534 VLOG(1) << "Denied unauthorized download request for " | 543 VLOG(1) << "Denied unauthorized download request for " |
535 << url.possibly_invalid_spec(); | 544 << url.possibly_invalid_spec(); |
536 return CallbackAndReturn(started_callback, | 545 return CallbackAndReturn(started_callback, |
537 DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST); | 546 DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST); |
538 } | 547 } |
539 | 548 |
540 request_id_--; | 549 request_id_--; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1045 GetContentClient()->browser()->OverrideCookieStoreForRenderProcess( | 1054 GetContentClient()->browser()->OverrideCookieStoreForRenderProcess( |
1046 child_id); | 1055 child_id); |
1047 scoped_ptr<net::URLRequest> new_request; | 1056 scoped_ptr<net::URLRequest> new_request; |
1048 new_request = request_context->CreateRequest( | 1057 new_request = request_context->CreateRequest( |
1049 request_data.url, request_data.priority, NULL, cookie_store); | 1058 request_data.url, request_data.priority, NULL, cookie_store); |
1050 | 1059 |
1051 new_request->set_method(request_data.method); | 1060 new_request->set_method(request_data.method); |
1052 new_request->set_first_party_for_cookies( | 1061 new_request->set_first_party_for_cookies( |
1053 request_data.first_party_for_cookies); | 1062 request_data.first_party_for_cookies); |
1054 | 1063 |
1064 // If the request is a MAIN_FRAME request, the first-party URL gets updated on | |
1065 // redirects. | |
1066 if (request_data.resource_type == ResourceType::MAIN_FRAME) { | |
1067 new_request->set_first_party_url_policy( | |
1068 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | |
1069 } | |
1070 | |
1055 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1071 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
1056 SetReferrerForRequest(new_request.get(), referrer); | 1072 SetReferrerForRequest(new_request.get(), referrer); |
1057 | 1073 |
1058 net::HttpRequestHeaders headers; | 1074 net::HttpRequestHeaders headers; |
1059 headers.AddHeadersFromString(request_data.headers); | 1075 headers.AddHeadersFromString(request_data.headers); |
1060 new_request->SetExtraRequestHeaders(headers); | 1076 new_request->SetExtraRequestHeaders(headers); |
1061 | 1077 |
1062 new_request->SetLoadFlags(load_flags); | 1078 new_request->SetLoadFlags(load_flags); |
1063 | 1079 |
1064 // Resolve elements from request_body and prepare upload data. | 1080 // Resolve elements from request_body and prepare upload data. |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1996 | 2012 |
1997 // Add a flag to selectively bypass the data reduction proxy if the resource | 2013 // Add a flag to selectively bypass the data reduction proxy if the resource |
1998 // type is not an image. | 2014 // type is not an image. |
1999 if (request_data.resource_type != ResourceType::IMAGE) | 2015 if (request_data.resource_type != ResourceType::IMAGE) |
2000 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2016 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2001 | 2017 |
2002 return load_flags; | 2018 return load_flags; |
2003 } | 2019 } |
2004 | 2020 |
2005 } // namespace content | 2021 } // namespace content |
OLD | NEW |