Skip to content

Commit

Permalink
This CL is for the needs of ChromeFrame.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stoyan@google.com committed Oct 13, 2009
1 parent 2884a00 commit f9cc4c4
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 1 deletion.
10 changes: 10 additions & 0 deletions chrome/browser/external_tab_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions chrome/browser/external_tab_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/tab_contents/tab_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/tab_contents/tab_contents_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
6 changes: 6 additions & 0 deletions chrome/test/automation/automation_messages_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 13 additions & 0 deletions chrome_frame/chrome_active_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
1 change: 1 addition & 0 deletions chrome_frame/chrome_active_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 3 additions & 0 deletions chrome_frame/chrome_frame_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
}
1 change: 1 addition & 0 deletions chrome_frame/chrome_frame_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_

0 comments on commit f9cc4c4

Please sign in to comment.