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