summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 23:14:26 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 23:14:26 +0000
commit4150ef026218967e259f7b70cce5739afb12f475 (patch)
treeb416b3900afe8155fdce8817febde568527ac368 /chrome
parent802629d5d0b0aaafa00c94c5b39f5b7290723a32 (diff)
downloadchromium_src-4150ef026218967e259f7b70cce5739afb12f475.zip
chromium_src-4150ef026218967e259f7b70cce5739afb12f475.tar.gz
chromium_src-4150ef026218967e259f7b70cce5739afb12f475.tar.bz2
Support navigating to absolute index through automation.
Also, send more information in AutomationMsg_DidNavigate BUG=none TEST=none Review URL: http://codereview.chromium.org/165333 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_provider.cc14
-rw-r--r--chrome/browser/automation/automation_provider.h2
-rw-r--r--chrome/browser/external_tab_container.cc34
-rw-r--r--chrome/browser/external_tab_container.h8
-rw-r--r--chrome/test/automation/automation_messages.h41
-rw-r--r--chrome/test/automation/automation_messages_internal.h26
-rw-r--r--chrome/test/automation/automation_proxy_uitest.h3
-rw-r--r--chrome/test/automation/tab_proxy.cc11
-rw-r--r--chrome/test/automation/tab_proxy.h1
9 files changed, 119 insertions, 21 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 855b678..14504be 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1001,6 +1001,8 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
#endif
IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab,
NavigateInExternalTab)
+ IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex,
+ NavigateExternalTabAtIndex)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ShowInterstitialPage,
ShowInterstitialPage)
IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage,
@@ -2405,6 +2407,18 @@ void AutomationProvider::NavigateInExternalTab(
}
}
+void AutomationProvider::NavigateExternalTabAtIndex(
+ int handle, int navigation_index,
+ AutomationMsg_NavigationResponseValues* status) {
+ *status = AUTOMATION_MSG_NAVIGATION_ERROR;
+
+ if (tab_tracker_->ContainsHandle(handle)) {
+ NavigationController* tab = tab_tracker_->GetResource(handle);
+ tab->GoToIndex(navigation_index);
+ *status = AUTOMATION_MSG_NAVIGATION_SUCCESS;
+ }
+}
+
#if defined(OS_WIN)
void AutomationProvider::ProcessUnhandledAccelerator(
const IPC::Message& message, int handle, const MSG& msg) {
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index da47f06..6344661 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -302,6 +302,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
void NavigateInExternalTab(
int handle, const GURL& url,
AutomationMsg_NavigationResponseValues* status);
+ void NavigateExternalTabAtIndex(
+ int handle, int index, AutomationMsg_NavigationResponseValues* status);
// TODO(port): remove windowisms.
#if defined(OS_WIN)
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 69df25e..5cf341b 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -70,10 +70,6 @@ bool ExternalTabContainer::Init(Profile* profile,
// is the same as the lifetime of the window
SetProp(GetNativeView(), kWindowObjectKey, this);
- // If we are sending top level requests through the automation then
- // we should be using automation to load url requests as well.
- DCHECK(handle_top_level_requests ? load_requests_via_automation : 1);
-
if (load_requests_via_automation) {
// Customize our profile.
// TODO(joshia): If we are loading requests via automation
@@ -208,8 +204,11 @@ void ExternalTabContainer::OpenURLFromTab(TabContents* source,
void ExternalTabContainer::NavigationStateChanged(const TabContents* source,
unsigned changed_flags) {
if (automation_) {
+ IPC::NavigationInfo nav_info;
+ InitNavigationInfo(&nav_info, NavigationType::NAV_IGNORE, 0);
automation_->Send(new AutomationMsg_NavigationStateChanged(0, tab_handle_,
- changed_flags));
+ changed_flags,
+ nav_info));
}
}
@@ -405,14 +404,15 @@ void ExternalTabContainer::Observe(NotificationType type,
ignore_next_load_notification_ = true;
} else {
+ IPC::NavigationInfo navigation_info;
// When the previous entry index is invalid, it will be -1, which
// will still make the computation come out right (navigating to the
// 0th entry will be +1).
- automation_->Send(new AutomationMsg_DidNavigate(
- 0, tab_handle_, commit->type,
+ InitNavigationInfo(&navigation_info, commit->type,
commit->previous_entry_index -
- tab_contents_->controller().last_committed_entry_index(),
- commit->entry->url()));
+ tab_contents_->controller().last_committed_entry_index());
+ automation_->Send(new AutomationMsg_DidNavigate(0, tab_handle_,
+ navigation_info));
}
break;
}
@@ -516,3 +516,19 @@ bool ExternalTabContainer::ProcessUnhandledKeyStroke(HWND window,
return false;
}
+
+void ExternalTabContainer::InitNavigationInfo(IPC::NavigationInfo* nav_info,
+ NavigationType::Type nav_type,
+ int relative_offset) {
+ NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
+ DCHECK(nav_info);
+ DCHECK(entry);
+
+ nav_info->navigation_type = nav_type;
+ nav_info->relative_offset = relative_offset;
+ nav_info->navigation_index =
+ tab_contents_->controller().GetCurrentEntryIndex();
+ nav_info->title = UTF16ToWideHack(entry->title());
+ nav_info->url = entry->url();
+}
+
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index f51761a..53579af 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -11,6 +11,7 @@
#include "chrome/browser/automation/automation_profile_impl.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
+#include "chrome/common/navigation_types.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "views/widget/widget_win.h"
@@ -20,6 +21,10 @@ class Profile;
class TabContentsContainer;
class RenderViewContextMenuExternalWin;
+namespace IPC {
+struct NavigationInfo;
+}
+
// This class serves as the container window for an external tab.
// An external tab is a Chrome tab that is meant to displayed in an
// external process. This class provides the FocusManger needed by the
@@ -126,6 +131,9 @@ class ExternalTabContainer : public TabContentsDelegate,
protected:
// Overridden from views::WidgetWin:
virtual void OnDestroy();
+ void InitNavigationInfo(IPC::NavigationInfo* nav_info,
+ NavigationType::Type nav_type,
+ int relative_offset);
private:
// Unhook the keystroke listener and notify about the closing TabContents.
diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h
index 5874c9a..bc578d7 100644
--- a/chrome/test/automation/automation_messages.h
+++ b/chrome/test/automation/automation_messages.h
@@ -359,6 +359,47 @@ struct ParamTraits<ExternalTabSettings> {
}
};
+struct NavigationInfo {
+ int navigation_type;
+ int relative_offset;
+ int navigation_index;
+ std::wstring title;
+ GURL url;
+};
+
+// Traits for NavigationInfo structure to pack/unpack.
+template <>
+struct ParamTraits<NavigationInfo> {
+ typedef NavigationInfo param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.navigation_type);
+ WriteParam(m, p.relative_offset);
+ WriteParam(m, p.navigation_index);
+ WriteParam(m, p.title);
+ WriteParam(m, p.url);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return ReadParam(m, iter, &p->navigation_type) &&
+ ReadParam(m, iter, &p->relative_offset) &&
+ ReadParam(m, iter, &p->navigation_index) &&
+ ReadParam(m, iter, &p->title) &&
+ ReadParam(m, iter, &p->url);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.navigation_type, l);
+ l->append(L", ");
+ LogParam(p.relative_offset, l);
+ l->append(L", ");
+ LogParam(p.navigation_index, l);
+ l->append(L", ");
+ LogParam(p.title, l);
+ l->append(L", ");
+ LogParam(p.url, l);
+ l->append(L")");
+ }
+};
+
} // namespace IPC
#define MESSAGES_INTERNAL_FILE \
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 5309298..93ad554 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -438,9 +438,10 @@ IPC_BEGIN_MESSAGES(Automation)
// (see TabContents::InvalidateTypes)
// Response:
// None expected
- IPC_MESSAGE_ROUTED2(AutomationMsg_NavigationStateChanged,
- int, // tab handle
- int) // TabContents::InvalidateTypes
+ IPC_MESSAGE_ROUTED3(AutomationMsg_NavigationStateChanged,
+ int, // tab handle
+ int, // TabContents::InvalidateTypes
+ IPC::NavigationInfo) // title, url etc.
// This message is an outgoing message from Chrome to an external host.
// It is a notification that the target URL has changed (the target URL
@@ -561,15 +562,11 @@ IPC_BEGIN_MESSAGES(Automation)
// This message is an outgoing message from Chrome to an external host.
// It is a notification that a navigation happened
// Request:
- // -int: Tab handle
- // -int : Indicates the type of navigation (see the NavigationType enum)
- // -int: If this was not a new navigation, then this value indicates the
- // relative offset of the navigation. A positive offset means a
- // forward navigation, a negative value means a backward navigation
- // and 0 means this was a redirect
+ // -int: Tab handle
+ //
// Response:
// None expected
- IPC_MESSAGE_ROUTED4(AutomationMsg_DidNavigate, int, int, int, GURL)
+ IPC_MESSAGE_ROUTED2(AutomationMsg_DidNavigate, int, IPC::NavigationInfo)
// This message requests the different security states of the page displayed
// in the specified tab.
@@ -1019,4 +1016,13 @@ IPC_BEGIN_MESSAGES(Automation)
AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, int, GURL, int,
AutomationMsg_NavigationResponseValues)
+ // This message notifies the AutomationProvider to navigate to a specified
+ // navigation entry index in the external tab with given handle. The first
+ // parameter is the handle to the tab resource. The second parameter is the
+ // index of navigation entry.
+ // The return value contains a status code which is nonnegative on success.
+ // see AutomationMsg_NavigationResponseValues for the navigation response.
+ IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigateExternalTabAtIndex, int, int,
+ AutomationMsg_NavigationResponseValues)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/automation_proxy_uitest.h b/chrome/test/automation/automation_proxy_uitest.h
index e5e593a..692fbc9 100644
--- a/chrome/test/automation/automation_proxy_uitest.h
+++ b/chrome/test/automation/automation_proxy_uitest.h
@@ -71,8 +71,7 @@ class AutomationProxyForExternalTab : public AutomationProxy {
protected:
virtual void OnMessageReceived(const IPC::Message& msg);
- void OnDidNavigate(int tab_handle, int navigation_type, int relative_offset,
- const GURL& url) {
+ void OnDidNavigate(int tab_handle, const IPC::NavigationInfo& nav_info) {
navigate_complete_ = true;
}
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 3d21d8f..f59f821 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -117,6 +117,17 @@ AutomationMsg_NavigationResponseValues TabProxy::NavigateInExternalTab(
return rv;
}
+AutomationMsg_NavigationResponseValues TabProxy::NavigateExternalTabAtIndex(
+ int index) {
+ if (!is_valid())
+ return AUTOMATION_MSG_NAVIGATION_ERROR;
+
+ AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR;
+ sender_->Send(new AutomationMsg_NavigateExternalTabAtIndex(0, handle_, index,
+ &rv));
+ return rv;
+}
+
bool TabProxy::SetAuth(const std::wstring& username,
const std::wstring& password) {
if (!is_valid())
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index 2c19bea..9b7232f 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -100,6 +100,7 @@ class TabProxy : public AutomationResourceProxy {
// can be passed to Chrome on the command line. This is a synchronous call and
// hence blocks until the navigation completes.
AutomationMsg_NavigationResponseValues NavigateInExternalTab(const GURL& url);
+ AutomationMsg_NavigationResponseValues NavigateExternalTabAtIndex(int index);
// Navigates to a url. This is an asynchronous version of NavigateToURL.
// The function returns immediately after sending the LoadURL notification