Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 483773002: PlzNavigate: implement CommitNavigation on the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a class to keep track of navigation parameters Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "content/browser/child_process_security_policy_impl.h" 13 #include "content/browser/child_process_security_policy_impl.h"
14 #include "content/browser/devtools/render_view_devtools_agent_host.h" 14 #include "content/browser/devtools/render_view_devtools_agent_host.h"
15 #include "content/browser/frame_host/cross_site_transferring_request.h" 15 #include "content/browser/frame_host/cross_site_transferring_request.h"
16 #include "content/browser/frame_host/debug_urls.h" 16 #include "content/browser/frame_host/debug_urls.h"
17 #include "content/browser/frame_host/interstitial_page_impl.h" 17 #include "content/browser/frame_host/interstitial_page_impl.h"
18 #include "content/browser/frame_host/navigation_before_commit_info.h" 18 #include "content/browser/frame_host/navigation_before_commit_info.h"
19 #include "content/browser/frame_host/navigation_controller_impl.h" 19 #include "content/browser/frame_host/navigation_controller_impl.h"
20 #include "content/browser/frame_host/navigation_entry_impl.h" 20 #include "content/browser/frame_host/navigation_entry_impl.h"
21 #include "content/browser/frame_host/navigation_parameters.h"
21 #include "content/browser/frame_host/navigation_request.h" 22 #include "content/browser/frame_host/navigation_request.h"
22 #include "content/browser/frame_host/navigation_request_info.h" 23 #include "content/browser/frame_host/navigation_request_info.h"
23 #include "content/browser/frame_host/navigator.h" 24 #include "content/browser/frame_host/navigator.h"
24 #include "content/browser/frame_host/render_frame_host_factory.h" 25 #include "content/browser/frame_host/render_frame_host_factory.h"
25 #include "content/browser/frame_host/render_frame_host_impl.h" 26 #include "content/browser/frame_host/render_frame_host_impl.h"
26 #include "content/browser/frame_host/render_frame_proxy_host.h" 27 #include "content/browser/frame_host/render_frame_proxy_host.h"
27 #include "content/browser/renderer_host/render_process_host_impl.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
28 #include "content/browser/renderer_host/render_view_host_factory.h" 29 #include "content/browser/renderer_host/render_view_host_factory.h"
29 #include "content/browser/renderer_host/render_view_host_impl.h" 30 #include "content/browser/renderer_host/render_view_host_impl.h"
30 #include "content/browser/site_instance_impl.h" 31 #include "content/browser/site_instance_impl.h"
31 #include "content/browser/webui/web_ui_controller_factory_registry.h" 32 #include "content/browser/webui/web_ui_controller_factory_registry.h"
32 #include "content/browser/webui/web_ui_impl.h" 33 #include "content/browser/webui/web_ui_impl.h"
33 #include "content/common/view_messages.h" 34 #include "content/common/view_messages.h"
34 #include "content/public/browser/content_browser_client.h" 35 #include "content/public/browser/content_browser_client.h"
35 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/notification_types.h" 37 #include "content/public/browser/notification_types.h"
37 #include "content/public/browser/render_widget_host_iterator.h" 38 #include "content/public/browser/render_widget_host_iterator.h"
38 #include "content/public/browser/render_widget_host_view.h" 39 #include "content/public/browser/render_widget_host_view.h"
39 #include "content/public/browser/user_metrics.h" 40 #include "content/public/browser/user_metrics.h"
40 #include "content/public/browser/web_ui_controller.h" 41 #include "content/public/browser/web_ui_controller.h"
41 #include "content/public/common/content_switches.h" 42 #include "content/public/common/content_switches.h"
42 #include "content/public/common/referrer.h" 43 #include "content/public/common/referrer.h"
43 #include "content/public/common/url_constants.h" 44 #include "content/public/common/url_constants.h"
44 #include "net/base/load_flags.h" 45 #include "net/base/load_flags.h"
45 46
46 namespace content { 47 namespace content {
47 48
48 namespace {
49
50 // PlzNavigate
51 // Simulates a renderer response to a navigation request when there is no live
52 // renderer.
53 FrameHostMsg_BeginNavigation_Params BeginNavigationFromNavigate(
54 const FrameMsg_Navigate_Params& navigate_params) {
55 FrameHostMsg_BeginNavigation_Params begin_navigation_params;
56 begin_navigation_params.method = navigate_params.is_post ? "POST" : "GET";
57 begin_navigation_params.url = navigate_params.url;
58 begin_navigation_params.referrer =
59 Referrer(navigate_params.referrer.url, navigate_params.referrer.policy);
60
61 // TODO(clamy): This should be modified to take into account caching policy
62 // requirements (eg for POST reloads).
63 begin_navigation_params.load_flags = net::LOAD_NORMAL;
64
65 // TODO(clamy): Post data from the browser should be put in the request body.
66
67 begin_navigation_params.has_user_gesture = false;
68 begin_navigation_params.transition_type = navigate_params.transition;
69 begin_navigation_params.should_replace_current_entry =
70 navigate_params.should_replace_current_entry;
71 begin_navigation_params.allow_download =
72 navigate_params.allow_download;
73 return begin_navigation_params;
74 }
75
76 } // namespace
77
78 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { 49 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) {
79 node->render_manager()->pending_delete_hosts_.clear(); 50 node->render_manager()->pending_delete_hosts_.clear();
80 return true; 51 return true;
81 } 52 }
82 53
83 RenderFrameHostManager::RenderFrameHostManager( 54 RenderFrameHostManager::RenderFrameHostManager(
84 FrameTreeNode* frame_tree_node, 55 FrameTreeNode* frame_tree_node,
85 RenderFrameHostDelegate* render_frame_delegate, 56 RenderFrameHostDelegate* render_frame_delegate,
86 RenderViewHostDelegate* render_view_delegate, 57 RenderViewHostDelegate* render_view_delegate,
87 RenderWidgetHostDelegate* render_widget_delegate, 58 RenderWidgetHostDelegate* render_widget_delegate,
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh) 512 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh)
542 pending_delete_hosts_.erase(site_instance_id); 513 pending_delete_hosts_.erase(site_instance_id);
543 } 514 }
544 515
545 void RenderFrameHostManager::ResetProxyHosts() { 516 void RenderFrameHostManager::ResetProxyHosts() {
546 STLDeleteValues(&proxy_hosts_); 517 STLDeleteValues(&proxy_hosts_);
547 } 518 }
548 519
549 // PlzNavigate 520 // PlzNavigate
550 bool RenderFrameHostManager::RequestNavigation( 521 bool RenderFrameHostManager::RequestNavigation(
551 const NavigationEntryImpl& entry, 522 scoped_ptr<NavigationParameters> navigation_parameters) {
552 const FrameMsg_Navigate_Params& navigate_params) {
553 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 523 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
554 switches::kEnableBrowserSideNavigation)); 524 switches::kEnableBrowserSideNavigation));
525 navigation_parameters_ = navigation_parameters.Pass();
555 // TODO(clamy): replace RenderViewHost::IsRenderViewLive by 526 // TODO(clamy): replace RenderViewHost::IsRenderViewLive by
556 // RenderFrameHost::IsLive. 527 // RenderFrameHost::IsLive.
557 if (render_frame_host_->render_view_host()->IsRenderViewLive()) 528 if (render_frame_host_->render_view_host()->IsRenderViewLive())
558 // TODO(clamy): send a RequestNavigation IPC. 529 // TODO(clamy): send a RequestNavigation IPC.
559 return true; 530 return true;
560 531
561 // The navigation request is sent directly to the IO thread. 532 // The navigation request is sent directly to the IO thread.
562 OnBeginNavigation(BeginNavigationFromNavigate(navigate_params)); 533 OnBeginNavigation(navigation_parameters_->SimulateRendererResponse());
563 return true; 534 return true;
564 } 535 }
565 536
566 // PlzNavigate 537 // PlzNavigate
567 void RenderFrameHostManager::OnBeginNavigation( 538 void RenderFrameHostManager::OnBeginNavigation(
568 const FrameHostMsg_BeginNavigation_Params& params) { 539 const FrameHostMsg_BeginNavigation_Params& params) {
569 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 540 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
570 switches::kEnableBrowserSideNavigation)); 541 switches::kEnableBrowserSideNavigation));
542 DCHECK(navigation_parameters_.get());
543 navigation_parameters_->UpdateFromBeginNavigationParams(params);
571 // TODO(clamy): Check if navigations are blocked and if so, return 544 // TODO(clamy): Check if navigations are blocked and if so, return
572 // immediately. 545 // immediately.
573 NavigationRequestInfo info(params); 546 NavigationRequestInfo info(params);
574 547
575 info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ? 548 info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ?
576 params.url : frame_tree_node_->frame_tree()->root()->current_url(); 549 params.url : frame_tree_node_->frame_tree()->root()->current_url();
577 info.is_main_frame = frame_tree_node_->IsMainFrame(); 550 info.is_main_frame = frame_tree_node_->IsMainFrame();
578 info.parent_is_main_frame = !frame_tree_node_->parent() ? 551 info.parent_is_main_frame = !frame_tree_node_->parent() ?
579 false : frame_tree_node_->parent()->IsMainFrame(); 552 false : frame_tree_node_->parent()->IsMainFrame();
580 info.is_showing = GetRenderWidgetHostView()->IsShowing(); 553 info.is_showing = GetRenderWidgetHostView()->IsShowing();
554 info.allow_download = navigation_parameters_->allow_download();
581 555
582 // TODO(clamy): Check if the current RFH should be initialized (in case it has 556 // TODO(clamy): Check if the current RFH should be initialized (in case it has
583 // crashed) not to display a sad tab while navigating. 557 // crashed) not to display a sad tab while navigating.
584 // TODO(clamy): Spawn a speculative renderer process if we do not have one to 558 // TODO(clamy): Spawn a speculative renderer process if we do not have one to
585 // use for the navigation. 559 // use for the navigation.
586 navigation_request_.reset(new NavigationRequest( 560 navigation_request_.reset(new NavigationRequest(
587 info, frame_tree_node_->frame_tree_node_id())); 561 info, frame_tree_node_->frame_tree_node_id()));
588 navigation_request_->BeginNavigation(params.request_body); 562 navigation_request_->BeginNavigation(params.request_body);
589 } 563 }
590 564
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( 599 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager(
626 render_frame_host_->GetSiteInstance()); 600 render_frame_host_->GetSiteInstance());
627 if (!InitRenderView(render_frame_host_->render_view_host(), 601 if (!InitRenderView(render_frame_host_->render_view_host(),
628 opener_route_id, 602 opener_route_id,
629 MSG_ROUTING_NONE, 603 MSG_ROUTING_NONE,
630 frame_tree_node_->IsMainFrame())) { 604 frame_tree_node_->IsMainFrame())) {
631 return; 605 return;
632 } 606 }
633 } 607 }
634 608
609 DCHECK(navigation_parameters_.get());
610 navigation_parameters_->UpdateFromCommitInfo(info);
635 frame_tree_node_->navigator()->CommitNavigation( 611 frame_tree_node_->navigator()->CommitNavigation(
636 render_frame_host_.get(), info); 612 render_frame_host_.get(),
613 navigation_parameters_->MakeCommitNavigationParams());
637 } 614 }
638 615
639 void RenderFrameHostManager::Observe( 616 void RenderFrameHostManager::Observe(
640 int type, 617 int type,
641 const NotificationSource& source, 618 const NotificationSource& source,
642 const NotificationDetails& details) { 619 const NotificationDetails& details) {
643 switch (type) { 620 switch (type) {
644 case NOTIFICATION_RENDERER_PROCESS_CLOSED: 621 case NOTIFICATION_RENDERER_PROCESS_CLOSED:
645 case NOTIFICATION_RENDERER_PROCESS_CLOSING: 622 case NOTIFICATION_RENDERER_PROCESS_CLOSING:
646 RendererProcessClosing( 623 RendererProcessClosing(
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1664 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1688 SiteInstance* instance) { 1665 SiteInstance* instance) {
1689 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1666 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1690 if (iter != proxy_hosts_.end()) { 1667 if (iter != proxy_hosts_.end()) {
1691 delete iter->second; 1668 delete iter->second;
1692 proxy_hosts_.erase(iter); 1669 proxy_hosts_.erase(iter);
1693 } 1670 }
1694 } 1671 }
1695 1672
1696 } // namespace content 1673 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698