diff options
author | stoyan@google.com <stoyan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 14:56:38 +0000 |
---|---|---|
committer | stoyan@google.com <stoyan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 14:56:38 +0000 |
commit | f9cc4c4597f2455409008a76d88ed11dbe05796a (patch) | |
tree | 3d1df599805bde20ebfc063c9da87637bb240e08 | |
parent | 2884a003274a81a3d67a0af97070c427e5ff8956 (diff) | |
download | chromium_src-f9cc4c4597f2455409008a76d88ed11dbe05796a.zip chromium_src-f9cc4c4597f2455409008a76d88ed11dbe05796a.tar.gz chromium_src-f9cc4c4597f2455409008a76d88ed11dbe05796a.tar.bz2 |
This CL is for the needs of ChromeFrame.
TabContentsDelegate implementation may override navigations caused by JsvaScript history object.
Yet not perfect since webkit view of navigation stack differs from the view of external-non-Chrome-host-browser.
We have to provide the full stack from host-browser (+visited links alongside) in the same way as Chrome-browser provides it to renderer.
BUG=24004
Review URL: http://codereview.chromium.org/261046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28818 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/external_tab_container.cc | 10 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.h | 1 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.h | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 6 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 13 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.h | 1 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_delegate.cc | 3 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_delegate.h | 1 |
9 files changed, 43 insertions, 1 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index f66cab5..4529ac3 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 29cd62d..1438f5d 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 ba0c339..c4b5a7a 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 7ed952f..7b5f7a7 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 5d009b5..c270ce4a 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 2e3c43f..1f7515d 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<IBrowserService> browser_service; + DoQueryService(SID_SShellBrowser, m_spClientSite, browser_service.Receive()); + if (browser_service) { + ScopedComPtr<ITravelLog> 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 ee2c850..072bc00 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 9a1069b..396d7a9 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 ebde626..2c8acd9 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_ |