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

Unified Diff: content/browser/frame_host/navigator_impl.cc

Issue 483773002: PlzNavigate: implement CommitNavigation on the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split the class into structs used by IPCs 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 7bde6cd9a54537e86539b1e3179fd99286986710..32aa46e927358a6c1065465d60a5726a0a376860 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -71,26 +71,17 @@ RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) {
return rfh->frame_tree_node()->frame_tree()->root()->render_manager();
}
-} // namespace
-
-
-NavigatorImpl::NavigatorImpl(
- NavigationControllerImpl* navigation_controller,
- NavigatorDelegate* delegate)
- : controller_(navigation_controller),
- delegate_(delegate) {
-}
-
-// static.
-void NavigatorImpl::MakeNavigateParams(
+void InitializeNavigationParams(
const NavigationEntryImpl& entry,
- const NavigationControllerImpl& controller,
+ NavigationControllerImpl* controller,
NavigationController::ReloadType reload_type,
base::TimeTicks navigation_start,
- FrameMsg_Navigate_Params* params) {
+ NavigationParamsWithRequestAndCommitInfo* params) {
+ params->url = entry.GetURL();
+ params->referrer = entry.GetReferrer();
+ params->transition = entry.GetTransitionType();
params->page_id = entry.GetPageID();
params->should_clear_history_list = entry.should_clear_history_list();
- params->should_replace_current_entry = entry.should_replace_entry();
if (entry.should_clear_history_list()) {
// Set the history list related parameters to the same values a
// NavigationController would return before its first navigation. This will
@@ -99,21 +90,40 @@ void NavigatorImpl::MakeNavigateParams(
params->current_history_list_offset = -1;
params->current_history_list_length = 0;
} else {
- params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
+ params->pending_history_list_offset =
+ controller->GetIndexOfEntry(&entry);
params->current_history_list_offset =
- controller.GetLastCommittedEntryIndex();
- params->current_history_list_length = controller.GetEntryCount();
+ controller->GetLastCommittedEntryIndex();
+ params->current_history_list_length =
+ controller->GetEntryCount();
}
- params->url = entry.GetURL();
+ params->page_state = entry.GetPageState();
+ params->navigation_type = GetNavigationType(
+ controller->GetBrowserContext(), entry, reload_type);
+ params->is_overriding_user_agent = entry.GetIsOverridingUserAgent();
+ params->browser_navigation_start = navigation_start;
+ params->is_post = entry.GetHasPostData();
+ // Avoid downloading when in view-source mode.
+ params->allow_download = !entry.IsViewSourceMode();
+}
+
+void MakeNavigateParams(
+ const NavigationEntryImpl& entry,
+ NavigationControllerImpl* controller,
+ NavigationController::ReloadType reload_type,
+ base::TimeTicks navigation_start,
+ FrameMsg_Navigate_Params* params) {
+ InitializeNavigationParams(
+ entry,
+ controller,
+ reload_type,
+ navigation_start,
+ static_cast<NavigationParamsWithRequestAndCommitInfo*>(params));
if (!entry.GetBaseURLForDataURL().is_empty()) {
params->base_url_for_data_url = entry.GetBaseURLForDataURL();
params->history_url_for_data_url = entry.GetVirtualURL();
}
- params->referrer = entry.GetReferrer();
- params->transition = entry.GetTransitionType();
- params->page_state = entry.GetPageState();
- params->navigation_type =
- GetNavigationType(controller.GetBrowserContext(), entry, reload_type);
+ params->should_replace_current_entry = entry.should_replace_entry();
// This is used by the old performance infrastructure to set up DocumentState
// associated with the RenderView.
// TODO(ppi): make it go away.
@@ -123,10 +133,6 @@ void NavigatorImpl::MakeNavigateParams(
entry.transferred_global_request_id().child_id;
params->transferred_request_request_id =
entry.transferred_global_request_id().request_id;
- params->is_overriding_user_agent = entry.GetIsOverridingUserAgent();
- // Avoid downloading when in view-source mode.
- params->allow_download = !entry.IsViewSourceMode();
- params->is_post = entry.GetHasPostData();
if (entry.GetBrowserInitiatedPostData()) {
params->browser_initiated_post_data.assign(
entry.GetBrowserInitiatedPostData()->front(),
@@ -144,7 +150,16 @@ void NavigatorImpl::MakeNavigateParams(
params->can_load_local_resources = entry.GetCanLoadLocalResources();
params->frame_to_navigate = entry.GetFrameToNavigate();
- params->browser_navigation_start = navigation_start;
+}
+
+} // namespace
+
+
+NavigatorImpl::NavigatorImpl(
+ NavigationControllerImpl* navigation_controller,
+ NavigatorDelegate* delegate)
+ : controller_(navigation_controller),
+ delegate_(delegate) {
}
NavigationController* NavigatorImpl::GetController() {
@@ -348,11 +363,6 @@ bool NavigatorImpl::NavigateToEntry(
// TODO(ppi): make this go away.
current_load_start_ = base::TimeTicks::Now();
- // Create the navigation parameters.
- FrameMsg_Navigate_Params navigate_params;
- MakeNavigateParams(
- entry, *controller_, reload_type, navigation_start, &navigate_params);
-
RenderFrameHostManager* manager =
render_frame_host->frame_tree_node()->render_manager();
@@ -361,7 +371,14 @@ bool NavigatorImpl::NavigateToEntry(
// node.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- return manager->RequestNavigation(entry, navigate_params);
+ scoped_ptr<NavigationParamsWithRequestAndCommitInfo> navigation_params(
+ new NavigationParamsWithRequestAndCommitInfo());
+ InitializeNavigationParams(entry,
+ controller_,
+ reload_type,
+ current_load_start_,
+ navigation_params.get());
+ return manager->RequestNavigation(navigation_params.Pass());
}
RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry);
@@ -380,6 +397,11 @@ bool NavigatorImpl::NavigateToEntry(
if (delegate_)
delegate_->AboutToNavigateRenderFrame(dest_render_frame_host);
+ // Create the navigation parameters.
+ FrameMsg_Navigate_Params navigate_params;
+ MakeNavigateParams(
+ entry, controller_, reload_type, navigation_start, &navigate_params);
+
// Navigate in the desired RenderFrameHost.
// We can skip this step in the rare case that this is a transfer navigation
// which began in the chosen RenderFrameHost, since the request has already
@@ -664,11 +686,24 @@ void NavigatorImpl::RequestTransferURL(
void NavigatorImpl::CommitNavigation(
RenderFrameHostImpl* render_frame_host,
- const NavigationBeforeCommitInfo& info) {
+ const FrameMsg_CommitNavigation_Params& commit_navigation_params) {
CheckWebUIRendererDoesNotDisplayNormalURL(
- render_frame_host, info.navigation_url);
- // TODO(clamy): the render_frame_host should now send a commit IPC to the
- // renderer.
+ render_frame_host, commit_navigation_params.url);
+ render_frame_host->CommitNavigation(commit_navigation_params);
+}
+
+scoped_ptr<NavigationParamsWithRequestAndCommitInfo>
+NavigatorImpl::MakeNavigationParamsForTest(
+ const NavigationEntryImpl& entry,
+ NavigationController::ReloadType reload_type) {
+ scoped_ptr<NavigationParamsWithRequestAndCommitInfo> navigation_params (
+ new NavigationParamsWithRequestAndCommitInfo());
+ InitializeNavigationParams(entry,
+ controller_,
+ reload_type,
+ base::TimeTicks::Now(),
+ navigation_params.get());
+ return navigation_params.Pass();
}
void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(

Powered by Google App Engine
This is Rietveld 408576698