From ff64b3e804f47534554f654f523c7abfbe45b88a Mon Sep 17 00:00:00 2001 From: "japhet@chromium.org" Date: Sat, 31 May 2014 04:07:33 +0000 Subject: Immediately SetTitle on a new NavigationEntry created via history.pushState We already have the title available (because we're not throwing away the old document in the renderer process), and if we don't immediately set the title, there is a race condition where the title may be updated in the ui before the renderer process sends a FrameHostMsg_UpdateTitle IPC. In this case, the title will flicker to the page url and immeidately back to the proper title. BUG=375455 TEST=NavigationControllerTest.PushStateUpdatesTitle Review URL: https://codereview.chromium.org/308143004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274006 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/frame_host/navigation_controller_impl.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'content/browser/frame_host/navigation_controller_impl.cc') diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc index 5469151..463d186b 100644 --- a/content/browser/frame_host/navigation_controller_impl.cc +++ b/content/browser/frame_host/navigation_controller_impl.cc @@ -1057,6 +1057,12 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage( new_entry->SetOriginalRequestURL(params.original_request_url); new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); + // history.pushState() is classified as a navigation to a new page, but + // sets was_within_same_page to true. In this case, we already have the + // title available, so set it immediately. + if (params.was_within_same_page) + new_entry->SetTitle(GetLastCommittedEntry()->GetTitle()); + DCHECK(!params.history_list_was_cleared || !replace_entry); // The browser requested to clear the session history when it initiated the // navigation. Now we know that the renderer has updated its state accordingly -- cgit v1.1