Chromium Code Reviews| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 } | 588 } |
| 589 | 589 |
| 590 DownloadInterruptReason ResourceDispatcherHostImpl::BeginDownload( | 590 DownloadInterruptReason ResourceDispatcherHostImpl::BeginDownload( |
| 591 scoped_ptr<net::URLRequest> request, | 591 scoped_ptr<net::URLRequest> request, |
| 592 const Referrer& referrer, | 592 const Referrer& referrer, |
| 593 bool is_content_initiated, | 593 bool is_content_initiated, |
| 594 ResourceContext* context, | 594 ResourceContext* context, |
| 595 int child_id, | 595 int child_id, |
| 596 int route_id, | 596 int route_id, |
| 597 bool prefer_cache, | 597 bool prefer_cache, |
| 598 bool do_not_prompt_for_login, | |
| 598 scoped_ptr<DownloadSaveInfo> save_info, | 599 scoped_ptr<DownloadSaveInfo> save_info, |
| 599 uint32 download_id, | 600 uint32 download_id, |
| 600 const DownloadStartedCallback& started_callback) { | 601 const DownloadStartedCallback& started_callback) { |
| 601 if (is_shutdown_) | 602 if (is_shutdown_) |
| 602 return CallbackAndReturn(started_callback, | 603 return CallbackAndReturn(started_callback, |
| 603 DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN); | 604 DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN); |
| 604 | 605 |
| 605 const GURL& url = request->original_url(); | 606 const GURL& url = request->original_url(); |
| 606 | 607 |
| 607 // http://crbug.com/90971 | 608 // http://crbug.com/90971 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 const net::URLRequestContext* request_context = context->GetRequestContext(); | 651 const net::URLRequestContext* request_context = context->GetRequestContext(); |
| 651 if (!request_context->job_factory()->IsHandledURL(url)) { | 652 if (!request_context->job_factory()->IsHandledURL(url)) { |
| 652 VLOG(1) << "Download request for unsupported protocol: " | 653 VLOG(1) << "Download request for unsupported protocol: " |
| 653 << url.possibly_invalid_spec(); | 654 << url.possibly_invalid_spec(); |
| 654 return CallbackAndReturn(started_callback, | 655 return CallbackAndReturn(started_callback, |
| 655 DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST); | 656 DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST); |
| 656 } | 657 } |
| 657 | 658 |
| 658 ResourceRequestInfoImpl* extra_info = | 659 ResourceRequestInfoImpl* extra_info = |
| 659 CreateRequestInfo(child_id, route_id, true, context); | 660 CreateRequestInfo(child_id, route_id, true, context); |
| 661 extra_info->set_do_not_prompt_for_login(do_not_prompt_for_login); | |
| 660 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | 662 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
| 661 | 663 |
| 662 if (request->url().SchemeIs(url::kBlobScheme)) { | 664 if (request->url().SchemeIs(url::kBlobScheme)) { |
| 663 ChromeBlobStorageContext* blob_context = | 665 ChromeBlobStorageContext* blob_context = |
| 664 GetChromeBlobStorageContextForResourceContext(context); | 666 GetChromeBlobStorageContextForResourceContext(context); |
| 665 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 667 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 666 request.get(), | 668 request.get(), |
| 667 blob_context->context()->GetBlobDataFromPublicURL(request->url())); | 669 blob_context->context()->GetBlobDataFromPublicURL(request->url())); |
| 668 } | 670 } |
| 669 | 671 |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 1187 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
| 1186 } | 1188 } |
| 1187 | 1189 |
| 1188 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1190 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
| 1189 SetReferrerForRequest(new_request.get(), referrer); | 1191 SetReferrerForRequest(new_request.get(), referrer); |
| 1190 | 1192 |
| 1191 net::HttpRequestHeaders headers; | 1193 net::HttpRequestHeaders headers; |
| 1192 headers.AddHeadersFromString(request_data.headers); | 1194 headers.AddHeadersFromString(request_data.headers); |
| 1193 new_request->SetExtraRequestHeaders(headers); | 1195 new_request->SetExtraRequestHeaders(headers); |
| 1194 | 1196 |
| 1195 new_request->SetLoadFlags(load_flags); | |
| 1196 | |
| 1197 storage::BlobStorageContext* blob_context = | 1197 storage::BlobStorageContext* blob_context = |
| 1198 GetBlobStorageContext(filter_->blob_storage_context()); | 1198 GetBlobStorageContext(filter_->blob_storage_context()); |
| 1199 // Resolve elements from request_body and prepare upload data. | 1199 // Resolve elements from request_body and prepare upload data. |
| 1200 if (request_data.request_body.get()) { | 1200 if (request_data.request_body.get()) { |
| 1201 // |blob_context| could be null when the request is from the plugins because | 1201 // |blob_context| could be null when the request is from the plugins because |
| 1202 // ResourceMessageFilters created in PluginProcessHost don't have the blob | 1202 // ResourceMessageFilters created in PluginProcessHost don't have the blob |
| 1203 // context. | 1203 // context. |
| 1204 if (blob_context) { | 1204 if (blob_context) { |
| 1205 // Attaches the BlobDataHandles to request_body not to free the blobs and | 1205 // Attaches the BlobDataHandles to request_body not to free the blobs and |
| 1206 // any attached shareable files until upload completion. These data will | 1206 // any attached shareable files until upload completion. These data will |
| 1207 // be used in UploadDataStream and ServiceWorkerURLRequestJob. | 1207 // be used in UploadDataStream and ServiceWorkerURLRequestJob. |
| 1208 AttachRequestBodyBlobDataHandles( | 1208 AttachRequestBodyBlobDataHandles( |
| 1209 request_data.request_body.get(), | 1209 request_data.request_body.get(), |
| 1210 blob_context); | 1210 blob_context); |
| 1211 } | 1211 } |
| 1212 new_request->set_upload(UploadDataStreamBuilder::Build( | 1212 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 1213 request_data.request_body.get(), | 1213 request_data.request_body.get(), |
| 1214 blob_context, | 1214 blob_context, |
| 1215 filter_->file_system_context(), | 1215 filter_->file_system_context(), |
| 1216 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 1216 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
| 1217 .get())); | 1217 .get())); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 bool allow_download = request_data.allow_download && | 1220 bool allow_download = request_data.allow_download && |
| 1221 IsResourceTypeFrame(request_data.resource_type); | 1221 IsResourceTypeFrame(request_data.resource_type); |
|
mmenke
2014/12/10 19:28:30
Suggest moving the load_flags and is_sync_load stu
baranovich
2014/12/10 22:24:38
Done.
| |
| 1222 bool do_not_prompt_for_login = | |
| 1223 request_data.resource_type == RESOURCE_TYPE_PREFETCH || | |
| 1224 request_data.resource_type == RESOURCE_TYPE_FAVICON; | |
|
mmenke
2014/12/10 19:28:30
BUG: You need request_data.do_not_prompt_for_logi
baranovich
2014/12/10 22:24:38
I didn't found any tests (at least in RDH browsert
baranovich
2014/12/10 22:24:38
Done.
| |
| 1225 if (request_data.resource_type == RESOURCE_TYPE_IMAGE && | |
| 1226 HTTP_AUTH_RELATION_BLOCKED_CROSS == | |
| 1227 HttpAuthRelationTypeOf(request_data.url, | |
| 1228 request_data.first_party_for_cookies)) { | |
| 1229 // Prevent third-party image content from prompting for login, as this | |
| 1230 // is often a scam to extract credentials for another domain from the user. | |
| 1231 // Only block image loads, as the attack applies largely to the "src" | |
| 1232 // property of the <img> tag. It is common for web properties to allow | |
| 1233 // untrusted values for <img src>; this is considered a fair thing for an | |
| 1234 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't | |
| 1235 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags | |
| 1236 // would be considered vulnerable in and of itself. | |
| 1237 do_not_prompt_for_login = true; | |
| 1238 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; | |
|
baranovich
2014/12/09 23:33:49
not sure if it's the best decision. On the one han
mmenke
2014/12/10 19:28:30
It's certainly a bit ugly, but I don't have a bett
| |
| 1239 } | |
| 1240 | |
| 1241 new_request->SetLoadFlags(load_flags); | |
| 1222 | 1242 |
| 1223 // Make extra info and read footer (contains request ID). | 1243 // Make extra info and read footer (contains request ID). |
| 1224 ResourceRequestInfoImpl* extra_info = | 1244 ResourceRequestInfoImpl* extra_info = |
| 1225 new ResourceRequestInfoImpl( | 1245 new ResourceRequestInfoImpl( |
| 1226 process_type, | 1246 process_type, |
| 1227 child_id, | 1247 child_id, |
| 1228 route_id, | 1248 route_id, |
| 1229 request_data.origin_pid, | 1249 request_data.origin_pid, |
| 1230 request_id, | 1250 request_id, |
| 1231 request_data.render_frame_id, | 1251 request_data.render_frame_id, |
| 1232 request_data.is_main_frame, | 1252 request_data.is_main_frame, |
| 1233 request_data.parent_is_main_frame, | 1253 request_data.parent_is_main_frame, |
| 1234 request_data.parent_render_frame_id, | 1254 request_data.parent_render_frame_id, |
| 1235 request_data.resource_type, | 1255 request_data.resource_type, |
| 1236 request_data.transition_type, | 1256 request_data.transition_type, |
| 1237 request_data.should_replace_current_entry, | 1257 request_data.should_replace_current_entry, |
| 1238 false, // is download | 1258 false, // is download |
| 1239 false, // is stream | 1259 false, // is stream |
| 1240 allow_download, | 1260 allow_download, |
| 1241 request_data.has_user_gesture, | 1261 request_data.has_user_gesture, |
| 1242 request_data.enable_load_timing, | 1262 request_data.enable_load_timing, |
| 1243 request_data.enable_upload_progress, | 1263 request_data.enable_upload_progress, |
| 1264 do_not_prompt_for_login, | |
| 1244 request_data.referrer_policy, | 1265 request_data.referrer_policy, |
| 1245 request_data.visiblity_state, | 1266 request_data.visiblity_state, |
| 1246 resource_context, | 1267 resource_context, |
| 1247 filter_->GetWeakPtr(), | 1268 filter_->GetWeakPtr(), |
| 1248 !is_sync_load); | 1269 !is_sync_load); |
| 1249 // Request takes ownership. | 1270 // Request takes ownership. |
| 1250 extra_info->AssociateWithRequest(new_request.get()); | 1271 extra_info->AssociateWithRequest(new_request.get()); |
| 1251 | 1272 |
| 1252 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 1273 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
| 1253 // Hang on to a reference to ensure the blob is not released prior | 1274 // Hang on to a reference to ensure the blob is not released prior |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1479 int route_id, | 1500 int route_id, |
| 1480 bool download, | 1501 bool download, |
| 1481 ResourceContext* context) { | 1502 ResourceContext* context) { |
| 1482 return new ResourceRequestInfoImpl( | 1503 return new ResourceRequestInfoImpl( |
| 1483 PROCESS_TYPE_RENDERER, | 1504 PROCESS_TYPE_RENDERER, |
| 1484 child_id, | 1505 child_id, |
| 1485 route_id, | 1506 route_id, |
| 1486 0, | 1507 0, |
| 1487 request_id_, | 1508 request_id_, |
| 1488 MSG_ROUTING_NONE, // render_frame_id | 1509 MSG_ROUTING_NONE, // render_frame_id |
| 1489 false, // is_main_frame | 1510 false, // is_main_frame |
| 1490 false, // parent_is_main_frame | 1511 false, // parent_is_main_frame |
| 1491 -1, // parent_render_frame_id | 1512 -1, // parent_render_frame_id |
| 1492 RESOURCE_TYPE_SUB_RESOURCE, | 1513 RESOURCE_TYPE_SUB_RESOURCE, |
| 1493 ui::PAGE_TRANSITION_LINK, | 1514 ui::PAGE_TRANSITION_LINK, |
| 1494 false, // should_replace_current_entry | 1515 false, // should_replace_current_entry |
| 1495 download, // is_download | 1516 download, // is_download |
| 1496 false, // is_stream | 1517 false, // is_stream |
| 1497 download, // allow_download | 1518 download, // allow_download |
| 1498 false, // has_user_gesture | 1519 false, // has_user_gesture |
| 1499 false, // enable_load_timing | 1520 false, // enable_load_timing |
| 1500 false, // enable_upload_progress | 1521 false, // enable_upload_progress |
| 1522 false, // do_not_prompt_for_login | |
| 1501 blink::WebReferrerPolicyDefault, | 1523 blink::WebReferrerPolicyDefault, |
| 1502 blink::WebPageVisibilityStateVisible, | 1524 blink::WebPageVisibilityStateVisible, |
| 1503 context, | 1525 context, |
| 1504 base::WeakPtr<ResourceMessageFilter>(), // filter | 1526 base::WeakPtr<ResourceMessageFilter>(), // filter |
| 1505 true); // is_async | 1527 true); // is_async |
| 1506 } | 1528 } |
| 1507 | 1529 |
| 1508 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, | 1530 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, |
| 1509 int route_id, | 1531 int route_id, |
| 1510 bool is_visible, | 1532 bool is_visible, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1945 params.transition, | 1967 params.transition, |
| 1946 // should_replace_current_entry. This was only maintained at layer for | 1968 // should_replace_current_entry. This was only maintained at layer for |
| 1947 // request transfers and isn't needed for browser-side navigations. | 1969 // request transfers and isn't needed for browser-side navigations. |
| 1948 false, | 1970 false, |
| 1949 false, // is download | 1971 false, // is download |
| 1950 false, // is stream | 1972 false, // is stream |
| 1951 params.allow_download, | 1973 params.allow_download, |
| 1952 info.navigation_params.has_user_gesture, | 1974 info.navigation_params.has_user_gesture, |
| 1953 true, // enable_load_timing | 1975 true, // enable_load_timing |
| 1954 false, // enable_upload_progress | 1976 false, // enable_upload_progress |
| 1977 false, // do_not_prompt_for_login | |
| 1955 params.referrer.policy, | 1978 params.referrer.policy, |
| 1956 // TODO(davidben): This is only used for prerenders. Replace | 1979 // TODO(davidben): This is only used for prerenders. Replace |
| 1957 // is_showing with something for that. Or maybe it just comes from the | 1980 // is_showing with something for that. Or maybe it just comes from the |
| 1958 // same mechanism as the cookie one. | 1981 // same mechanism as the cookie one. |
| 1959 blink::WebPageVisibilityStateVisible, | 1982 blink::WebPageVisibilityStateVisible, |
| 1960 resource_context, | 1983 resource_context, |
| 1961 base::WeakPtr<ResourceMessageFilter>(), // filter | 1984 base::WeakPtr<ResourceMessageFilter>(), // filter |
| 1962 true); | 1985 true); |
| 1963 // Request takes ownership. | 1986 // Request takes ownership. |
| 1964 extra_info->AssociateWithRequest(new_request.get()); | 1987 extra_info->AssociateWithRequest(new_request.get()); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2319 // Although EV status is irrelevant to sub-frames and sub-resources, we have | 2342 // Although EV status is irrelevant to sub-frames and sub-resources, we have |
| 2320 // to perform EV certificate verification on all resources because an HTTP | 2343 // to perform EV certificate verification on all resources because an HTTP |
| 2321 // keep-alive connection created to load a sub-frame or a sub-resource could | 2344 // keep-alive connection created to load a sub-frame or a sub-resource could |
| 2322 // be reused to load a main frame. | 2345 // be reused to load a main frame. |
| 2323 load_flags |= net::LOAD_VERIFY_EV_CERT; | 2346 load_flags |= net::LOAD_VERIFY_EV_CERT; |
| 2324 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { | 2347 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { |
| 2325 load_flags |= net::LOAD_MAIN_FRAME; | 2348 load_flags |= net::LOAD_MAIN_FRAME; |
| 2326 } else if (request_data.resource_type == RESOURCE_TYPE_SUB_FRAME) { | 2349 } else if (request_data.resource_type == RESOURCE_TYPE_SUB_FRAME) { |
| 2327 load_flags |= net::LOAD_SUB_FRAME; | 2350 load_flags |= net::LOAD_SUB_FRAME; |
| 2328 } else if (request_data.resource_type == RESOURCE_TYPE_PREFETCH) { | 2351 } else if (request_data.resource_type == RESOURCE_TYPE_PREFETCH) { |
| 2329 load_flags |= (net::LOAD_PREFETCH | net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); | 2352 load_flags |= net::LOAD_PREFETCH; |
| 2330 } else if (request_data.resource_type == RESOURCE_TYPE_FAVICON) { | |
| 2331 load_flags |= net::LOAD_DO_NOT_PROMPT_FOR_LOGIN; | |
| 2332 } else if (request_data.resource_type == RESOURCE_TYPE_IMAGE) { | |
| 2333 // Prevent third-party image content from prompting for login, as this | |
| 2334 // is often a scam to extract credentials for another domain from the user. | |
| 2335 // Only block image loads, as the attack applies largely to the "src" | |
| 2336 // property of the <img> tag. It is common for web properties to allow | |
| 2337 // untrusted values for <img src>; this is considered a fair thing for an | |
| 2338 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't | |
| 2339 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags | |
| 2340 // would be considered vulnerable in and of itself. | |
| 2341 HttpAuthRelationType relation_type = HttpAuthRelationTypeOf( | |
| 2342 request_data.url, request_data.first_party_for_cookies); | |
| 2343 if (relation_type == HTTP_AUTH_RELATION_BLOCKED_CROSS) { | |
| 2344 load_flags |= (net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY | | |
| 2345 net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); | |
| 2346 } | |
| 2347 } | 2353 } |
| 2348 | 2354 |
| 2349 if (is_sync_load) | 2355 if (is_sync_load) |
| 2350 load_flags |= net::LOAD_IGNORE_LIMITS; | 2356 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 2351 | 2357 |
| 2352 ChildProcessSecurityPolicyImpl* policy = | 2358 ChildProcessSecurityPolicyImpl* policy = |
| 2353 ChildProcessSecurityPolicyImpl::GetInstance(); | 2359 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 2354 if (!policy->CanSendCookiesForOrigin(child_id, request_data.url)) { | 2360 if (!policy->CanSendCookiesForOrigin(child_id, request_data.url)) { |
| 2355 load_flags |= (net::LOAD_DO_NOT_SEND_COOKIES | | 2361 load_flags |= (net::LOAD_DO_NOT_SEND_COOKIES | |
| 2356 net::LOAD_DO_NOT_SEND_AUTH_DATA | | 2362 net::LOAD_DO_NOT_SEND_AUTH_DATA | |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2367 | 2373 |
| 2368 // Add a flag to selectively bypass the data reduction proxy if the resource | 2374 // Add a flag to selectively bypass the data reduction proxy if the resource |
| 2369 // type is not an image. | 2375 // type is not an image. |
| 2370 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2376 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
| 2371 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2377 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
| 2372 | 2378 |
| 2373 return load_flags; | 2379 return load_flags; |
| 2374 } | 2380 } |
| 2375 | 2381 |
| 2376 } // namespace content | 2382 } // namespace content |
| OLD | NEW |