OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/frame_host/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "content/browser/appcache/appcache_navigation_handle.h" |
| 10 #include "content/browser/appcache/chrome_appcache_service.h" |
9 #include "content/browser/child_process_security_policy_impl.h" | 11 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 12 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
11 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
12 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
13 #include "content/browser/frame_host/navigation_controller_impl.h" | 15 #include "content/browser/frame_host/navigation_controller_impl.h" |
14 #include "content/browser/frame_host/navigation_handle_impl.h" | 16 #include "content/browser/frame_host/navigation_handle_impl.h" |
15 #include "content/browser/frame_host/navigation_request_info.h" | 17 #include "content/browser/frame_host/navigation_request_info.h" |
16 #include "content/browser/frame_host/navigator.h" | 18 #include "content/browser/frame_host/navigator.h" |
17 #include "content/browser/frame_host/navigator_impl.h" | 19 #include "content/browser/frame_host/navigator_impl.h" |
18 #include "content/browser/loader/navigation_url_loader.h" | 20 #include "content/browser/loader/navigation_url_loader.h" |
19 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
20 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 22 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
21 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 23 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
22 #include "content/browser/site_instance_impl.h" | 24 #include "content/browser/site_instance_impl.h" |
| 25 #include "content/common/appcache_interfaces.h" |
23 #include "content/common/resource_request_body_impl.h" | 26 #include "content/common/resource_request_body_impl.h" |
24 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
25 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
26 #include "content/public/browser/global_request_id.h" | 29 #include "content/public/browser/global_request_id.h" |
27 #include "content/public/browser/navigation_controller.h" | 30 #include "content/public/browser/navigation_controller.h" |
28 #include "content/public/browser/navigation_data.h" | 31 #include "content/public/browser/navigation_data.h" |
29 #include "content/public/browser/navigation_ui_data.h" | 32 #include "content/public/browser/navigation_ui_data.h" |
30 #include "content/public/browser/storage_partition.h" | 33 #include "content/public/browser/storage_partition.h" |
31 #include "content/public/browser/stream_handle.h" | 34 #include "content/public/browser/stream_handle.h" |
| 35 #include "content/public/common/appcache_info.h" |
32 #include "content/public/common/content_client.h" | 36 #include "content/public/common/content_client.h" |
33 #include "content/public/common/request_context_type.h" | 37 #include "content/public/common/request_context_type.h" |
34 #include "content/public/common/resource_response.h" | 38 #include "content/public/common/resource_response.h" |
35 #include "content/public/common/url_constants.h" | 39 #include "content/public/common/url_constants.h" |
36 #include "net/base/load_flags.h" | 40 #include "net/base/load_flags.h" |
37 #include "net/base/url_util.h" | 41 #include "net/base/url_util.h" |
38 #include "net/http/http_request_headers.h" | 42 #include "net/http/http_request_headers.h" |
39 #include "net/url_request/redirect_info.h" | 43 #include "net/url_request/redirect_info.h" |
40 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 44 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
41 | 45 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 navigation_handle_->service_worker_handle() && | 402 navigation_handle_->service_worker_handle() && |
399 navigation_handle_->service_worker_handle() | 403 navigation_handle_->service_worker_handle() |
400 ->service_worker_provider_host_id() != | 404 ->service_worker_provider_host_id() != |
401 kInvalidServiceWorkerProviderId; | 405 kInvalidServiceWorkerProviderId; |
402 request_params_.service_worker_provider_id = | 406 request_params_.service_worker_provider_id = |
403 did_create_service_worker_host | 407 did_create_service_worker_host |
404 ? navigation_handle_->service_worker_handle() | 408 ? navigation_handle_->service_worker_handle() |
405 ->service_worker_provider_host_id() | 409 ->service_worker_provider_host_id() |
406 : kInvalidServiceWorkerProviderId; | 410 : kInvalidServiceWorkerProviderId; |
407 | 411 |
| 412 request_params_.appcache_host_id = |
| 413 navigation_handle_->appcache_handle() |
| 414 ? navigation_handle_->appcache_handle()->appcache_host_id() |
| 415 : kAppCacheNoHostId; |
| 416 |
408 // Update the lofi state of the request. | 417 // Update the lofi state of the request. |
409 if (response->head.is_using_lofi) | 418 if (response->head.is_using_lofi) |
410 common_params_.lofi_state = LOFI_ON; | 419 common_params_.lofi_state = LOFI_ON; |
411 else | 420 else |
412 common_params_.lofi_state = LOFI_OFF; | 421 common_params_.lofi_state = LOFI_OFF; |
413 | 422 |
414 // Select an appropriate renderer to commit the navigation. | 423 // Select an appropriate renderer to commit the navigation. |
415 RenderFrameHostImpl* render_frame_host = | 424 RenderFrameHostImpl* render_frame_host = |
416 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); | 425 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
417 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, | 426 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 (frame_tree_node_->pending_sandbox_flags() & | 512 (frame_tree_node_->pending_sandbox_flags() & |
504 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; | 513 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; |
505 request_params_.should_create_service_worker = can_create_service_worker; | 514 request_params_.should_create_service_worker = can_create_service_worker; |
506 if (can_create_service_worker) { | 515 if (can_create_service_worker) { |
507 ServiceWorkerContextWrapper* service_worker_context = | 516 ServiceWorkerContextWrapper* service_worker_context = |
508 static_cast<ServiceWorkerContextWrapper*>( | 517 static_cast<ServiceWorkerContextWrapper*>( |
509 partition->GetServiceWorkerContext()); | 518 partition->GetServiceWorkerContext()); |
510 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 519 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
511 } | 520 } |
512 | 521 |
| 522 if (IsSchemeSupportedForAppCache(common_params_.url)) { |
| 523 navigation_handle_->InitAppCacheHandle( |
| 524 static_cast<ChromeAppCacheService*>(partition->GetAppCacheService())); |
| 525 } |
| 526 |
513 // Mark the fetch_start (Navigation Timing API). | 527 // Mark the fetch_start (Navigation Timing API). |
514 request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); | 528 request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); |
515 | 529 |
516 // TODO(mkwst): This is incorrect. It ought to use the definition from | 530 // TODO(mkwst): This is incorrect. It ought to use the definition from |
517 // 'Document::firstPartyForCookies()' in Blink, which walks the ancestor tree | 531 // 'Document::firstPartyForCookies()' in Blink, which walks the ancestor tree |
518 // and verifies that all origins are PSL-matches (and special-cases extension | 532 // and verifies that all origins are PSL-matches (and special-cases extension |
519 // URLs). | 533 // URLs). |
520 const GURL& first_party_for_cookies = | 534 const GURL& first_party_for_cookies = |
521 frame_tree_node_->IsMainFrame() | 535 frame_tree_node_->IsMainFrame() |
522 ? common_params_.url | 536 ? common_params_.url |
(...skipping 15 matching lines...) Expand all Loading... |
538 | 552 |
539 loader_ = NavigationURLLoader::Create( | 553 loader_ = NavigationURLLoader::Create( |
540 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 554 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
541 base::MakeUnique<NavigationRequestInfo>( | 555 base::MakeUnique<NavigationRequestInfo>( |
542 common_params_, begin_params_, first_party_for_cookies, | 556 common_params_, begin_params_, first_party_for_cookies, |
543 frame_tree_node_->current_origin(), frame_tree_node_->IsMainFrame(), | 557 frame_tree_node_->current_origin(), frame_tree_node_->IsMainFrame(), |
544 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), | 558 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), |
545 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, | 559 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, |
546 report_raw_headers), | 560 report_raw_headers), |
547 std::move(navigation_ui_data), | 561 std::move(navigation_ui_data), |
548 navigation_handle_->service_worker_handle(), this); | 562 navigation_handle_->service_worker_handle(), |
| 563 navigation_handle_->appcache_handle(), this); |
549 } | 564 } |
550 | 565 |
551 void NavigationRequest::OnRedirectChecksComplete( | 566 void NavigationRequest::OnRedirectChecksComplete( |
552 NavigationThrottle::ThrottleCheckResult result) { | 567 NavigationThrottle::ThrottleCheckResult result) { |
553 CHECK(result != NavigationThrottle::DEFER); | 568 CHECK(result != NavigationThrottle::DEFER); |
554 | 569 |
555 // Abort the request if needed. This will destroy the NavigationRequest. | 570 // Abort the request if needed. This will destroy the NavigationRequest. |
556 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 571 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
557 result == NavigationThrottle::CANCEL) { | 572 result == NavigationThrottle::CANCEL) { |
558 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 573 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 TransferNavigationHandleOwnership(render_frame_host); | 614 TransferNavigationHandleOwnership(render_frame_host); |
600 | 615 |
601 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 616 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
602 common_params_, request_params_, | 617 common_params_, request_params_, |
603 is_view_source_); | 618 is_view_source_); |
604 | 619 |
605 frame_tree_node_->ResetNavigationRequest(true); | 620 frame_tree_node_->ResetNavigationRequest(true); |
606 } | 621 } |
607 | 622 |
608 } // namespace content | 623 } // namespace content |
OLD | NEW |