diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index f66cab5489208b..4529ac34befb05 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -638,3 +638,13 @@ void ExternalTabContainer::Navigate(const GURL& url, const GURL& referrer) { tab_contents_->controller().LoadURL(url, referrer, PageTransition::START_PAGE); } + +bool ExternalTabContainer::OnGoToEntryOffset(int offset) { + if (load_requests_via_automation_) { + automation_->Send(new AutomationMsg_RequestGoToHistoryEntryOffset( + 0, tab_handle_, offset)); + return false; + } + + return true; +} diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 29cd62dff8ddaa..1438f5dd8d0dd0 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -123,6 +123,7 @@ class ExternalTabContainer : public TabContentsDelegate, virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); virtual bool TakeFocus(bool reverse); + virtual bool OnGoToEntryOffset(int offset); virtual void ShowPageInfo(Profile* profile, const GURL& url, diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index ba0c33998c955f..c4b5a7adbc41bb 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1695,7 +1695,8 @@ void TabContents::OnFindReply(int request_id, } void TabContents::GoToEntryAtOffset(int offset) { - controller_.GoToOffset(offset); + if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) + controller_.GoToOffset(offset); } void TabContents::GetHistoryListCount(int* back_list_count, diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index 7ed952f2b97f70..7b5f7a744891e3 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -229,6 +229,12 @@ class TabContentsDelegate { // Shows the repost form confirmation dialog box. virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) {} + // Allows delegate to override navigation to the history entries. + // Returns true to allow TabContents to continue with the default processing. + virtual bool OnGoToEntryOffset(int offset) { + return true; + } + protected: ~TabContentsDelegate() {} diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 5d009b5d7f2284..c270ce4ac53287 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1119,4 +1119,10 @@ IPC_BEGIN_MESSAGES(Automation) std::string /* event_name */, int /* duration ms */) + // Sent by automation provider - go to history entry via automation. + IPC_MESSAGE_ROUTED2(AutomationMsg_RequestGoToHistoryEntryOffset, + int, // tab handle + int) // numbers of entries (negative or positive) + + IPC_END_MESSAGES(Automation) diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index 2e3c43f11dd7dd..1f7515d9d6cdef 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -790,3 +790,16 @@ HRESULT ChromeActiveDocument::SetPageFontSize(const GUID* cmd_group_guid, return S_OK; } +void ChromeActiveDocument::OnGoToHistoryEntryOffset(int tab_handle, + int offset) { + DLOG(INFO) << "GoToHistoryEntryOffset " << offset; + ScopedComPtr browser_service; + DoQueryService(SID_SShellBrowser, m_spClientSite, browser_service.Receive()); + if (browser_service) { + ScopedComPtr travel_log; + browser_service->GetTravelLog(travel_log.Receive()); + if (travel_log) { + travel_log->Travel(browser_service, offset); + } + } +} diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h index ee2c850cb64657..072bc00e503f44 100644 --- a/chrome_frame/chrome_active_document.h +++ b/chrome_frame/chrome_active_document.h @@ -218,6 +218,7 @@ END_EXEC_COMMAND_MAP() int open_disposition); virtual void OnLoad(int tab_handle, const GURL& url); + virtual void OnGoToHistoryEntryOffset(int tab_handle, int offset); // A helper method that updates our internal navigation state // as well as IE's navigation state (viz Title and current URL). diff --git a/chrome_frame/chrome_frame_delegate.cc b/chrome_frame/chrome_frame_delegate.cc index 9a1069b95465b0..396d7a989ce640 100644 --- a/chrome_frame/chrome_frame_delegate.cc +++ b/chrome_frame/chrome_frame_delegate.cc @@ -24,6 +24,7 @@ bool ChromeFrameDelegateImpl::IsTabMessage(const IPC::Message& message, IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestEnd, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_SetCookieAsync, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_AttachExternalTab, ) + IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestGoToHistoryEntryOffset, ) IPC_MESSAGE_UNHANDLED(is_tab_message = false); IPC_END_MESSAGE_MAP() @@ -63,5 +64,7 @@ void ChromeFrameDelegateImpl::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(AutomationMsg_RequestEnd, OnRequestEnd) IPC_MESSAGE_HANDLER(AutomationMsg_SetCookieAsync, OnSetCookieAsync) IPC_MESSAGE_HANDLER(AutomationMsg_AttachExternalTab, OnAttachExternalTab) + IPC_MESSAGE_HANDLER(AutomationMsg_RequestGoToHistoryEntryOffset, + OnGoToHistoryEntryOffset) IPC_END_MESSAGE_MAP() } diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h index ebde6262d1b638..2c8acd94513179 100644 --- a/chrome_frame/chrome_frame_delegate.h +++ b/chrome_frame/chrome_frame_delegate.h @@ -91,6 +91,7 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate { const std::string& cookie) {} virtual void OnAttachExternalTab(int tab_handle, intptr_t cookie, int disposition) {} + virtual void OnGoToHistoryEntryOffset(int tab_handle, int offset) {} }; #endif // CHROME_FRAME_CHROME_FRAME_DELEGATE_H_