summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 21:00:20 +0000
committermihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 21:00:20 +0000
commit4bf3522cf76f8b107ea0f1fe5c9de17fa54fe3c6 (patch)
treeb698d91a1518d69993c741afc655bc1f5beba0c6 /chrome
parent2847278884354276afb89ad4bd726156ad3fa42a (diff)
downloadchromium_src-4bf3522cf76f8b107ea0f1fe5c9de17fa54fe3c6.zip
chromium_src-4bf3522cf76f8b107ea0f1fe5c9de17fa54fe3c6.tar.gz
chromium_src-4bf3522cf76f8b107ea0f1fe5c9de17fa54fe3c6.tar.bz2
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. (second attempt of r56693, this time with updated unit tests) BUG=40395 TEST=manual testing with hp.com and keyboard shortcut search experiment, history_uitest Review URL: http://codereview.chromium.org/3124035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc35
-rw-r--r--chrome/browser/tab_contents/navigation_controller.h6
-rw-r--r--chrome/browser/tab_contents/navigation_controller_unittest.cc1
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc1
4 files changed, 3 insertions, 40 deletions
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<TabNavigation>& navigations,
std::vector<linked_ptr<NavigationEntry> >* 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 88c6538..623b4a0 100644
--- a/chrome/browser/tab_contents/navigation_controller.h
+++ b/chrome/browser/tab_contents/navigation_controller.h
@@ -312,9 +312,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.
@@ -561,9 +558,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/navigation_controller_unittest.cc b/chrome/browser/tab_contents/navigation_controller_unittest.cc
index b24d967..9d6543a 100644
--- a/chrome/browser/tab_contents/navigation_controller_unittest.cc
+++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc
@@ -1192,7 +1192,6 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// This should NOT generate a new entry.
NavigationController::LoadCommittedDetails details;
- controller().OnUserGesture();
EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details));
EXPECT_TRUE(notifications.Check2AndReset(
NotificationType::NAV_LIST_PRUNED,
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 6c54fb0..f8f1b88 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1908,7 +1908,6 @@ void TabContents::OnUserGesture() {
if (limiter)
limiter->OnUserGesture(this);
ExternalProtocolHandler::PermitLaunchUrl();
- controller_.OnUserGesture();
}
void TabContents::OnFindReply(int request_id,