From 22b83aa4d58d07f92722566a5520a6df4d9d1c0b Mon Sep 17 00:00:00 2001 From: "tonyg@chromium.org" Date: Thu, 19 Aug 2010 16:26:19 +0000 Subject: Undo user gesture detection added to NavigationController by r18373, since WebKit now has this logic as of http://trac.webkit.org/changeset/65340. I couldn't remove ViewHostMsg_DocumentLoadedInFrame/ NavigationController::DocumentLoadedInFrame since it accumulated other usages since then. Contributed by mihaip@chromium.org BUG=40395 TEST=manual testing with hp.com and keyboard shortcut search experiment, history_uitest Review URL: http://codereview.chromium.org/3168013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56693 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/tab_contents/navigation_controller.cc | 35 ++-------------------- .../browser/tab_contents/navigation_controller.h | 6 ---- chrome/browser/tab_contents/tab_contents.cc | 1 - 3 files changed, 3 insertions(+), 39 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index 1d63c3b..fe49825 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -103,12 +103,6 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) { new_url.ReplaceComponents(replacements); } -// Navigation within this limit since the last document load is considered to -// be automatic (i.e., machine-initiated) rather than user-initiated unless -// a user gesture has been observed. -const base::TimeDelta kMaxAutoNavigationTimeDelta = - base::TimeDelta::FromSeconds(5); - } // namespace // NavigationController --------------------------------------------------- @@ -131,7 +125,6 @@ NavigationController::NavigationController(TabContents* contents, max_restored_page_id_(-1), ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), needs_reload_(false), - user_gesture_observed_(false), session_storage_namespace_id_(profile->GetWebKitContext()-> dom_storage_context()->AllocateSessionStorageNamespaceId()), pending_reload_(NO_RELOAD) { @@ -500,14 +493,11 @@ void NavigationController::DocumentLoadedInFrame() { last_document_loaded_ = base::TimeTicks::Now(); } -void NavigationController::OnUserGesture() { - user_gesture_observed_ = true; -} - bool NavigationController::RendererDidNavigate( const ViewHostMsg_FrameNavigate_Params& params, int extra_invalidate_flags, LoadCommittedDetails* details) { + // Save the previous state before we clobber it. if (GetLastCommittedEntry()) { details->previous_url = GetLastCommittedEntry()->url(); @@ -535,6 +525,7 @@ bool NavigationController::RendererDidNavigate( // Do navigation-type specific actions. These will make and commit an entry. details->type = ClassifyNavigation(params); + switch (details->type) { case NavigationType::NEW_PAGE: RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); @@ -694,11 +685,6 @@ bool NavigationController::IsRedirect( return params.redirects.size() > 1; } -bool NavigationController::IsLikelyAutoNavigation(base::TimeTicks now) { - return !user_gesture_observed_ && - (now - last_document_loaded_) < kMaxAutoNavigationTimeDelta; -} - void NavigationController::CreateNavigationEntriesFromTabNavigations( const std::vector& navigations, std::vector >* entries) { @@ -739,14 +725,6 @@ void NavigationController::RendererDidNavigateToNewPage( new_entry->set_site_instance(tab_contents_->GetSiteInstance()); new_entry->set_has_post_data(params.is_post); - // If the current entry is a redirection source and the redirection has - // occurred within kMaxAutoNavigationTimeDelta since the last document load, - // this is likely to be machine-initiated redirect and the entry needs to be - // replaced with the new entry to avoid unwanted redirections in navigating - // backward/forward. - // Otherwise, just insert the new entry. - *did_replace_entry = IsRedirect(params) && - IsLikelyAutoNavigation(base::TimeTicks::Now()); InsertOrReplaceEntry(new_entry, *did_replace_entry); } @@ -1019,13 +997,6 @@ void NavigationController::InsertOrReplaceEntry(NavigationEntry* entry, // This is a new page ID, so we need everybody to know about it. tab_contents_->UpdateMaxPageID(entry->page_id()); - - // When an entry is inserted, clear the user gesture observed flag. - // This is not done when replacing an entry (for example navigating within a - // page) because once a user has interacted with a page, we never want to - // mistake a subsequent navigation for an auto navigation. - if (!replace) - user_gesture_observed_ = false; } void NavigationController::SetWindowID(const SessionID& id) { @@ -1040,7 +1011,7 @@ void NavigationController::NavigateToPendingEntry(ReloadType reload_type) { // For session history navigations only the pending_entry_index_ is set. if (!pending_entry_) { - DCHECK(pending_entry_index_ != -1); + DCHECK_NE(pending_entry_index_, -1); pending_entry_ = entries_[pending_entry_index_].get(); } diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h index 43ab1f7..e92f4d6 100644 --- a/chrome/browser/tab_contents/navigation_controller.h +++ b/chrome/browser/tab_contents/navigation_controller.h @@ -313,9 +313,6 @@ class NavigationController { // Called when a document has been loaded in a frame. void DocumentLoadedInFrame(); - // Called when the user presses the mouse, enter key or space bar. - void OnUserGesture(); - // For use by TabContents ---------------------------------------------------- // Handles updating the navigation state after the renderer has navigated. @@ -562,9 +559,6 @@ class NavigationController { // The time ticks at which the last document was loaded. base::TimeTicks last_document_loaded_; - // Whether a user gesture has been observed since the last navigation. - bool user_gesture_observed_; - // The session storage id that any (indirectly) owned RenderView should use. int64 session_storage_namespace_id_; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index a0ef815..7e54cf4 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1907,7 +1907,6 @@ void TabContents::OnUserGesture() { if (limiter) limiter->OnUserGesture(this); ExternalProtocolHandler::PermitLaunchUrl(); - controller_.OnUserGesture(); } void TabContents::OnFindReply(int request_id, -- cgit v1.1