diff options
26 files changed, 782 insertions, 380 deletions
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc index ec5b5f2..bb876c5 100644 --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc @@ -3895,7 +3895,7 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { ASSERT_TRUE(message != NULL); Tuple1<FrameMsg_Navigate_Params> nav_params; FrameMsg_Navigate::Read(message, &nav_params); - EXPECT_EQ(url1, nav_params.a.url); + EXPECT_EQ(url1, nav_params.a.common_params.url); process()->sink().ClearMessages(); // Now test history.forward() @@ -3907,7 +3907,7 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); ASSERT_TRUE(message != NULL); FrameMsg_Navigate::Read(message, &nav_params); - EXPECT_EQ(url3, nav_params.a.url); + EXPECT_EQ(url3, nav_params.a.common_params.url); process()->sink().ClearMessages(); controller.DiscardNonCommittedEntries(); diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc index e0c1215b..4e33ea5 100644 --- a/content/browser/frame_host/navigation_request.cc +++ b/content/browser/frame_host/navigation_request.cc @@ -5,6 +5,7 @@ #include "content/browser/frame_host/navigation_request.h" #include "base/logging.h" +#include "content/browser/frame_host/navigation_request_info.h" #include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/common/resource_request_body.h" #include "content/public/browser/browser_thread.h" @@ -16,13 +17,18 @@ namespace { // The next available browser-global navigation request ID. static int64 next_navigation_request_id_ = 0; -void OnBeginNavigation(const NavigationRequestInfo& info, +void OnBeginNavigation(const CommonNavigationParams& common_params, + const NavigationRequestInfo& info, scoped_refptr<ResourceRequestBody> request_body, int64 navigation_request_id, int64 frame_tree_node_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); ResourceDispatcherHostImpl::Get()->StartNavigationRequest( - info, request_body, navigation_request_id, frame_tree_node_id); + common_params, + info, + request_body, + navigation_request_id, + frame_tree_node_id); } void CancelNavigationRequest(int64 navigation_request_id, @@ -34,24 +40,30 @@ void CancelNavigationRequest(int64 navigation_request_id, } // namespace -NavigationRequest::NavigationRequest(const NavigationRequestInfo& info, - int64 frame_tree_node_id) - : navigation_request_id_(++next_navigation_request_id_), - info_(info), - frame_tree_node_id_(frame_tree_node_id) { +NavigationRequest::NavigationRequest( + int64 frame_tree_node_id, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params) + : navigation_request_id_(++next_navigation_request_id_), + frame_tree_node_id_(frame_tree_node_id), + common_params_(common_params), + commit_params_(commit_params) { } NavigationRequest::~NavigationRequest() { } void NavigationRequest::BeginNavigation( + scoped_ptr<NavigationRequestInfo> info, scoped_refptr<ResourceRequestBody> request_body) { + info_ = info.Pass(); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&OnBeginNavigation, - info_, + common_params_, + *info_, request_body, navigation_request_id_, frame_tree_node_id_)); diff --git a/content/browser/frame_host/navigation_request.h b/content/browser/frame_host/navigation_request.h index 44bbc30..8f24c75 100644 --- a/content/browser/frame_host/navigation_request.h +++ b/content/browser/frame_host/navigation_request.h @@ -7,11 +7,13 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" -#include "content/browser/frame_host/navigation_request_info.h" +#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" +#include "content/common/navigation_params.h" namespace content { class ResourceRequestBody; +struct NavigationRequestInfo; // PlzNavigate // A UI thread object that owns a navigation request until it commits. It @@ -19,33 +21,48 @@ class ResourceRequestBody; // ResourceDispatcherHost (that lives on the IO thread). // TODO(clamy): Describe the interactions between the UI and IO thread during // the navigation following its refactoring. -class NavigationRequest { +class CONTENT_EXPORT NavigationRequest { public: - NavigationRequest(const NavigationRequestInfo& info, - int64 frame_tree_node_id); + NavigationRequest(int64 frame_tree_node_id, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params); ~NavigationRequest(); // Called on the UI thread by the RenderFrameHostManager which owns the - // NavigationRequest. After calling this function, |body| can no longer be - // manipulated on the UI thread. - void BeginNavigation(scoped_refptr<ResourceRequestBody> body); + // NavigationRequest. Takes ownership of |info|. After calling this function, + // |body| can no longer be manipulated on the UI thread. + void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, + scoped_refptr<ResourceRequestBody> body); // Called on the UI thread by the RenderFrameHostManager which owns the // NavigationRequest whenever this navigation request should be canceled. void CancelNavigation(); - const NavigationRequestInfo& info() const { return info_; } - int64 frame_tree_node_id() const { return frame_tree_node_id_; } - int64 navigation_request_id() const { return navigation_request_id_; } + CommonNavigationParams& common_params() { return common_params_; } + + const CommitNavigationParams& commit_params() const { return commit_params_; } + + NavigationRequestInfo* info_for_test() const { return info_.get(); } + private: const int64 navigation_request_id_; - const NavigationRequestInfo info_; const int64 frame_tree_node_id_; + // Initialized on creation of the NavigationRequest. Sent to the renderer when + // the navigation is ready to commit. + // Note: When the navigation is ready to commit, the url in |common_params| + // will be set to the final navigation url, obtained after following all + // redirects. + CommonNavigationParams common_params_; + const CommitNavigationParams commit_params_; + + // Initialized when beginning the navigation. + scoped_ptr<NavigationRequestInfo> info_; + DISALLOW_COPY_AND_ASSIGN(NavigationRequest); }; diff --git a/content/browser/frame_host/navigation_request_info.h b/content/browser/frame_host/navigation_request_info.h index cc6d5a7..1800531 100644 --- a/content/browser/frame_host/navigation_request_info.h +++ b/content/browser/frame_host/navigation_request_info.h @@ -18,7 +18,8 @@ namespace content { // ResourceDispatcherHost. It is initialized on the UI thread, and then passed // to the IO thread by a NavigationRequest object. struct NavigationRequestInfo { - NavigationRequestInfo(const FrameHostMsg_BeginNavigation_Params& params); + explicit NavigationRequestInfo( + const FrameHostMsg_BeginNavigation_Params& params); const FrameHostMsg_BeginNavigation_Params navigation_params; diff --git a/content/browser/frame_host/navigator.h b/content/browser/frame_host/navigator.h index ce580d7..6e49dc3 100644 --- a/content/browser/frame_host/navigator.h +++ b/content/browser/frame_host/navigator.h @@ -26,7 +26,8 @@ class NavigationControllerImpl; class NavigationEntryImpl; class NavigatorDelegate; class RenderFrameHostImpl; -struct NavigationBeforeCommitInfo; +struct CommitNavigationParams; +struct CommonNavigationParams; // Implementations of this interface are responsible for performing navigations // in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode @@ -114,7 +115,9 @@ class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> { // Signal |render_frame_host| that a navigation is ready to commit (the // response to the navigation request has been received). virtual void CommitNavigation(RenderFrameHostImpl* render_frame_host, - const NavigationBeforeCommitInfo& info) {}; + const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params) {} // Called when the first resource request for a given navigation is executed // so that it can be tracked into an histogram. diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc index 0e9060e..dcd5544 100644 --- a/content/browser/frame_host/navigator_impl.cc +++ b/content/browser/frame_host/navigator_impl.cc @@ -12,6 +12,7 @@ #include "content/browser/frame_host/navigation_before_commit_info.h" #include "content/browser/frame_host/navigation_controller_impl.h" #include "content/browser/frame_host/navigation_entry_impl.h" +#include "content/browser/frame_host/navigation_request.h" #include "content/browser/frame_host/navigator_delegate.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h" @@ -19,6 +20,7 @@ #include "content/browser/webui/web_ui_controller_factory_registry.h" #include "content/browser/webui/web_ui_impl.h" #include "content/common/frame_messages.h" +#include "content/common/navigation_params.h" #include "content/common/view_messages.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" @@ -72,75 +74,53 @@ 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) { -} - -NavigatorImpl::~NavigatorImpl() { -} - -// static. -void NavigatorImpl::MakeNavigateParams( - const NavigationEntryImpl& entry, - const NavigationControllerImpl& controller, - NavigationController::ReloadType reload_type, - base::TimeTicks navigation_start, - FrameMsg_Navigate_Params* params) { - 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 - // fully clear the RenderView's view of the session history. - params->pending_history_list_offset = -1; - params->current_history_list_offset = -1; - params->current_history_list_length = 0; - } else { - params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); - params->current_history_list_offset = - controller.GetLastCommittedEntryIndex(); - params->current_history_list_length = controller.GetEntryCount(); - } - params->url = entry.GetURL(); +void MakeNavigateParams(const NavigationEntryImpl& entry, + NavigationControllerImpl* controller, + NavigationController::ReloadType reload_type, + base::TimeTicks navigation_start, + FrameMsg_Navigate_Params* params) { + params->common_params = CommonNavigationParams( + entry.GetURL(), entry.GetReferrer(), entry.GetTransitionType(), + GetNavigationType(controller->GetBrowserContext(), entry, reload_type), + !entry.IsViewSourceMode()); + params->request_params = RequestNavigationParams( + entry.GetHasPostData(), + entry.extra_headers(), + entry.GetBrowserInitiatedPostData()); + params->commit_params = CommitNavigationParams( + entry.GetPageState(), entry.GetIsOverridingUserAgent(), navigation_start); 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. params->request_time = base::Time::Now(); - params->extra_headers = entry.extra_headers(); params->transferred_request_child_id = 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(), - entry.GetBrowserInitiatedPostData()->front() + - entry.GetBrowserInitiatedPostData()->size()); - } + params->page_id = entry.GetPageID(); + params->should_clear_history_list = entry.should_clear_history_list(); + 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 + // fully clear the RenderView's view of the session history. + params->pending_history_list_offset = -1; + params->current_history_list_offset = -1; + params->current_history_list_length = 0; + } else { + params->pending_history_list_offset = controller->GetIndexOfEntry(&entry); + params->current_history_list_offset = + controller->GetLastCommittedEntryIndex(); + params->current_history_list_length = controller->GetEntryCount(); + } // Set the redirect chain to the navigation's redirects, unless we are // returning to a completed navigation (whose previous redirects don't apply). - if (ui::PageTransitionIsNewNavigation(params->transition)) { + if (ui::PageTransitionIsNewNavigation(params->common_params.transition)) { params->redirects = entry.GetRedirectChain(); } else { params->redirects.clear(); @@ -148,9 +128,20 @@ 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) { +} + +NavigatorImpl::~NavigatorImpl() {} + NavigationController* NavigatorImpl::GetController() { return controller_; } @@ -317,7 +308,6 @@ bool NavigatorImpl::NavigateToEntry( // capture the time needed for the RenderFrameHost initialization. base::TimeTicks navigation_start = base::TimeTicks::Now(); - FrameMsg_Navigate_Params navigate_params; RenderFrameHostManager* manager = render_frame_host->frame_tree_node()->render_manager(); @@ -327,10 +317,23 @@ bool NavigatorImpl::NavigateToEntry( if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)) { navigation_start_time_and_url = MakeTuple(navigation_start, entry.GetURL()); - // Create the navigation parameters. - MakeNavigateParams( - entry, *controller_, reload_type, navigation_start, &navigate_params); - return manager->RequestNavigation(entry, navigate_params); + FrameMsg_Navigate_Type::Value navigation_type = + GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); + scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( + render_frame_host->frame_tree_node()->frame_tree_node_id(), + CommonNavigationParams(entry.GetURL(), + entry.GetReferrer(), + entry.GetTransitionType(), + navigation_type, + !entry.IsViewSourceMode()), + CommitNavigationParams(entry.GetPageState(), + entry.GetIsOverridingUserAgent(), + navigation_start))); + RequestNavigationParams request_params(entry.GetHasPostData(), + entry.extra_headers(), + entry.GetBrowserInitiatedPostData()); + return manager->RequestNavigation(navigation_request.Pass(), + request_params); } RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); @@ -352,8 +355,9 @@ bool NavigatorImpl::NavigateToEntry( // Create the navigation parameters. // TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once // http://crbug.com/408684 is fixed. + FrameMsg_Navigate_Params navigate_params; MakeNavigateParams( - entry, *controller_, reload_type, navigation_start, &navigate_params); + 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 @@ -654,11 +658,12 @@ void NavigatorImpl::RequestTransferURL( void NavigatorImpl::CommitNavigation( RenderFrameHostImpl* render_frame_host, - const NavigationBeforeCommitInfo& info) { - CheckWebUIRendererDoesNotDisplayNormalURL( - render_frame_host, info.navigation_url); - // TODO(clamy): the render_frame_host should now send a commit IPC to the - // renderer. + const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params) { + CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, + common_params.url); + render_frame_host->CommitNavigation(stream_url, common_params, commit_params); } void NavigatorImpl::LogResourceRequestTime( diff --git a/content/browser/frame_host/navigator_impl.h b/content/browser/frame_host/navigator_impl.h index b2cc5fc..3db2821 100644 --- a/content/browser/frame_host/navigator_impl.h +++ b/content/browser/frame_host/navigator_impl.h @@ -6,6 +6,7 @@ #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_ #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "base/tuple.h" #include "content/browser/frame_host/navigation_controller_impl.h" @@ -13,6 +14,7 @@ #include "content/common/content_export.h" #include "url/gurl.h" +class GURL; struct FrameMsg_Navigate_Params; namespace content { @@ -20,6 +22,9 @@ namespace content { class NavigationControllerImpl; class NavigatorDelegate; struct LoadCommittedDetails; +struct CommitNavigationParams; +struct CommonNavigationParams; +struct RequestNavigationParams; // This class is an implementation of Navigator, responsible for managing // navigations in regular browser tabs. @@ -28,13 +33,6 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator { NavigatorImpl(NavigationControllerImpl* navigation_controller, NavigatorDelegate* delegate); - // Fills in |params| based on the content of |entry|. - static void MakeNavigateParams(const NavigationEntryImpl& entry, - const NavigationControllerImpl& controller, - NavigationController::ReloadType reload_type, - base::TimeTicks navigation_start, - FrameMsg_Navigate_Params* params); - // Navigator implementation. virtual NavigationController* GetController() OVERRIDE; virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host, @@ -74,8 +72,9 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator { bool user_gesture) OVERRIDE; virtual void CommitNavigation( RenderFrameHostImpl* render_frame_host, - const NavigationBeforeCommitInfo& info) OVERRIDE; - + const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params) OVERRIDE; virtual void LogResourceRequestTime( base::TimeTicks timestamp, const GURL& url) OVERRIDE; diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index 7be414e..6498fd9 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -1054,10 +1054,11 @@ void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { } void RenderFrameHostImpl::OnBeginNavigation( - const FrameHostMsg_BeginNavigation_Params& params) { + const FrameHostMsg_BeginNavigation_Params& params, + const CommonNavigationParams& common_params) { CHECK(CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)); - frame_tree_node()->render_manager()->OnBeginNavigation(params); + frame_tree_node()->render_manager()->OnBeginNavigation(params, common_params); } void RenderFrameHostImpl::OnAccessibilityEvents( @@ -1227,8 +1228,8 @@ void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { // so do not grant them the ability to request additional URLs. if (!GetProcess()->IsIsolatedGuest()) { ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( - GetProcess()->GetID(), params.url); - if (params.url.SchemeIs(url::kDataScheme) && + GetProcess()->GetID(), params.common_params.url); + if (params.common_params.url.SchemeIs(url::kDataScheme) && params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { // If 'data:' is used, and we have a 'file:' base url, grant access to // local files. @@ -1265,20 +1266,20 @@ void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { // // Blink doesn't send throb notifications for JavaScript URLs, so we // don't want to either. - if (!params.url.SchemeIs(url::kJavaScriptScheme)) + if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme)) delegate_->DidStartLoading(this, true); } void RenderFrameHostImpl::NavigateToURL(const GURL& url) { FrameMsg_Navigate_Params params; + params.common_params.url = url; + params.common_params.transition = ui::PAGE_TRANSITION_LINK; + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.commit_params.browser_navigation_start = base::TimeTicks::Now(); params.page_id = -1; params.pending_history_list_offset = -1; params.current_history_list_offset = -1; params.current_history_list_length = 0; - params.url = url; - params.transition = ui::PAGE_TRANSITION_LINK; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.browser_navigation_start = base::TimeTicks::Now(); Navigate(params); } @@ -1371,6 +1372,20 @@ void RenderFrameHostImpl::NotificationClosed(int notification_id) { cancel_notification_callbacks_.erase(notification_id); } +// PlzNavigate +void RenderFrameHostImpl::CommitNavigation( + const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params) { + // TODO(clamy): Check if we have to add security checks for the browser plugin + // guests. + + Send(new FrameMsg_CommitNavigation( + routing_id_, stream_url, common_params, commit_params)); + // TODO(clamy): Check if we should start the throbber for non javascript urls + // here. +} + void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( int request_id, blink::WebNotificationPermission permission) { Send(new PlatformNotificationMsg_PermissionRequestComplete( @@ -1510,7 +1525,8 @@ void RenderFrameHostImpl::SetNavigationsSuspended( SetState(RenderFrameHostImpl::STATE_DEFAULT); DCHECK(!proceed_time.is_null()); - suspended_nav_params_->browser_navigation_start = proceed_time; + suspended_nav_params_->commit_params.browser_navigation_start = + proceed_time; Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); suspended_nav_params_.reset(); } diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index 341651a..4a9ab45 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -55,9 +55,12 @@ class RenderProcessHost; class RenderViewHostImpl; class RenderWidgetHostImpl; class TimeoutMonitor; +struct CommitNavigationParams; struct ContextMenuParams; +struct CommonNavigationParams; struct GlobalRequestID; struct Referrer; +struct RequestNavigationParams; struct ShowDesktopNotificationHostMsgParams; struct TransitionLayerData; @@ -344,6 +347,12 @@ class CONTENT_EXPORT RenderFrameHostImpl void DidCancelPopupMenu(); #endif + // PlzNavigate: Indicates that a navigation is ready to commit and can be + // handled by this RenderFrame. + void CommitNavigation(const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params); + protected: friend class RenderFrameHostFactory; @@ -413,8 +422,8 @@ class CONTENT_EXPORT RenderFrameHostImpl const base::string16& title, blink::WebTextDirection title_direction); void OnUpdateEncoding(const std::string& encoding); - void OnBeginNavigation( - const FrameHostMsg_BeginNavigation_Params& params); + void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, + const CommonNavigationParams& common_params); void OnAccessibilityEvents( const std::vector<AccessibilityHostMsg_EventParams>& params); void OnAccessibilityLocationChanges( diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc index 8d557ac..d3eb8db 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc @@ -30,6 +30,7 @@ #include "content/browser/site_instance_impl.h" #include "content/browser/webui/web_ui_controller_factory_registry.h" #include "content/browser/webui/web_ui_impl.h" +#include "content/common/navigation_params.h" #include "content/common/view_messages.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/notification_service.h" @@ -45,36 +46,50 @@ namespace content { -namespace { +// PlzNavigate +// Returns the net load flags to use based on the navigation type. +// TODO(clamy): unify the code with what is happening on the renderer side. +int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) { + int load_flags = net::LOAD_NORMAL; + switch (navigation_type) { + case FrameMsg_Navigate_Type::RELOAD: + case FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL: + load_flags |= net::LOAD_VALIDATE_CACHE; + break; + case FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE: + load_flags |= net::LOAD_BYPASS_CACHE; + break; + case FrameMsg_Navigate_Type::RESTORE: + load_flags |= net::LOAD_PREFERRING_CACHE; + break; + case FrameMsg_Navigate_Type::RESTORE_WITH_POST: + load_flags |= net::LOAD_ONLY_FROM_CACHE; + break; + case FrameMsg_Navigate_Type::NORMAL: + default: + break; + } + return load_flags; +} // PlzNavigate -// Simulates a renderer response to a navigation request when there is no live -// renderer. -FrameHostMsg_BeginNavigation_Params BeginNavigationFromNavigate( - const FrameMsg_Navigate_Params& navigate_params) { +// Generates a default FrameHostMsg_BeginNavigation_Params to be used when there +// is no live renderer. +FrameHostMsg_BeginNavigation_Params MakeDefaultBeginNavigation( + const RequestNavigationParams& request_params, + FrameMsg_Navigate_Type::Value navigation_type) { FrameHostMsg_BeginNavigation_Params begin_navigation_params; - begin_navigation_params.method = navigate_params.is_post ? "POST" : "GET"; - begin_navigation_params.url = navigate_params.url; - begin_navigation_params.referrer = - Referrer(navigate_params.referrer.url, navigate_params.referrer.policy); - - // TODO(clamy): This should be modified to take into account caching policy - // requirements (eg for POST reloads). - begin_navigation_params.load_flags = net::LOAD_NORMAL; + begin_navigation_params.method = request_params.is_post ? "POST" : "GET"; + begin_navigation_params.load_flags = + LoadFlagFromNavigationType(navigation_type); // TODO(clamy): Post data from the browser should be put in the request body. + // Headers should be filled in as well. begin_navigation_params.has_user_gesture = false; - begin_navigation_params.transition_type = navigate_params.transition; - begin_navigation_params.should_replace_current_entry = - navigate_params.should_replace_current_entry; - begin_navigation_params.allow_download = - navigate_params.allow_download; return begin_navigation_params; } -} // namespace - bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { node->render_manager()->pending_delete_hosts_.clear(); return true; @@ -565,33 +580,53 @@ void RenderFrameHostManager::ResetProxyHosts() { // PlzNavigate bool RenderFrameHostManager::RequestNavigation( - const NavigationEntryImpl& entry, - const FrameMsg_Navigate_Params& navigate_params) { + scoped_ptr<NavigationRequest> navigation_request, + const RequestNavigationParams& request_params) { CHECK(CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)); + + // TODO(clamy): Check if navigations are blocked and if so store the + // parameters. + + // If there is an ongoing request it must be canceled. + if (navigation_request_.get()) + navigation_request_->CancelNavigation(); + + navigation_request_ = navigation_request.Pass(); + if (render_frame_host_->IsRenderFrameLive()) { // TODO(clamy): send a RequestNavigation IPC. return true; } // The navigation request is sent directly to the IO thread. - OnBeginNavigation(BeginNavigationFromNavigate(navigate_params)); + OnBeginNavigation( + MakeDefaultBeginNavigation( + request_params, navigation_request_->common_params().navigation_type), + navigation_request_->common_params()); return true; } // PlzNavigate void RenderFrameHostManager::OnBeginNavigation( - const FrameHostMsg_BeginNavigation_Params& params) { + const FrameHostMsg_BeginNavigation_Params& params, + const CommonNavigationParams& common_params) { CHECK(CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)); - // TODO(clamy): Check if navigations are blocked and if so, return - // immediately. - NavigationRequestInfo info(params); - - info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ? - params.url : frame_tree_node_->frame_tree()->root()->current_url(); - info.is_main_frame = frame_tree_node_->IsMainFrame(); - info.parent_is_main_frame = !frame_tree_node_->parent() ? + // TODO(clamy): In case of a renderer initiated navigation create a new + // NavigationRequest. + DCHECK(navigation_request_.get()); + // Update the referrer with the one received from the renderer. + navigation_request_->common_params().referrer = common_params.referrer; + + scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); + + info->first_party_for_cookies = + frame_tree_node_->IsMainFrame() + ? navigation_request_->common_params().url + : frame_tree_node_->frame_tree()->root()->current_url(); + info->is_main_frame = frame_tree_node_->IsMainFrame(); + info->parent_is_main_frame = !frame_tree_node_->parent() ? false : frame_tree_node_->parent()->IsMainFrame(); // TODO(clamy): Check if the current RFH should be initialized (in case it has @@ -599,13 +634,7 @@ void RenderFrameHostManager::OnBeginNavigation( // TODO(clamy): Spawn a speculative renderer process if we do not have one to // use for the navigation. - // If there is an ongoing request it must be canceled. - if (navigation_request_.get()) - navigation_request_->CancelNavigation(); - - navigation_request_.reset(new NavigationRequest( - info, frame_tree_node_->frame_tree_node_id())); - navigation_request_->BeginNavigation(params.request_body); + navigation_request_->BeginNavigation(info.Pass(), params.request_body); } // PlzNavigate @@ -628,7 +657,7 @@ void RenderFrameHostManager::CommitNavigation( scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( info.navigation_url, NULL, - navigation_request_->info().navigation_params.transition_type, + navigation_request_->common_params().transition, false, false); DCHECK(!pending_render_frame_host_.get()); @@ -661,7 +690,10 @@ void RenderFrameHostManager::CommitNavigation( } frame_tree_node_->navigator()->CommitNavigation( - render_frame_host_.get(), info); + render_frame_host_.get(), + info.stream_url, + navigation_request_->common_params(), + navigation_request_->commit_params()); } void RenderFrameHostManager::Observe( diff --git a/content/browser/frame_host/render_frame_host_manager.h b/content/browser/frame_host/render_frame_host_manager.h index 4ca4546..058f6a0 100644 --- a/content/browser/frame_host/render_frame_host_manager.h +++ b/content/browser/frame_host/render_frame_host_manager.h @@ -43,7 +43,9 @@ class RenderWidgetHostDelegate; class RenderWidgetHostView; class TestWebContents; class WebUIImpl; +struct CommonNavigationParams; struct NavigationBeforeCommitInfo; +struct RequestNavigationParams; // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state // machine to make cross-process navigations in a frame possible. @@ -316,16 +318,18 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to // navigate. If no live renderer is present, then the navigation request will - // be sent directly to the ResourceDispatcherHost. - bool RequestNavigation(const NavigationEntryImpl& entry, - const FrameMsg_Navigate_Params& navigate_params); + // be sent directly to the ResourceDispatcherHost. Takes ownership of + // |navigation_request|. + bool RequestNavigation(scoped_ptr<NavigationRequest> navigation_request, + const RequestNavigationParams& request_params); // PlzNavigate: Used to start a navigation. OnBeginNavigation is called // directly by RequestNavigation when there is no live renderer. Otherwise, it // is called following a BeginNavigation IPC from the renderer (which in // browser-initiated navigation also happens after RequestNavigation has been // called). - void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); + void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, + const CommonNavigationParams& common_params); // PlzNavigate: Called when a navigation request has received a response, to // select a renderer to use for the navigation. diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc index 8d2cf17..23b49c8 100644 --- a/content/browser/frame_host/render_frame_host_manager_unittest.cc +++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc @@ -12,12 +12,14 @@ #include "content/browser/frame_host/navigation_controller_impl.h" #include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/frame_host/navigation_request.h" +#include "content/browser/frame_host/navigation_request_info.h" #include "content/browser/frame_host/navigator.h" #include "content/browser/frame_host/navigator_impl.h" #include "content/browser/frame_host/render_frame_host_manager.h" #include "content/browser/frame_host/render_frame_proxy_host.h" #include "content/browser/site_instance_impl.h" #include "content/browser/webui/web_ui_controller_factory_registry.h" +#include "content/common/navigation_params.h" #include "content/common/view_messages.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" @@ -40,6 +42,7 @@ #include "content/test/test_render_frame_host.h" #include "content/test/test_render_view_host.h" #include "content/test/test_web_contents.h" +#include "net/base/load_flags.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/page_transition_types.h" @@ -394,6 +397,47 @@ class RenderFrameHostManagerTest CommandLine::ForCurrentProcess()->AppendSwitch( switches::kEnableBrowserSideNavigation); } + + void SendRequestNavigation(FrameTreeNode* node, + const GURL& url) { + SendRequestNavigationWithParameters( + node, url, Referrer(), ui::PAGE_TRANSITION_LINK, + FrameMsg_Navigate_Type::NORMAL); + } + + void SendRequestNavigationWithParameters( + FrameTreeNode* node, + const GURL& url, + const Referrer& referrer, + ui::PageTransition transition_type, + FrameMsg_Navigate_Type::Value navigation_type) { + scoped_ptr<NavigationEntryImpl> entry( + NavigationEntryImpl::FromNavigationEntry( + NavigationController::CreateNavigationEntry( + url, + referrer, + transition_type, + false, + std::string(), + controller().GetBrowserContext()))); + scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( + node->frame_tree_node_id(), + CommonNavigationParams(entry->GetURL(), + entry->GetReferrer(), + entry->GetTransitionType(), + navigation_type, + !entry->IsViewSourceMode()), + CommitNavigationParams(entry->GetPageState(), + entry->GetIsOverridingUserAgent(), + base::TimeTicks::Now()))); + RequestNavigationParams request_params( + entry->GetHasPostData(), + entry->extra_headers(), + entry->GetBrowserInitiatedPostData()); + node->render_manager()->RequestNavigation(navigation_request.Pass(), + request_params); + } + private: RenderFrameHostManagerTestWebUIControllerFactory factory_; scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; @@ -1708,6 +1752,8 @@ TEST_F(RenderFrameHostManagerTest, // PlzNavigate: Test that a proper NavigationRequest is created by // BeginNavigation. +// Note that all PlzNavigate methods on the browser side require the use of the +// flag kEnableBrowserSideNavigation. TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { const GURL kUrl1("http://www.google.com/"); const GURL kUrl2("http://www.chromium.org/"); @@ -1725,29 +1771,33 @@ TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { contents()->GetFrameTree()->AddFrame( contents()->GetFrameTree()->root(), 14, "Child")); + RenderFrameHostManager* subframe_manager = + subframe_rfh->frame_tree_node()->render_manager(); + SendRequestNavigation(subframe_rfh->frame_tree_node(), kUrl2); // Simulate a BeginNavigation IPC on the subframe. subframe_rfh->SendBeginNavigationWithURL(kUrl2); NavigationRequest* subframe_request = - GetNavigationRequestForRenderFrameManager( - subframe_rfh->frame_tree_node()->render_manager()); + GetNavigationRequestForRenderFrameManager(subframe_manager); ASSERT_TRUE(subframe_request); - EXPECT_EQ(kUrl2, subframe_request->info().navigation_params.url); + EXPECT_EQ(kUrl2, subframe_request->common_params().url); // First party for cookies url should be that of the main frame. - EXPECT_EQ( - kUrl1, subframe_request->info().first_party_for_cookies); - EXPECT_FALSE(subframe_request->info().is_main_frame); - EXPECT_TRUE(subframe_request->info().parent_is_main_frame); + EXPECT_EQ(kUrl1, subframe_request->info_for_test()->first_party_for_cookies); + EXPECT_FALSE(subframe_request->info_for_test()->is_main_frame); + EXPECT_TRUE(subframe_request->info_for_test()->parent_is_main_frame); EXPECT_EQ(kFirstNavRequestID, subframe_request->navigation_request_id()); + RenderFrameHostManager* main_frame_manager = + contents()->GetMainFrame()->frame_tree_node()->render_manager(); + SendRequestNavigation(contents()->GetMainFrame()->frame_tree_node(), kUrl3); // Simulate a BeginNavigation IPC on the main frame. contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl3); - NavigationRequest* main_request = GetNavigationRequestForRenderFrameManager( - contents()->GetMainFrame()->frame_tree_node()->render_manager()); + NavigationRequest* main_request = + GetNavigationRequestForRenderFrameManager(main_frame_manager); ASSERT_TRUE(main_request); - EXPECT_EQ(kUrl3, main_request->info().navigation_params.url); - EXPECT_EQ(kUrl3, main_request->info().first_party_for_cookies); - EXPECT_TRUE(main_request->info().is_main_frame); - EXPECT_FALSE(main_request->info().parent_is_main_frame); + EXPECT_EQ(kUrl3, main_request->common_params().url); + EXPECT_EQ(kUrl3, main_request->info_for_test()->first_party_for_cookies); + EXPECT_TRUE(main_request->info_for_test()->is_main_frame); + EXPECT_FALSE(main_request->info_for_test()->parent_is_main_frame); EXPECT_EQ(kFirstNavRequestID + 1, main_request->navigation_request_id()); } @@ -1759,10 +1809,9 @@ TEST_F(RenderFrameHostManagerTest, EnableBrowserSideNavigation(); EXPECT_FALSE(main_test_rfh()->render_view_host()->IsRenderViewLive()); - contents()->GetController().LoadURL( - kUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); RenderFrameHostManager* render_manager = main_test_rfh()->frame_tree_node()->render_manager(); + SendRequestNavigation(main_test_rfh()->frame_tree_node(), kUrl); NavigationRequest* main_request = GetNavigationRequestForRenderFrameManager(render_manager); // A NavigationRequest should have been generated. @@ -1801,6 +1850,7 @@ TEST_F(RenderFrameHostManagerTest, EnableBrowserSideNavigation(); // Navigate to a different site. + SendRequestNavigation(main_test_rfh()->frame_tree_node(), kUrl2); main_test_rfh()->SendBeginNavigationWithURL(kUrl2); NavigationRequest* main_request = GetNavigationRequestForRenderFrameManager(render_manager); @@ -1837,6 +1887,7 @@ TEST_F(RenderFrameHostManagerTest, EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); // Request navigation to the 1st URL and gather data. + SendRequestNavigation(main_test_rfh()->frame_tree_node(), kUrl1); main_test_rfh()->SendBeginNavigationWithURL(kUrl1); NavigationRequest* request1 = GetNavigationRequestForRenderFrameManager(render_manager); @@ -1844,6 +1895,7 @@ TEST_F(RenderFrameHostManagerTest, int64 request_id1 = request1->navigation_request_id(); // Request navigation to the 2nd URL and gather more data. + SendRequestNavigation(main_test_rfh()->frame_tree_node(), kUrl2); main_test_rfh()->SendBeginNavigationWithURL(kUrl2); NavigationRequest* request2 = GetNavigationRequestForRenderFrameManager(render_manager); @@ -1891,4 +1943,42 @@ TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationHistogramTest) { histo_tester.ExpectTotalCount("Navigation.TimeToCommit", 2); } +// PlzNavigate: Test that a reload navigation is properly signaled to the +// renderer when the navigation can commit. +TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationReload) { + const GURL kUrl("http://www.google.com/"); + contents()->NavigateAndCommit(kUrl); + + EnableBrowserSideNavigation(); + RenderFrameHostManager* render_manager = + main_test_rfh()->frame_tree_node()->render_manager(); + SendRequestNavigationWithParameters( + main_test_rfh()->frame_tree_node(), kUrl, Referrer(), + ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::RELOAD); + contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); + // A NavigationRequest should have been generated. + NavigationRequest* main_request = + GetNavigationRequestForRenderFrameManager(render_manager); + ASSERT_TRUE(main_request != NULL); + EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD, + main_request->common_params().navigation_type); + int page_id = contents()->GetMaxPageIDForSiteInstance( + main_test_rfh()->GetSiteInstance()) + 1; + main_test_rfh()->SendNavigate(page_id, kUrl); + + // Now do a shift+reload. + SendRequestNavigationWithParameters( + main_test_rfh()->frame_tree_node(), + kUrl, + Referrer(), + ui::PAGE_TRANSITION_LINK, + FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); + contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); + // A NavigationRequest should have been generated. + main_request = GetNavigationRequestForRenderFrameManager(render_manager); + ASSERT_TRUE(main_request != NULL); + EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, + main_request->common_params().navigation_type); +} + } // namespace content diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc index bdff087..e69020b 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc @@ -54,6 +54,7 @@ #include "content/browser/streams/stream_registry.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/appcache_interfaces.h" +#include "content/common/navigation_params.h" #include "content/common/resource_messages.h" #include "content/common/ssl_status_serialization.h" #include "content/common/view_messages.h" @@ -1755,6 +1756,7 @@ void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( } void ResourceDispatcherHostImpl::StartNavigationRequest( + const CommonNavigationParams& params, const NavigationRequestInfo& info, scoped_refptr<ResourceRequestBody> request_body, int64 navigation_request_id, diff --git a/content/browser/loader/resource_dispatcher_host_impl.h b/content/browser/loader/resource_dispatcher_host_impl.h index 48d9755..d1431a4 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.h +++ b/content/browser/loader/resource_dispatcher_host_impl.h @@ -61,6 +61,7 @@ class ResourceMessageFilter; class ResourceRequestInfoImpl; class SaveFileManager; class WebContentsImpl; +struct CommonNavigationParams; struct DownloadSaveInfo; struct NavigationRequestInfo; struct Referrer; @@ -252,7 +253,8 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl // PlzNavigate // Called by NavigationRequest to start a navigation request in the node // identified by |frame_node_id|. - void StartNavigationRequest(const NavigationRequestInfo& info, + void StartNavigationRequest(const CommonNavigationParams& common_params, + const NavigationRequestInfo& info, scoped_refptr<ResourceRequestBody> request_body, int64 navigation_request_id, int64 frame_node_id); diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h index f4b0825..f3d9e26 100644 --- a/content/common/frame_messages.h +++ b/content/common/frame_messages.h @@ -10,6 +10,7 @@ #include "content/common/frame_message_enums.h" #include "content/common/frame_param.h" #include "content/common/navigation_gesture.h" +#include "content/common/navigation_params.h" #include "content/common/resource_request_body.h" #include "content/public/common/color_suggestion.h" #include "content/public/common/common_param_traits.h" @@ -173,7 +174,35 @@ IPC_STRUCT_BEGIN_WITH_PARENT(FrameHostMsg_DidCommitProvisionalLoad_Params, IPC_STRUCT_MEMBER(int, render_view_routing_id) IPC_STRUCT_END() +IPC_STRUCT_TRAITS_BEGIN(content::CommonNavigationParams) + IPC_STRUCT_TRAITS_MEMBER(url) + IPC_STRUCT_TRAITS_MEMBER(referrer) + IPC_STRUCT_TRAITS_MEMBER(transition) + IPC_STRUCT_TRAITS_MEMBER(navigation_type) + IPC_STRUCT_TRAITS_MEMBER(allow_download) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(content::RequestNavigationParams) + IPC_STRUCT_TRAITS_MEMBER(is_post) + IPC_STRUCT_TRAITS_MEMBER(extra_headers) + IPC_STRUCT_TRAITS_MEMBER(browser_initiated_post_data) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(content::CommitNavigationParams) + IPC_STRUCT_TRAITS_MEMBER(page_state) + IPC_STRUCT_TRAITS_MEMBER(is_overriding_user_agent) + IPC_STRUCT_TRAITS_MEMBER(browser_navigation_start) +IPC_STRUCT_TRAITS_END() + IPC_STRUCT_BEGIN(FrameMsg_Navigate_Params) + // TODO(clamy): investigate which parameters are also needed in PlzNavigate + // and move them to the appropriate NavigationParams struct. + + // These structs contain parameters shared by other navigation IPCs. + IPC_STRUCT_MEMBER(content::CommonNavigationParams, common_params) + IPC_STRUCT_MEMBER(content::RequestNavigationParams, request_params) + IPC_STRUCT_MEMBER(content::CommitNavigationParams, commit_params) + // The page_id for this navigation, or -1 if it is a new navigation. Back, // Forward, and Reload navigations should have a valid page_id. If the load // succeeds, then this page_id will be reflected in the resultant @@ -195,9 +224,6 @@ IPC_STRUCT_BEGIN(FrameMsg_Navigate_Params) // succesful when the navigation commits. IPC_STRUCT_MEMBER(bool, should_clear_history_list) - // The URL to load. - IPC_STRUCT_MEMBER(GURL, url) - // Base URL for use in WebKit's SubstituteData. // Is only used with data: URLs. IPC_STRUCT_MEMBER(GURL, base_url_for_data_url) @@ -206,36 +232,20 @@ IPC_STRUCT_BEGIN(FrameMsg_Navigate_Params) // Is only used with data: URLs. IPC_STRUCT_MEMBER(GURL, history_url_for_data_url) - // The URL to send in the "Referer" header field. Can be empty if there is - // no referrer. - IPC_STRUCT_MEMBER(content::Referrer, referrer) - // Any redirect URLs that occurred before |url|. Useful for cross-process // navigations; defaults to empty. IPC_STRUCT_MEMBER(std::vector<GURL>, redirects) - // The type of transition. - IPC_STRUCT_MEMBER(ui::PageTransition, transition) - // Informs the RenderView the pending navigation should replace the current // history entry when it commits. This is used for cross-process redirects so // the transferred navigation can recover the navigation state. IPC_STRUCT_MEMBER(bool, should_replace_current_entry) - // Opaque history state (received by ViewHostMsg_UpdateState). - IPC_STRUCT_MEMBER(content::PageState, page_state) - - // Type of navigation. - IPC_STRUCT_MEMBER(FrameMsg_Navigate_Type::Value, navigation_type) - // The time the request was created. This is used by the old performance // infrastructure to set up DocumentState associated with the RenderView. // TODO(ppi): make it go away. IPC_STRUCT_MEMBER(base::Time, request_time) - // Extra headers (separated by \n) to send during the request. - IPC_STRUCT_MEMBER(std::string, extra_headers) - // The following two members identify a previous request that has been // created before this navigation is being transferred to a new render view. // This serves the purpose of recycling the old request. @@ -243,28 +253,12 @@ IPC_STRUCT_BEGIN(FrameMsg_Navigate_Params) IPC_STRUCT_MEMBER(int, transferred_request_child_id) IPC_STRUCT_MEMBER(int, transferred_request_request_id) - // Whether or not we should allow the url to download. - IPC_STRUCT_MEMBER(bool, allow_download) - - // Whether or not the user agent override string should be used. - IPC_STRUCT_MEMBER(bool, is_overriding_user_agent) - - // True if this was a post request. - IPC_STRUCT_MEMBER(bool, is_post) - - // If is_post is true, holds the post_data information from browser. Empty - // otherwise. - IPC_STRUCT_MEMBER(std::vector<unsigned char>, browser_initiated_post_data) - // Whether or not this url should be allowed to access local file:// // resources. IPC_STRUCT_MEMBER(bool, can_load_local_resources) // If not empty, which frame to navigate. IPC_STRUCT_MEMBER(std::string, frame_to_navigate) - - // The navigationStart time to expose through the Navigation Timing API to JS. - IPC_STRUCT_MEMBER(base::TimeTicks, browser_navigation_start) IPC_STRUCT_END() IPC_STRUCT_BEGIN(FrameHostMsg_OpenURL_Params) @@ -277,15 +271,12 @@ IPC_STRUCT_END() // PlzNavigate IPC_STRUCT_BEGIN(FrameHostMsg_BeginNavigation_Params) + // TODO(clamy): See if it is possible to define a common struct between this + // IPC and ResourceMsg_Request_Params. + // The request method: GET, POST, etc. IPC_STRUCT_MEMBER(std::string, method) - // The requested URL. - IPC_STRUCT_MEMBER(GURL, url) - - // The referrer to use (may be empty). - IPC_STRUCT_MEMBER(content::Referrer, referrer) - // Additional HTTP request headers. IPC_STRUCT_MEMBER(std::string, headers) @@ -298,15 +289,6 @@ IPC_STRUCT_BEGIN(FrameHostMsg_BeginNavigation_Params) // True if the request was user initiated. IPC_STRUCT_MEMBER(bool, has_user_gesture) - - IPC_STRUCT_MEMBER(ui::PageTransition, transition_type) - - // Whether this navigation should replace the current session history entry on - // commit. - IPC_STRUCT_MEMBER(bool, should_replace_current_entry) - - // Whether or not we should allow the URL to download. - IPC_STRUCT_MEMBER(bool, allow_download) IPC_STRUCT_END() #if defined(OS_MACOSX) || defined(OS_ANDROID) @@ -482,6 +464,15 @@ IPC_MESSAGE_ROUTED1(FrameMsg_SelectPopupMenuItem, #endif +// PlzNavigate +// Tells the renderer that a navigation is ready to commit. The renderer should +// request |stream_url| to get access to the stream containing the body of the +// response. +IPC_MESSAGE_ROUTED3(FrameMsg_CommitNavigation, + GURL, /* stream_url */ + content::CommonNavigationParams, /* common_params */ + content::CommitNavigationParams /* commit_params */) + // ----------------------------------------------------------------------------- // Messages sent from the renderer to the browser. @@ -744,9 +735,11 @@ IPC_MESSAGE_CONTROL4(FrameHostMsg_AddNavigationTransitionData, std::string /* selector */, std::string /* markup */) +// PlzNavigate // Tells the browser to perform a navigation. -IPC_MESSAGE_ROUTED1(FrameHostMsg_BeginNavigation, - FrameHostMsg_BeginNavigation_Params) +IPC_MESSAGE_ROUTED2(FrameHostMsg_BeginNavigation, + FrameHostMsg_BeginNavigation_Params, + content::CommonNavigationParams) // Sent once a paint happens after the first non empty layout. In other words // after the frame has painted something. diff --git a/content/common/navigation_params.cc b/content/common/navigation_params.cc new file mode 100644 index 0000000..31787ac --- /dev/null +++ b/content/common/navigation_params.cc @@ -0,0 +1,61 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/navigation_params.h" + +#include "base/memory/ref_counted_memory.h" + +namespace content { +CommonNavigationParams::CommonNavigationParams() + : transition(ui::PAGE_TRANSITION_LINK), + navigation_type(FrameMsg_Navigate_Type::NORMAL), + allow_download(true) { +} + +CommonNavigationParams::~CommonNavigationParams() {} + +CommonNavigationParams::CommonNavigationParams( + const GURL& url, + const Referrer& referrer, + ui::PageTransition transition, + FrameMsg_Navigate_Type::Value navigation_type, + bool allow_download) + : url(url), + referrer(referrer), + transition(transition), + navigation_type(navigation_type), + allow_download(allow_download) { +} + +RequestNavigationParams::RequestNavigationParams() : is_post(false) {} + +RequestNavigationParams::RequestNavigationParams( + bool is_post, + const std::string& extra_headers, + const base::RefCountedMemory* post_data) + : is_post(is_post), + extra_headers(extra_headers) { + if (post_data) { + browser_initiated_post_data.assign( + post_data->front(), post_data->front() + post_data->size()); + } +} + +RequestNavigationParams::~RequestNavigationParams() {} + +CommitNavigationParams::CommitNavigationParams() + : is_overriding_user_agent(false) { +} + +CommitNavigationParams::CommitNavigationParams(const PageState& page_state, + bool is_overriding_user_agent, + base::TimeTicks navigation_start) + : page_state(page_state), + is_overriding_user_agent(is_overriding_user_agent), + browser_navigation_start(navigation_start) { +} + +CommitNavigationParams::~CommitNavigationParams() {} + +} // namespace content diff --git a/content/common/navigation_params.h b/content/common/navigation_params.h new file mode 100644 index 0000000..d30d382 --- /dev/null +++ b/content/common/navigation_params.h @@ -0,0 +1,104 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_COMMON_NAVIGATION_PARAMS_H_ +#define CONTENT_COMMON_NAVIGATION_PARAMS_H_ + +#include <string> + +#include "base/basictypes.h" +#include "base/time/time.h" +#include "content/common/content_export.h" +#include "content/common/frame_message_enums.h" +#include "content/public/common/page_state.h" +#include "content/public/common/referrer.h" +#include "ui/base/page_transition_types.h" +#include "url/gurl.h" + +namespace base { +class RefCountedMemory; +} + +namespace content { +class NavigationEntry; + +// The following structures hold parameters used during a navigation. In +// particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and +// FrameHostMsg_BeginNavigation. +// TODO(clamy): Depending on the avancement of the history refactoring move the +// history parameters from FrameMsg_Navigate into one of the structs. + +// Used by all navigation IPCs. +struct CONTENT_EXPORT CommonNavigationParams { + CommonNavigationParams(); + CommonNavigationParams(const GURL& url, + const Referrer& referrer, + ui::PageTransition transition, + FrameMsg_Navigate_Type::Value navigation_type, + bool allow_download); + ~CommonNavigationParams(); + + // The URL to navigate to. + // PlzNavigate: May be modified when the navigation is ready to commit. + GURL url; + + // The URL to send in the "Referer" header field. Can be empty if there is + // no referrer. + Referrer referrer; + + // The type of transition. + ui::PageTransition transition; + + // Type of navigation. + FrameMsg_Navigate_Type::Value navigation_type; + + // Allows the URL to be downloaded (true by default). + // Avoid downloading when in view-source mode. + bool allow_download; +}; + +// Used by FrameMsg_Navigate. +// PlzNavigate: sent to the renderer when requesting a navigation. +struct CONTENT_EXPORT RequestNavigationParams { + RequestNavigationParams(); + RequestNavigationParams(bool is_post, + const std::string& extra_headers, + const base::RefCountedMemory* post_data); + ~RequestNavigationParams(); + + // Whether the navigation is a POST request (as opposed to a GET). + bool is_post; + + // Extra headers (separated by \n) to send during the request. + std::string extra_headers; + + // If is_post is true, holds the post_data information from browser. Empty + // otherwise. + std::vector<unsigned char> browser_initiated_post_data; +}; + +// Used by FrameMsg_Navigate. +// PlzNavigate: sent to the renderer when the navigation is ready to commit. +struct CONTENT_EXPORT CommitNavigationParams { + CommitNavigationParams(); + CommitNavigationParams(const PageState& page_state, + bool is_overriding_user_agent, + base::TimeTicks navigation_start); + ~CommitNavigationParams(); + + // Opaque history state (received by ViewHostMsg_UpdateState). + PageState page_state; + + // Whether or not the user agent override string should be used. + bool is_overriding_user_agent; + + // The navigationStart time to expose through the Navigation Timing API to JS. + base::TimeTicks browser_navigation_start; + + // TODO(clamy): Move the redirect chain here. +}; + +} // namespace content + +#endif // CONTENT_COMMON_NAVIGATION_PARAMS_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index 95ca603..53321cb 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -402,6 +402,8 @@ 'common/mojo/service_registry_impl.cc', 'common/mojo/service_registry_impl.h', 'common/navigation_gesture.h', + 'common/navigation_params.cc', + 'common/navigation_params.h', 'common/net/url_fetcher.cc', 'common/net/url_request_user_data.cc', 'common/net/url_request_user_data.h', diff --git a/content/public/test/render_view_test.cc b/content/public/test/render_view_test.cc index 25615bd..be2793f 100644 --- a/content/public/test/render_view_test.cc +++ b/content/public/test/render_view_test.cc @@ -338,8 +338,8 @@ void RenderViewTest::ClearHistory() { void RenderViewTest::Reload(const GURL& url) { FrameMsg_Navigate_Params params; - params.url = url; - params.navigation_type = FrameMsg_Navigate_Type::RELOAD; + params.common_params.url = url; + params.common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); impl->GetMainRenderFrame()->OnNavigate(params); FrameLoadWaiter(impl->GetMainRenderFrame()).Wait(); @@ -411,13 +411,14 @@ void RenderViewTest::GoToOffset(int offset, const PageState& state) { int pending_offset = offset + impl->history_list_offset(); FrameMsg_Navigate_Params navigate_params; - navigate_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - navigate_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + navigate_params.common_params.navigation_type = + FrameMsg_Navigate_Type::NORMAL; + navigate_params.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; navigate_params.current_history_list_length = history_list_length; navigate_params.current_history_list_offset = impl->history_list_offset(); navigate_params.pending_history_list_offset = pending_offset; navigate_params.page_id = impl->page_id_ + offset; - navigate_params.page_state = state; + navigate_params.commit_params.page_state = state; navigate_params.request_time = base::Time::Now(); FrameMsg_Navigate navigate_message(impl->GetMainRenderFrame()->GetRoutingID(), diff --git a/content/renderer/accessibility/renderer_accessibility_browsertest.cc b/content/renderer/accessibility/renderer_accessibility_browsertest.cc index 736ebb6..a197b9f 100644 --- a/content/renderer/accessibility/renderer_accessibility_browsertest.cc +++ b/content/renderer/accessibility/renderer_accessibility_browsertest.cc @@ -335,14 +335,15 @@ TEST_F(RendererAccessibilityTest, // because the element it was referring to no longer exists, // so the event here is from loading this new page. FrameMsg_Navigate_Params nav_params; - nav_params.url = GURL("data:text/html,<p>Hello, again.</p>"); - nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - nav_params.transition = ui::PAGE_TRANSITION_TYPED; + nav_params.common_params.url = GURL("data:text/html,<p>Hello, again.</p>"); + nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; nav_params.current_history_list_length = 1; nav_params.current_history_list_offset = 0; nav_params.pending_history_list_offset = 1; nav_params.page_id = -1; - nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + nav_params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(nav_params); accessibility->SendPendingAccessibilityEvents(); EXPECT_TRUE(sink_->GetUniqueMessageMatching( diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 9dba04f..4e03eca 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -797,6 +797,7 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, OnSetAccessibilityMode) IPC_MESSAGE_HANDLER(FrameMsg_DisownOpener, OnDisownOpener) + IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) #if defined(OS_ANDROID) IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) #elif defined(OS_MACOSX) @@ -810,15 +811,18 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", - "id", routing_id_, "url", params.url.possibly_invalid_spec()); - MaybeHandleDebugURL(params.url); + "id", routing_id_, + "url", params.common_params.url.possibly_invalid_spec()); + MaybeHandleDebugURL(params.common_params.url); if (!render_view_->webview()) return; - FOR_EACH_OBSERVER( - RenderViewObserver, render_view_->observers_, Navigate(params.url)); + FOR_EACH_OBSERVER(RenderViewObserver, + render_view_->observers_, + Navigate(params.common_params.url)); - bool is_reload = RenderViewImpl::IsReload(params); + bool is_reload = + RenderViewImpl::IsReload(params.common_params.navigation_type); WebURLRequest::CachePolicy cache_policy = WebURLRequest::UseProtocolCachePolicy; @@ -851,24 +855,27 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { is_swapped_out_ = false; } + int pending_history_list_offset = params.pending_history_list_offset; + int current_history_list_offset = params.current_history_list_offset; + int current_history_list_length = params.current_history_list_length; if (params.should_clear_history_list) { - CHECK_EQ(params.pending_history_list_offset, -1); - CHECK_EQ(params.current_history_list_offset, -1); - CHECK_EQ(params.current_history_list_length, 0); + CHECK_EQ(pending_history_list_offset, -1); + CHECK_EQ(current_history_list_offset, -1); + CHECK_EQ(current_history_list_length, 0); } - render_view_->history_list_offset_ = params.current_history_list_offset; - render_view_->history_list_length_ = params.current_history_list_length; + render_view_->history_list_offset_ = current_history_list_offset; + render_view_->history_list_length_ = current_history_list_length; if (render_view_->history_list_length_ >= 0) { render_view_->history_page_ids_.resize( render_view_->history_list_length_, -1); } - if (params.pending_history_list_offset >= 0 && - params.pending_history_list_offset < render_view_->history_list_length_) { - render_view_->history_page_ids_[params.pending_history_list_offset] = + if (pending_history_list_offset >= 0 && + pending_history_list_offset < render_view_->history_list_length_) { + render_view_->history_page_ids_[pending_history_list_offset] = params.page_id; } - GetContentClient()->SetActiveURL(params.url); + GetContentClient()->SetActiveURL(params.common_params.url); WebFrame* frame = frame_; if (!params.frame_to_navigate.empty()) { @@ -894,20 +901,20 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { // back/forward navigation event. if (is_reload) { bool reload_original_url = - (params.navigation_type == - FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); - bool ignore_cache = (params.navigation_type == - FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); + (params.common_params.navigation_type == + FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); + bool ignore_cache = (params.common_params.navigation_type == + FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); if (reload_original_url) - frame->reloadWithOverrideURL(params.url, true); + frame->reloadWithOverrideURL(params.common_params.url, true); else frame->reload(ignore_cache); - } else if (params.page_state.IsValid()) { + } else if (params.commit_params.page_state.IsValid()) { // We must know the page ID of the page we are navigating back to. DCHECK_NE(params.page_id, -1); scoped_ptr<HistoryEntry> entry = - PageStateToHistoryEntry(params.page_state); + PageStateToHistoryEntry(params.commit_params.page_state); if (entry) { // Ensure we didn't save the swapped out URL in UpdateState, since the // browser should never be telling us to navigate to swappedout://. @@ -917,7 +924,8 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { } else if (!params.base_url_for_data_url.is_empty()) { // A loadData request with a specified base URL. std::string mime_type, charset, data; - if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { + if (net::DataURL::Parse( + params.common_params.url, &mime_type, &charset, &data)) { frame->loadData( WebData(data.c_str(), data.length()), WebString::fromUTF8(mime_type), @@ -926,12 +934,12 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { params.history_url_for_data_url, false); } else { - CHECK(false) << - "Invalid URL passed: " << params.url.possibly_invalid_spec(); + CHECK(false) << "Invalid URL passed: " + << params.common_params.url.possibly_invalid_spec(); } } else { // Navigate to the given URL. - WebURLRequest request(params.url); + WebURLRequest request(params.common_params.url); // A session history navigation should have been accompanied by state. CHECK_EQ(params.page_id, -1); @@ -939,37 +947,39 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { if (frame->isViewSourceModeEnabled()) request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); - if (params.referrer.url.is_valid()) { + if (params.common_params.referrer.url.is_valid()) { WebString referrer = WebSecurityPolicy::generateReferrerHeader( - params.referrer.policy, - params.url, - WebString::fromUTF8(params.referrer.url.spec())); + params.common_params.referrer.policy, + params.common_params.url, + WebString::fromUTF8(params.common_params.referrer.url.spec())); if (!referrer.isEmpty()) - request.setHTTPReferrer(referrer, params.referrer.policy); + request.setHTTPReferrer(referrer, params.common_params.referrer.policy); } - if (!params.extra_headers.empty()) { - for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), - params.extra_headers.end(), "\n"); - i.GetNext(); ) { + if (!params.request_params.extra_headers.empty()) { + for (net::HttpUtil::HeadersIterator i( + params.request_params.extra_headers.begin(), + params.request_params.extra_headers.end(), + "\n"); + i.GetNext();) { request.addHTTPHeaderField(WebString::fromUTF8(i.name()), WebString::fromUTF8(i.values())); } } - if (params.is_post) { + if (params.request_params.is_post) { request.setHTTPMethod(WebString::fromUTF8("POST")); // Set post data. WebHTTPBody http_body; http_body.initialize(); const char* data = NULL; - if (params.browser_initiated_post_data.size()) { + if (params.request_params.browser_initiated_post_data.size()) { data = reinterpret_cast<const char*>( - ¶ms.browser_initiated_post_data.front()); + ¶ms.request_params.browser_initiated_post_data.front()); } - http_body.appendData( - WebData(data, params.browser_initiated_post_data.size())); + http_body.appendData(WebData( + data, params.request_params.browser_initiated_post_data.size())); request.setHTTPBody(http_body); } @@ -982,14 +992,15 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { // Navigation Timing information for the browser-initiated navigations. In // case of cross-process navigations, this carries over the time of // finishing the onbeforeunload handler of the previous page. - DCHECK(!params.browser_navigation_start.is_null()); + DCHECK(!params.commit_params.browser_navigation_start.is_null()); if (frame->provisionalDataSource()) { // |browser_navigation_start| is likely before this process existed, so we // can't use InterProcessTimeTicksConverter. We need at least to ensure // that the browser-side navigation start we set is not later than the one // on the renderer side. - base::TimeTicks navigation_start = std::min( - params.browser_navigation_start, renderer_navigation_start); + base::TimeTicks navigation_start = + std::min(params.commit_params.browser_navigation_start, + renderer_navigation_start); double navigation_start_seconds = (navigation_start - base::TimeTicks()).InSecondsF(); frame->provisionalDataSource()->setNavigationStartTime( @@ -2137,7 +2148,7 @@ void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame, navigation_state->pending_history_list_offset(); render_view_->pending_navigation_params_->should_clear_history_list = navigation_state->history_list_was_cleared(); - render_view_->pending_navigation_params_->transition = + render_view_->pending_navigation_params_->common_params.transition = navigation_state->transition_type(); render_view_->pending_navigation_params_->request_time = document_state->request_time(); @@ -3469,6 +3480,14 @@ void RenderFrameImpl::FocusedNodeChanged(const WebNode& node) { renderer_accessibility_->FocusedNodeChanged(node); } +// PlzNavigate +void RenderFrameImpl::OnCommitNavigation( + const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params) { + NOTIMPLEMENTED(); +} + WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( RenderFrame* render_frame, const NavigationPolicyInfo& info) { diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 7dd2860..eb47720 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -33,6 +33,7 @@ #include "content/renderer/media/android/renderer_media_player_manager.h" #endif +class GURL; class TransportDIB; struct FrameMsg_Navigate_Params; @@ -79,6 +80,8 @@ class RenderWidget; class RenderWidgetFullscreenPepper; class ScreenOrientationDispatcher; class UserMediaClientImpl; +struct CommitNavigationParams; +struct CommonNavigationParams; struct CustomContextMenuContext; class CONTENT_EXPORT RenderFrameImpl @@ -549,6 +552,11 @@ class CONTENT_EXPORT RenderFrameImpl void OnCopyToFindPboard(); #endif + // PlzNavigate + void OnCommitNavigation(const GURL& stream_url, + const CommonNavigationParams& common_params, + const CommitNavigationParams& commit_params); + // Virtual since overridden by WebTestProxy for layout tests. virtual blink::WebNavigationPolicy DecidePolicyForNavigation( RenderFrame* render_frame, diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index 5752e37..bbf0454 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -363,19 +363,20 @@ TEST_F(RenderViewImplTest, OnNavigationHttpPost) { FrameMsg_Navigate_Params nav_params; // An http url will trigger a resource load so cannot be used here. - nav_params.url = GURL("data:text/html,<div>Page</div>"); - nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - nav_params.transition = ui::PAGE_TRANSITION_TYPED; + nav_params.common_params.url = GURL("data:text/html,<div>Page</div>"); + nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; nav_params.page_id = -1; - nav_params.is_post = true; - nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + nav_params.request_params.is_post = true; + nav_params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); // Set up post data. const unsigned char* raw_data = reinterpret_cast<const unsigned char*>( "post \0\ndata"); const unsigned int length = 11; const std::vector<unsigned char> post_data(raw_data, raw_data + length); - nav_params.browser_initiated_post_data = post_data; + nav_params.request_params.browser_initiated_post_data = post_data; frame()->OnNavigate(nav_params); ProcessPendingMessages(); @@ -568,14 +569,15 @@ TEST_F(RenderViewImplTest, SendSwapOutACK) { // If we navigate back to this RenderView, ensure we don't send a state // update for the swapped out URL. (http://crbug.com/72235) FrameMsg_Navigate_Params nav_params; - nav_params.url = GURL("data:text/html,<div>Page B</div>"); - nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - nav_params.transition = ui::PAGE_TRANSITION_TYPED; + nav_params.common_params.url = GURL("data:text/html,<div>Page B</div>"); + nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; nav_params.current_history_list_length = 1; nav_params.current_history_list_offset = 0; nav_params.pending_history_list_offset = 1; nav_params.page_id = -1; - nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + nav_params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(nav_params); ProcessPendingMessages(); const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching( @@ -606,14 +608,15 @@ TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { // Back to page A (page_id 1) and commit. FrameMsg_Navigate_Params params_A; - params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_A.current_history_list_length = 2; params_A.current_history_list_offset = 1; params_A.pending_history_list_offset = 0; params_A.page_id = 1; - params_A.page_state = state_A; - params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params_A.commit_params.page_state = state_A; + params_A.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params_A); ProcessPendingMessages(); @@ -631,15 +634,16 @@ TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) { // provisional load in the renderer process, after we unload the old page). // Ensure the old page gets reloaded, not swappedout://. FrameMsg_Navigate_Params nav_params; - nav_params.url = GURL("data:text/html,<div>Page A</div>"); - nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; - nav_params.transition = ui::PAGE_TRANSITION_RELOAD; + nav_params.common_params.url = GURL("data:text/html,<div>Page A</div>"); + nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::RELOAD; + nav_params.common_params.transition = ui::PAGE_TRANSITION_RELOAD; nav_params.current_history_list_length = 2; nav_params.current_history_list_offset = 0; nav_params.pending_history_list_offset = 0; nav_params.page_id = 1; - nav_params.page_state = state_A; - nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + nav_params.commit_params.page_state = state_A; + nav_params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(nav_params); ProcessPendingMessages(); @@ -711,14 +715,15 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) { // Go back to C and commit, preparing for our real test. FrameMsg_Navigate_Params params_C; - params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params_C.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params_C.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_C.current_history_list_length = 4; params_C.current_history_list_offset = 3; params_C.pending_history_list_offset = 2; params_C.page_id = 3; - params_C.page_state = state_C; - params_C.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params_C.commit_params.page_state = state_C; + params_C.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params_C); ProcessPendingMessages(); render_thread_->sink().ClearMessages(); @@ -729,26 +734,28 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) { // Back to page B (page_id 2), without committing. FrameMsg_Navigate_Params params_B; - params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_B.current_history_list_length = 4; params_B.current_history_list_offset = 2; params_B.pending_history_list_offset = 1; params_B.page_id = 2; - params_B.page_state = state_B; - params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params_B.commit_params.page_state = state_B; + params_B.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params_B); // Back to page A (page_id 1) and commit. FrameMsg_Navigate_Params params; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_B.current_history_list_length = 4; params_B.current_history_list_offset = 2; params_B.pending_history_list_offset = 0; params.page_id = 1; - params.page_state = state_A; - params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params.commit_params.page_state = state_A; + params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params); ProcessPendingMessages(); @@ -796,14 +803,15 @@ TEST_F(RenderViewImplTest, StaleNavigationsIgnored) { // Back to page A (page_id 1) and commit. FrameMsg_Navigate_Params params_A; - params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_A.current_history_list_length = 2; params_A.current_history_list_offset = 1; params_A.pending_history_list_offset = 0; params_A.page_id = 1; - params_A.page_state = state_A; - params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params_A.commit_params.page_state = state_A; + params_A.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params_A); ProcessPendingMessages(); @@ -815,14 +823,16 @@ TEST_F(RenderViewImplTest, StaleNavigationsIgnored) { // The browser then sends a stale navigation to B, which should be ignored. FrameMsg_Navigate_Params params_B; - params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_B.current_history_list_length = 2; params_B.current_history_list_offset = 0; params_B.pending_history_list_offset = 1; params_B.page_id = 2; - params_B.page_state = state_A; // Doesn't matter, just has to be present. - params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params_B.commit_params.page_state = + state_A; // Doesn't matter, just has to be present. + params_B.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params_B); // State should be unchanged. @@ -883,14 +893,15 @@ TEST_F(RenderViewImplTest, DontIgnoreBackAfterNavEntryLimit) { // It has now dropped the first entry, but the renderer isn't notified. // Ensure that going back to page B (page_id 2) at offset 0 is successful. FrameMsg_Navigate_Params params_B; - params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; + params_B.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params_B.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; params_B.current_history_list_length = 2; params_B.current_history_list_offset = 1; params_B.pending_history_list_offset = 0; params_B.page_id = 2; - params_B.page_state = state_B; - params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params_B.commit_params.page_state = state_B; + params_B.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params_B); ProcessPendingMessages(); @@ -1596,9 +1607,10 @@ TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { // but won't complete synchronously. FrameMsg_Navigate_Params params; params.page_id = -1; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.url = GURL("data:text/html,test data"); - params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.common_params.url = GURL("data:text/html,test data"); + params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params); // An error occurred. @@ -1619,9 +1631,10 @@ TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { // but won't complete synchronously. FrameMsg_Navigate_Params params; params.page_id = -1; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.url = GURL("data:text/html,test data"); - params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.common_params.url = GURL("data:text/html,test data"); + params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params); // A cancellation occurred. @@ -2001,14 +2014,15 @@ TEST_F(RenderViewImplTest, ZoomLimit) { FrameMsg_Navigate_Params params; params.page_id = -1; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); // Verifies navigation to a URL with preset zoom level indeed sets the level. // Regression test for http://crbug.com/139559, where the level was not // properly set when it is out of the default zoom limits of WebView. - params.url = GURL("data:text/html,min_zoomlimit_test"); - view()->OnSetZoomLevelForLoadingURL(params.url, kMinZoomLevel); + params.common_params.url = GURL("data:text/html,min_zoomlimit_test"); + view()->OnSetZoomLevelForLoadingURL(params.common_params.url, kMinZoomLevel); frame()->OnNavigate(params); ProcessPendingMessages(); EXPECT_DOUBLE_EQ(kMinZoomLevel, view()->GetWebView()->zoomLevel()); @@ -2016,8 +2030,8 @@ TEST_F(RenderViewImplTest, ZoomLimit) { // It should work even when the zoom limit is temporarily changed in the page. view()->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), ZoomFactorToZoomLevel(1.0)); - params.url = GURL("data:text/html,max_zoomlimit_test"); - view()->OnSetZoomLevelForLoadingURL(params.url, kMaxZoomLevel); + params.common_params.url = GURL("data:text/html,max_zoomlimit_test"); + view()->OnSetZoomLevelForLoadingURL(params.common_params.url, kMaxZoomLevel); frame()->OnNavigate(params); ProcessPendingMessages(); EXPECT_DOUBLE_EQ(kMaxZoomLevel, view()->GetWebView()->zoomLevel()); @@ -2079,15 +2093,16 @@ TEST_F(RenderViewImplTest, NavigateFrame) { // Navigate the frame only. FrameMsg_Navigate_Params nav_params; - nav_params.url = GURL("data:text/html,world"); - nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - nav_params.transition = ui::PAGE_TRANSITION_TYPED; + nav_params.common_params.url = GURL("data:text/html,world"); + nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; nav_params.current_history_list_length = 1; nav_params.current_history_list_offset = 0; nav_params.pending_history_list_offset = 1; nav_params.page_id = -1; nav_params.frame_to_navigate = "frame"; - nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + nav_params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(nav_params); FrameLoadWaiter( RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); @@ -2205,9 +2220,10 @@ TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { // but won't complete synchronously. FrameMsg_Navigate_Params params; params.page_id = -1; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.url = GURL("data:text/html,test data"); - params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.common_params.url = GURL("data:text/html,test data"); + params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params); // An error occurred. @@ -2235,9 +2251,10 @@ TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { // but won't complete synchronously. FrameMsg_Navigate_Params params; params.page_id = -1; - params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - params.url = GURL("data:text/html,test data"); - params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); + params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; + params.common_params.url = GURL("data:text/html,test data"); + params.commit_params.browser_navigation_start = + base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(params); // An error occurred. @@ -2448,12 +2465,13 @@ TEST_F(RenderViewImplTest, NavigationStartOverride) { // OnNavigate() is called. base::Time before_navigation = base::Time::Now(); FrameMsg_Navigate_Params early_nav_params; - early_nav_params.url = GURL("data:text/html,<div>Page</div>"); - early_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - early_nav_params.transition = ui::PAGE_TRANSITION_TYPED; + early_nav_params.common_params.url = GURL("data:text/html,<div>Page</div>"); + early_nav_params.common_params.navigation_type = + FrameMsg_Navigate_Type::NORMAL; + early_nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; early_nav_params.page_id = -1; - early_nav_params.is_post = true; - early_nav_params.browser_navigation_start = + early_nav_params.request_params.is_post = true; + early_nav_params.commit_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1); frame()->OnNavigate(early_nav_params); @@ -2467,12 +2485,14 @@ TEST_F(RenderViewImplTest, NavigationStartOverride) { // days from now is *not* reported as one that starts in the future; as we // sanitize the override allowing a maximum of ::Now(). FrameMsg_Navigate_Params late_nav_params; - late_nav_params.url = GURL("data:text/html,<div>Another page</div>"); - late_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; - late_nav_params.transition = ui::PAGE_TRANSITION_TYPED; + late_nav_params.common_params.url = + GURL("data:text/html,<div>Another page</div>"); + late_nav_params.common_params.navigation_type = + FrameMsg_Navigate_Type::NORMAL; + late_nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; late_nav_params.page_id = -1; - late_nav_params.is_post = true; - late_nav_params.browser_navigation_start = + late_nav_params.request_params.is_post = true; + late_nav_params.commit_params.browser_navigation_start = base::TimeTicks::Now() + base::TimeDelta::FromDays(42); frame()->OnNavigate(late_nav_params); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index b931da5..179c36b 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -343,12 +343,10 @@ static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = NULL; // static -bool RenderViewImpl::IsReload(const FrameMsg_Navigate_Params& params) { - return - params.navigation_type == FrameMsg_Navigate_Type::RELOAD || - params.navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || - params.navigation_type == - FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; +bool RenderViewImpl::IsReload(FrameMsg_Navigate_Type::Value navigation_type) { + return navigation_type == FrameMsg_Navigate_Type::RELOAD || + navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || + navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; } // static @@ -1408,7 +1406,8 @@ bool RenderViewImpl::IsBackForwardToStaleEntry( // Make sure this isn't a back/forward to an entry we have already cropped // or replaced from our history, before the browser knew about it. If so, // a new navigation has committed in the mean time, and we can ignore this. - bool is_back_forward = !is_reload && params.page_state.IsValid(); + bool is_back_forward = + !is_reload && params.commit_params.page_state.IsValid(); // Note: if the history_list_length_ is 0 for a back/forward, we must be // restoring from a previous session. We'll update our state in OnNavigate. @@ -2284,8 +2283,8 @@ void RenderViewImpl::PopulateDocumentStateFromPending( InternalDocumentStateData* internal_data = InternalDocumentStateData::FromDocumentState(document_state); - if (!params.url.SchemeIs(url::kJavaScriptScheme) && - params.navigation_type == FrameMsg_Navigate_Type::RESTORE) { + if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme) && + params.common_params.navigation_type == FrameMsg_Navigate_Type::RESTORE) { // We're doing a load of a page that was restored from the last session. By // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which // can result in stale data for pages that are set to expire. We explicitly @@ -2300,17 +2299,18 @@ void RenderViewImpl::PopulateDocumentStateFromPending( WebURLRequest::UseProtocolCachePolicy); } - if (IsReload(params)) + if (IsReload(params.common_params.navigation_type)) document_state->set_load_type(DocumentState::RELOAD); - else if (params.page_state.IsValid()) + else if (params.commit_params.page_state.IsValid()) document_state->set_load_type(DocumentState::HISTORY_LOAD); else document_state->set_load_type(DocumentState::NORMAL_LOAD); - internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); + internal_data->set_is_overriding_user_agent( + params.commit_params.is_overriding_user_agent); internal_data->set_must_reset_scroll_and_scale_state( - params.navigation_type == - FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); + params.common_params.navigation_type == + FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); document_state->set_can_load_local_resources(params.can_load_local_resources); } @@ -2321,20 +2321,20 @@ NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { // A navigation resulting from loading a javascript URL should not be treated // as a browser initiated event. Instead, we want it to look as if the page // initiated any load resulting from JS execution. - if (!params.url.SchemeIs(url::kJavaScriptScheme)) { + if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme)) { navigation_state = NavigationState::CreateBrowserInitiated( params.page_id, params.pending_history_list_offset, params.should_clear_history_list, - params.transition); + params.common_params.transition); navigation_state->set_should_replace_current_entry( params.should_replace_current_entry); navigation_state->set_transferred_request_child_id( params.transferred_request_child_id); navigation_state->set_transferred_request_request_id( params.transferred_request_request_id); - navigation_state->set_allow_download(params.allow_download); - navigation_state->set_extra_headers(params.extra_headers); + navigation_state->set_allow_download(params.common_params.allow_download); + navigation_state->set_extra_headers(params.request_params.extra_headers); } else { navigation_state = NavigationState::CreateContentInitiated(); } diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index a22c3ff..1b4d323 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -26,8 +26,10 @@ #include "content/common/content_export.h" #include "content/common/drag_event_source_info.h" #include "content/common/edit_command.h" +#include "content/common/frame_message_enums.h" #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" #include "content/common/navigation_gesture.h" +#include "content/common/navigation_params.h" #include "content/common/view_message_enums.h" #include "content/public/common/page_zoom.h" #include "content/public/common/referrer.h" @@ -624,7 +626,7 @@ class CONTENT_EXPORT RenderViewImpl void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame); void didChangeScrollOffset(blink::WebLocalFrame* frame); - static bool IsReload(const FrameMsg_Navigate_Params& params); + static bool IsReload(FrameMsg_Navigate_Type::Value navigation_type); static Referrer GetReferrerFromRequest( blink::WebFrame* frame, diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc index 12c3d39..8cfc8f5 100644 --- a/content/test/test_render_frame_host.cc +++ b/content/test/test_render_frame_host.cc @@ -176,16 +176,15 @@ void TestRenderFrameHost::SendNavigateWithParameters( } void TestRenderFrameHost::SendBeginNavigationWithURL(const GURL& url) { - FrameHostMsg_BeginNavigation_Params params; - params.method = "GET"; - params.url = url; - params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); - params.load_flags = net::LOAD_NORMAL; - params.has_user_gesture = false; - params.transition_type = ui::PAGE_TRANSITION_LINK; - params.should_replace_current_entry = false; - params.allow_download = true; - OnBeginNavigation(params); + FrameHostMsg_BeginNavigation_Params begin_params; + CommonNavigationParams common_params; + begin_params.method = "GET"; + begin_params.load_flags = net::LOAD_NORMAL; + begin_params.has_user_gesture = false; + common_params.url = url; + common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); + common_params.transition = ui::PAGE_TRANSITION_LINK; + OnBeginNavigation(begin_params, common_params); } void TestRenderFrameHost::DidDisownOpener() { |