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 <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 #include "net/ssl/ssl_cert_request_info.h" | 112 #include "net/ssl/ssl_cert_request_info.h" |
113 #include "net/url_request/url_request.h" | 113 #include "net/url_request/url_request.h" |
114 #include "net/url_request/url_request_context.h" | 114 #include "net/url_request/url_request_context.h" |
115 #include "net/url_request/url_request_job_factory.h" | 115 #include "net/url_request/url_request_job_factory.h" |
116 #include "storage/browser/blob/blob_data_handle.h" | 116 #include "storage/browser/blob/blob_data_handle.h" |
117 #include "storage/browser/blob/blob_storage_context.h" | 117 #include "storage/browser/blob/blob_storage_context.h" |
118 #include "storage/browser/blob/blob_url_request_job_factory.h" | 118 #include "storage/browser/blob/blob_url_request_job_factory.h" |
119 #include "storage/browser/blob/shareable_file_reference.h" | 119 #include "storage/browser/blob/shareable_file_reference.h" |
120 #include "storage/browser/fileapi/file_permission_policy.h" | 120 #include "storage/browser/fileapi/file_permission_policy.h" |
121 #include "storage/browser/fileapi/file_system_context.h" | 121 #include "storage/browser/fileapi/file_system_context.h" |
122 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h" | |
123 #include "ui/base/page_transition_types.h" | |
122 #include "url/url_constants.h" | 124 #include "url/url_constants.h" |
123 | 125 |
124 using base::Time; | 126 using base::Time; |
125 using base::TimeDelta; | 127 using base::TimeDelta; |
126 using base::TimeTicks; | 128 using base::TimeTicks; |
127 using storage::ShareableFileReference; | 129 using storage::ShareableFileReference; |
128 | 130 |
129 // ---------------------------------------------------------------------------- | 131 // ---------------------------------------------------------------------------- |
130 | 132 |
131 namespace content { | 133 namespace content { |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1462 // that was already fetched by the browser will not be transmitted to the | 1464 // that was already fetched by the browser will not be transmitted to the |
1463 // renderer. | 1465 // renderer. |
1464 if (is_navigation_stream_request) | 1466 if (is_navigation_stream_request) |
1465 new_request->set_method("GET"); | 1467 new_request->set_method("GET"); |
1466 else | 1468 else |
1467 new_request->set_method(request_data.method); | 1469 new_request->set_method(request_data.method); |
1468 | 1470 |
1469 new_request->set_first_party_for_cookies( | 1471 new_request->set_first_party_for_cookies( |
1470 request_data.first_party_for_cookies); | 1472 request_data.first_party_for_cookies); |
1471 new_request->set_initiator(request_data.request_initiator); | 1473 new_request->set_initiator(request_data.request_initiator); |
1474 if (request_data.insecure_request_policy & blink::kUpgradeInsecureRequests) { | |
1475 new_request->set_insecure_request_policy( | |
1476 net::URLRequest::UPGRADE_ALL_INSECURE_REQUESTS); | |
mmenke
2016/06/09 18:56:55
Does this have to be a member of the URLRequest?.
Mike West
2016/06/10 09:55:16
This seems like the best approach if you want to k
| |
1477 } | |
1472 | 1478 |
1473 if (request_data.originated_from_service_worker) { | 1479 if (request_data.originated_from_service_worker) { |
1474 new_request->SetUserData(URLRequestServiceWorkerData::kUserDataKey, | 1480 new_request->SetUserData(URLRequestServiceWorkerData::kUserDataKey, |
1475 new URLRequestServiceWorkerData()); | 1481 new URLRequestServiceWorkerData()); |
1476 } | 1482 } |
1477 | 1483 |
1478 // If the request is a MAIN_FRAME request, the first-party URL gets updated on | 1484 // If the request is a MAIN_FRAME request, the first-party URL gets updated on |
1479 // redirects. | 1485 // redirects. |
1480 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { | 1486 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { |
mmenke
2016/06/14 18:49:31
BUG: Need to duplicate main frame request logic f
| |
1481 new_request->set_first_party_url_policy( | 1487 new_request->set_first_party_url_policy( |
1482 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 1488 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
1483 } | 1489 } |
1484 | 1490 |
1485 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1491 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
1486 SetReferrerForRequest(new_request.get(), referrer); | 1492 SetReferrerForRequest(new_request.get(), referrer); |
1487 | 1493 |
1488 new_request->SetExtraRequestHeaders(headers); | 1494 new_request->SetExtraRequestHeaders(headers); |
1489 | 1495 |
1490 storage::BlobStorageContext* blob_context = | 1496 storage::BlobStorageContext* blob_context = |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2214 url_buf, info.common_params.url.spec().c_str(), arraysize(url_buf)); | 2220 url_buf, info.common_params.url.spec().c_str(), arraysize(url_buf)); |
2215 base::debug::Alias(url_buf); | 2221 base::debug::Alias(url_buf); |
2216 CHECK(ContainsKey(active_resource_contexts_, resource_context)); | 2222 CHECK(ContainsKey(active_resource_contexts_, resource_context)); |
2217 | 2223 |
2218 const net::URLRequestContext* request_context = | 2224 const net::URLRequestContext* request_context = |
2219 resource_context->GetRequestContext(); | 2225 resource_context->GetRequestContext(); |
2220 | 2226 |
2221 int load_flags = info.begin_params.load_flags; | 2227 int load_flags = info.begin_params.load_flags; |
2222 load_flags |= net::LOAD_VERIFY_EV_CERT; | 2228 load_flags |= net::LOAD_VERIFY_EV_CERT; |
2223 if (info.is_main_frame) | 2229 if (info.is_main_frame) |
2224 load_flags |= net::LOAD_MAIN_FRAME; | 2230 load_flags |= net::LOAD_MAIN_FRAME; |
mmenke
2016/06/14 18:49:31
Looks like we can we go through this for subframes
| |
2225 | 2231 |
2226 // TODO(davidben): BuildLoadFlagsForRequest includes logic for | 2232 // TODO(davidben): BuildLoadFlagsForRequest includes logic for |
2227 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? | 2233 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? |
2228 | 2234 |
2229 // Sync loads should have maximum priority and should be the only | 2235 // Sync loads should have maximum priority and should be the only |
2230 // requests that have the ignore limits flag set. | 2236 // requests that have the ignore limits flag set. |
2231 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); | 2237 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); |
2232 | 2238 |
2233 std::unique_ptr<net::URLRequest> new_request; | 2239 std::unique_ptr<net::URLRequest> new_request; |
2234 new_request = request_context->CreateRequest( | 2240 new_request = request_context->CreateRequest( |
2235 info.common_params.url, net::HIGHEST, nullptr); | 2241 info.common_params.url, net::HIGHEST, nullptr); |
2236 | 2242 |
2237 new_request->set_method(info.common_params.method); | 2243 new_request->set_method(info.common_params.method); |
2238 new_request->set_first_party_for_cookies( | 2244 new_request->set_first_party_for_cookies( |
2239 info.first_party_for_cookies); | 2245 info.first_party_for_cookies); |
2240 new_request->set_initiator(info.request_initiator); | 2246 new_request->set_initiator(info.request_initiator); |
2247 if (info.should_upgrade_to_secure_transport) { | |
2248 net::URLRequest::InsecureRequestPolicy policy = | |
2249 net::URLRequest::UPGRADE_ALL_INSECURE_REQUESTS; | |
2250 if (info.is_main_frame && | |
2251 info.common_params.transition != | |
2252 ui::PageTransition::PAGE_TRANSITION_FORM_SUBMIT) { | |
2253 policy = net::URLRequest::UPGRADE_SAME_HOST_INSECURE_REQUESTS; | |
2254 } | |
2255 new_request->set_insecure_request_policy(policy); | |
2256 } | |
mmenke
2016/06/14 18:49:31
I'm not following how the "UPGRADE_SAME_HOST_INSEC
| |
2241 if (info.is_main_frame) { | 2257 if (info.is_main_frame) { |
2242 new_request->set_first_party_url_policy( | 2258 new_request->set_first_party_url_policy( |
2243 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 2259 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
2244 } | 2260 } |
2245 | 2261 |
2246 SetReferrerForRequest(new_request.get(), info.common_params.referrer); | 2262 SetReferrerForRequest(new_request.get(), info.common_params.referrer); |
2247 | 2263 |
2248 net::HttpRequestHeaders headers; | 2264 net::HttpRequestHeaders headers; |
2249 headers.AddHeadersFromString(info.begin_params.headers); | 2265 headers.AddHeadersFromString(info.begin_params.headers); |
2250 new_request->SetExtraRequestHeaders(headers); | 2266 new_request->SetExtraRequestHeaders(headers); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2693 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2709 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); |
2694 response->head.security_info = SerializeSecurityInfo(ssl); | 2710 response->head.security_info = SerializeSecurityInfo(ssl); |
2695 } | 2711 } |
2696 | 2712 |
2697 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2713 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2698 return cert_store_for_testing_ ? cert_store_for_testing_ | 2714 return cert_store_for_testing_ ? cert_store_for_testing_ |
2699 : CertStore::GetInstance(); | 2715 : CertStore::GetInstance(); |
2700 } | 2716 } |
2701 | 2717 |
2702 } // namespace content | 2718 } // namespace content |
OLD | NEW |