OLD | NEW |
---|---|
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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 75 |
76 | 76 |
77 NavigatorImpl::NavigatorImpl( | 77 NavigatorImpl::NavigatorImpl( |
78 NavigationControllerImpl* navigation_controller, | 78 NavigationControllerImpl* navigation_controller, |
79 NavigatorDelegate* delegate) | 79 NavigatorDelegate* delegate) |
80 : controller_(navigation_controller), | 80 : controller_(navigation_controller), |
81 delegate_(delegate) { | 81 delegate_(delegate) { |
82 } | 82 } |
83 | 83 |
84 // static. | 84 // static. |
85 scoped_ptr<FrameMsg_CommitNavigation_Params> | |
86 NavigatorImpl::MakeCommitNavigationParams( | |
87 const NavigationEntryImpl& entry, | |
88 const NavigatorImpl* navigator, | |
89 NavigationController::ReloadType reload_type) { | |
90 scoped_ptr<FrameMsg_CommitNavigation_Params> commit_navigation_params( | |
91 new FrameMsg_CommitNavigation_Params()); | |
92 commit_navigation_params->page_id = entry.GetPageID(); | |
93 navigator->controller_->FillHistoryParametersForNavigationEntry( | |
(Do not use) nasko
2014/08/28 16:39:08
Do we need navigator for anything else than the co
clamy
2014/09/02 18:25:19
Done.
| |
94 entry, | |
95 &commit_navigation_params->pending_history_list_offset, | |
96 &commit_navigation_params->current_history_list_offset, | |
97 &commit_navigation_params->current_history_list_length); | |
98 commit_navigation_params->should_clear_history_list = | |
99 entry.should_clear_history_list(); | |
100 commit_navigation_params->referrer = entry.GetReferrer(); | |
101 commit_navigation_params->transition = entry.GetTransitionType(); | |
102 commit_navigation_params->page_state = entry.GetPageState(); | |
103 commit_navigation_params->navigation_type = GetNavigationType( | |
104 navigator->controller_->GetBrowserContext(), entry, reload_type); | |
105 commit_navigation_params->is_overriding_user_agent = | |
106 entry.GetIsOverridingUserAgent(); | |
107 return commit_navigation_params.Pass(); | |
108 } | |
109 | |
110 // static. | |
85 void NavigatorImpl::MakeNavigateParams( | 111 void NavigatorImpl::MakeNavigateParams( |
86 const NavigationEntryImpl& entry, | 112 const NavigationEntryImpl& entry, |
87 const NavigationControllerImpl& controller, | 113 const NavigatorImpl* navigator, |
88 NavigationController::ReloadType reload_type, | 114 NavigationController::ReloadType reload_type, |
89 base::TimeTicks navigation_start, | 115 base::TimeTicks navigation_start, |
90 FrameMsg_Navigate_Params* params) { | 116 FrameMsg_Navigate_Params* params) { |
91 params->page_id = entry.GetPageID(); | 117 params->page_id = entry.GetPageID(); |
92 params->should_clear_history_list = entry.should_clear_history_list(); | 118 params->should_clear_history_list = entry.should_clear_history_list(); |
93 params->should_replace_current_entry = entry.should_replace_entry(); | 119 params->should_replace_current_entry = entry.should_replace_entry(); |
94 if (entry.should_clear_history_list()) { | |
95 // Set the history list related parameters to the same values a | |
96 // NavigationController would return before its first navigation. This will | |
97 // fully clear the RenderView's view of the session history. | |
98 params->pending_history_list_offset = -1; | |
99 params->current_history_list_offset = -1; | |
100 params->current_history_list_length = 0; | |
101 } else { | |
102 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | |
103 params->current_history_list_offset = | |
104 controller.GetLastCommittedEntryIndex(); | |
105 params->current_history_list_length = controller.GetEntryCount(); | |
106 } | |
107 params->url = entry.GetURL(); | 120 params->url = entry.GetURL(); |
121 navigator->controller_->FillHistoryParametersForNavigationEntry( | |
122 entry, | |
123 ¶ms->pending_history_list_offset, | |
124 ¶ms->current_history_list_offset, | |
125 ¶ms->current_history_list_length); | |
108 if (!entry.GetBaseURLForDataURL().is_empty()) { | 126 if (!entry.GetBaseURLForDataURL().is_empty()) { |
109 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); | 127 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); |
110 params->history_url_for_data_url = entry.GetVirtualURL(); | 128 params->history_url_for_data_url = entry.GetVirtualURL(); |
111 } | 129 } |
112 params->referrer = entry.GetReferrer(); | 130 params->referrer = entry.GetReferrer(); |
113 params->transition = entry.GetTransitionType(); | 131 params->transition = entry.GetTransitionType(); |
114 params->page_state = entry.GetPageState(); | 132 params->page_state = entry.GetPageState(); |
115 params->navigation_type = | 133 params->navigation_type = GetNavigationType( |
116 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); | 134 navigator->controller_->GetBrowserContext(), entry, reload_type); |
117 // This is used by the old performance infrastructure to set up DocumentState | 135 // This is used by the old performance infrastructure to set up DocumentState |
118 // associated with the RenderView. | 136 // associated with the RenderView. |
119 // TODO(ppi): make it go away. | 137 // TODO(ppi): make it go away. |
120 params->request_time = base::Time::Now(); | 138 params->request_time = base::Time::Now(); |
121 params->extra_headers = entry.extra_headers(); | 139 params->extra_headers = entry.extra_headers(); |
122 params->transferred_request_child_id = | 140 params->transferred_request_child_id = |
123 entry.transferred_global_request_id().child_id; | 141 entry.transferred_global_request_id().child_id; |
124 params->transferred_request_request_id = | 142 params->transferred_request_request_id = |
125 entry.transferred_global_request_id().request_id; | 143 entry.transferred_global_request_id().request_id; |
126 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); | 144 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 362 |
345 // WebContents uses this to fill LoadNotificationDetails when the load | 363 // WebContents uses this to fill LoadNotificationDetails when the load |
346 // completes, so that PerformanceMonitor that listens to the notification can | 364 // completes, so that PerformanceMonitor that listens to the notification can |
347 // record the load time. PerformanceMonitor is no longer maintained. | 365 // record the load time. PerformanceMonitor is no longer maintained. |
348 // TODO(ppi): make this go away. | 366 // TODO(ppi): make this go away. |
349 current_load_start_ = base::TimeTicks::Now(); | 367 current_load_start_ = base::TimeTicks::Now(); |
350 | 368 |
351 // Create the navigation parameters. | 369 // Create the navigation parameters. |
352 FrameMsg_Navigate_Params navigate_params; | 370 FrameMsg_Navigate_Params navigate_params; |
353 MakeNavigateParams( | 371 MakeNavigateParams( |
354 entry, *controller_, reload_type, navigation_start, &navigate_params); | 372 entry, this, reload_type, navigation_start, &navigate_params); |
355 | 373 |
356 RenderFrameHostManager* manager = | 374 RenderFrameHostManager* manager = |
357 render_frame_host->frame_tree_node()->render_manager(); | 375 render_frame_host->frame_tree_node()->render_manager(); |
358 | 376 |
359 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead | 377 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. Instead |
360 // the RenderFrameHostManager handles the navigation requests for that frame | 378 // the RenderFrameHostManager handles the navigation requests for that frame |
361 // node. | 379 // node. |
362 if (CommandLine::ForCurrentProcess()->HasSwitch( | 380 if (CommandLine::ForCurrentProcess()->HasSwitch( |
363 switches::kEnableBrowserSideNavigation)) { | 381 switches::kEnableBrowserSideNavigation)) { |
364 return manager->RequestNavigation(entry, navigate_params); | 382 return manager->RequestNavigation( |
383 MakeCommitNavigationParams(entry, this, reload_type), | |
384 navigate_params); | |
365 } | 385 } |
366 | 386 |
367 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); | 387 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); |
368 if (!dest_render_frame_host) | 388 if (!dest_render_frame_host) |
369 return false; // Unable to create the desired RenderFrameHost. | 389 return false; // Unable to create the desired RenderFrameHost. |
370 | 390 |
371 // Make sure no code called via RFHM::Navigate clears the pending entry. | 391 // Make sure no code called via RFHM::Navigate clears the pending entry. |
372 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 392 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
373 | 393 |
374 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 394 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 // Navigations in Web UI pages count as browser-initiated navigations. | 677 // Navigations in Web UI pages count as browser-initiated navigations. |
658 params.is_renderer_initiated = false; | 678 params.is_renderer_initiated = false; |
659 } | 679 } |
660 | 680 |
661 if (delegate_) | 681 if (delegate_) |
662 delegate_->RequestOpenURL(render_frame_host, params); | 682 delegate_->RequestOpenURL(render_frame_host, params); |
663 } | 683 } |
664 | 684 |
665 void NavigatorImpl::CommitNavigation( | 685 void NavigatorImpl::CommitNavigation( |
666 RenderFrameHostImpl* render_frame_host, | 686 RenderFrameHostImpl* render_frame_host, |
667 const NavigationBeforeCommitInfo& info) { | 687 scoped_ptr<FrameMsg_CommitNavigation_Params> commit_navigation_params) { |
668 CheckWebUIRendererDoesNotDisplayNormalURL( | 688 CheckWebUIRendererDoesNotDisplayNormalURL( |
669 render_frame_host, info.navigation_url); | 689 render_frame_host, commit_navigation_params->url); |
670 // TODO(clamy): the render_frame_host should now send a commit IPC to the | 690 render_frame_host->CommitNavigation(*commit_navigation_params.get()); |
671 // renderer. | |
672 } | 691 } |
673 | 692 |
674 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( | 693 void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( |
675 RenderFrameHostImpl* render_frame_host, | 694 RenderFrameHostImpl* render_frame_host, |
676 const GURL& url) { | 695 const GURL& url) { |
677 int enabled_bindings = | 696 int enabled_bindings = |
678 render_frame_host->render_view_host()->GetEnabledBindings(); | 697 render_frame_host->render_view_host()->GetEnabledBindings(); |
679 bool is_allowed_in_web_ui_renderer = | 698 bool is_allowed_in_web_ui_renderer = |
680 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 699 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
681 controller_->GetBrowserContext(), url); | 700 controller_->GetBrowserContext(), url); |
682 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 701 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
683 !is_allowed_in_web_ui_renderer) { | 702 !is_allowed_in_web_ui_renderer) { |
684 // Log the URL to help us diagnose any future failures of this CHECK. | 703 // Log the URL to help us diagnose any future failures of this CHECK. |
685 GetContentClient()->SetActiveURL(url); | 704 GetContentClient()->SetActiveURL(url); |
686 CHECK(0); | 705 CHECK(0); |
687 } | 706 } |
688 } | 707 } |
689 | 708 |
690 } // namespace content | 709 } // namespace content |
OLD | NEW |