summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 23:03:00 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 23:03:00 +0000
commit3cc72b1caa55ca87811d8fab1ac9d55f05c2d496 (patch)
tree4379348afc5100d4188fb03650aa2f8013f5f254 /chrome/browser
parent330a9d04c938c3e79c30faade3713a1378b9bdeb (diff)
downloadchromium_src-3cc72b1caa55ca87811d8fab1ac9d55f05c2d496.zip
chromium_src-3cc72b1caa55ca87811d8fab1ac9d55f05c2d496.tar.gz
chromium_src-3cc72b1caa55ca87811d8fab1ac9d55f05c2d496.tar.bz2
Send session history offset and length parameters in the Navigate message to
keep the renderer's notion of those values properly synchronized with the NavigationController. R=brettw BUG=18062 TEST=see session_history_uitest.cc Review URL: http://codereview.chromium.org/1090002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc14
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h5
-rw-r--r--chrome/browser/session_history_uitest.cc37
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc4
-rw-r--r--chrome/browser/tab_contents/navigation_controller.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc25
-rw-r--r--chrome/browser/tab_contents/tab_contents.h2
8 files changed, 53 insertions, 38 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 1c76a24..f4e297c 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -975,8 +975,6 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) {
FilterURL(policy, renderer_id, &validated_params.password_form.action);
delegate_->DidNavigate(this, validated_params);
-
- UpdateBackForwardListCount();
}
void RenderViewHost::OnMsgUpdateState(int32 page_id,
@@ -1506,18 +1504,6 @@ void RenderViewHost::OnCrashedPlugin(const FilePath& plugin_path) {
integration_delegate->OnCrashedPlugin(plugin_path);
}
-void RenderViewHost::UpdateBackForwardListCount() {
- int back_list_count = 0, forward_list_count = 0;
- RenderViewHostDelegate::BrowserIntegration* integration_delegate =
- delegate_->GetBrowserIntegrationDelegate();
- if (integration_delegate) {
- integration_delegate->GetHistoryListCount(&back_list_count,
- &forward_list_count);
- Send(new ViewMsg_UpdateBackForwardListCount(
- routing_id(), back_list_count, forward_list_count));
- }
-}
-
void RenderViewHost::GetAllSavableResourceLinksForCurrentPage(
const GURL& page_url) {
Send(new ViewMsg_GetAllSavableResourceLinksForCurrentPage(routing_id(),
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index cc52d47..b413239 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -624,8 +624,6 @@ class RenderViewHost : public RenderWidgetHost {
private:
friend class TestRenderViewHost;
- void UpdateBackForwardListCount();
-
// The SiteInstance associated with this RenderViewHost. All pages drawn
// in this RenderViewHost are part of this SiteInstance. Should not change
// over time.
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index b1a1148..d9fbb01 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -204,11 +204,6 @@ class RenderViewHostDelegate {
// not valid.
virtual void GoToEntryAtOffset(int offset) = 0;
- // The page requests the size of the back and forward lists
- // within the NavigationController.
- virtual void GetHistoryListCount(int* back_list_count,
- int* forward_list_count) = 0;
-
// Notification when default plugin updates status of the missing plugin.
virtual void OnMissingPluginStatus(int status) = 0;
diff --git a/chrome/browser/session_history_uitest.cc b/chrome/browser/session_history_uitest.cc
index 8209338..e8ac1c5 100644
--- a/chrome/browser/session_history_uitest.cc
+++ b/chrome/browser/session_history_uitest.cc
@@ -23,6 +23,7 @@ const wchar_t kDocRoot[] = L"chrome/test/data";
class SessionHistoryTest : public UITest {
protected:
SessionHistoryTest() : UITest() {
+ dom_automation_enabled_ = true;
}
virtual void SetUp() {
@@ -515,4 +516,40 @@ TEST_F(SessionHistoryTest, LocationChangeInSubframe) {
EXPECT_EQ(L"Default Title", GetTabTitle());
}
+TEST_F(SessionHistoryTest, HistoryLength) {
+ scoped_refptr<HTTPTestServer> server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ ASSERT_TRUE(server.get());
+
+ int length;
+ ASSERT_TRUE(tab_->ExecuteAndExtractInt(
+ L"", L"domAutomationController.send(history.length)", &length));
+ EXPECT_EQ(1, length);
+
+ ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title1.html")));
+
+ ASSERT_TRUE(tab_->ExecuteAndExtractInt(
+ L"", L"domAutomationController.send(history.length)", &length));
+ EXPECT_EQ(2, length);
+
+ // Now test that history.length is updated when the navigation is committed.
+ ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage(
+ "files/session_history/record_length.html")));
+ ASSERT_TRUE(tab_->ExecuteAndExtractInt(
+ L"", L"domAutomationController.send(history.length)", &length));
+ EXPECT_EQ(3, length);
+ ASSERT_TRUE(tab_->ExecuteAndExtractInt(
+ L"", L"domAutomationController.send(history_length)", &length));
+ EXPECT_EQ(3, length);
+
+ ASSERT_TRUE(tab_->GoBack());
+ ASSERT_TRUE(tab_->GoBack());
+
+ // Ensure history.length is properly truncated.
+ ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title2.html")));
+ ASSERT_TRUE(tab_->ExecuteAndExtractInt(
+ L"", L"domAutomationController.send(history.length)", &length));
+ EXPECT_EQ(2, length);
+}
+
} // namespace
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index bdcc811..991b289 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/navigation_types.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -114,7 +115,8 @@ const base::TimeDelta kMaxAutoNavigationTimeDelta =
// NavigationController ---------------------------------------------------
// static
-size_t NavigationController::max_entry_count_ = 50;
+size_t NavigationController::max_entry_count_ =
+ chrome::kMaxSessionHistoryEntries;
// static
bool NavigationController::check_for_repost_ = true;
diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h
index c2dae3f..16011d3 100644
--- a/chrome/browser/tab_contents/navigation_controller.h
+++ b/chrome/browser/tab_contents/navigation_controller.h
@@ -395,9 +395,11 @@ class NavigationController {
static void DisablePromptOnRepost();
// Maximum number of entries before we start removing entries from the front.
+#ifdef UNIT_TEST
static void set_max_entry_count(size_t max_entry_count) {
max_entry_count_ = max_entry_count;
}
+#endif
static size_t max_entry_count() { return max_entry_count_; }
// Cancels a repost that brought up a warning.
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 97e49b3..aa2bc97 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -204,15 +204,20 @@ ViewMsg_Navigate_Params::NavigationType GetNavigationType(
return ViewMsg_Navigate_Params::NORMAL;
}
-void MakeNavigateParams(Profile* profile, const NavigationEntry& entry,
+void MakeNavigateParams(const NavigationController& controller,
NavigationController::ReloadType reload_type,
ViewMsg_Navigate_Params* params) {
+ const NavigationEntry& entry = *controller.pending_entry();
params->page_id = entry.page_id();
+ params->pending_history_list_offset = controller.pending_entry_index();
+ params->current_history_list_offset = controller.last_committed_entry_index();
+ params->current_history_list_length = controller.entry_count();
params->url = entry.url();
params->referrer = entry.referrer();
params->transition = entry.transition_type();
params->state = entry.content_state();
- params->navigation_type = GetNavigationType(profile, entry, reload_type);
+ params->navigation_type =
+ GetNavigationType(controller.profile(), entry, reload_type);
params->request_time = base::Time::Now();
}
@@ -739,10 +744,9 @@ bool TabContents::NavigateToPendingEntry(
// Tell DevTools agent that it is attached prior to the navigation.
DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
if (devtools_manager) { // NULL in unit tests.
- devtools_manager->OnNavigatingToPendingEntry(
- render_view_host(),
- dest_render_view_host,
- controller_.pending_entry()->url());
+ devtools_manager->OnNavigatingToPendingEntry(render_view_host(),
+ dest_render_view_host,
+ entry.url());
}
// Used for page load time metrics.
@@ -750,7 +754,7 @@ bool TabContents::NavigateToPendingEntry(
// Navigate in the desired RenderViewHost.
ViewMsg_Navigate_Params navigate_params;
- MakeNavigateParams(profile(), entry, reload_type, &navigate_params);
+ MakeNavigateParams(controller_, reload_type, &navigate_params);
dest_render_view_host->Navigate(navigate_params);
if (entry.page_id() == -1) {
@@ -1807,13 +1811,6 @@ void TabContents::GoToEntryAtOffset(int offset) {
controller_.GoToOffset(offset);
}
-void TabContents::GetHistoryListCount(int* back_list_count,
- int* forward_list_count) {
- int current_index = controller_.last_committed_entry_index();
- *back_list_count = current_index;
- *forward_list_count = controller_.entry_count() - current_index - 1;
-}
-
void TabContents::OnMissingPluginStatus(int status) {
#if defined(OS_WIN)
// TODO(PORT): pull in when plug-ins work
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 15f1a09..b113dd5 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -802,8 +802,6 @@ class TabContents : public PageNavigator,
int active_match_ordinal,
bool final_update);
virtual void GoToEntryAtOffset(int offset);
- virtual void GetHistoryListCount(int* back_list_count,
- int* forward_list_count);
virtual void OnMissingPluginStatus(int status);
virtual void OnCrashedPlugin(const FilePath& plugin_path);
virtual void OnCrashedWorker();