summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 23:18:19 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 23:18:19 +0000
commitf7a684345d7bfa3ebcabdadecef3c720c7ac6812 (patch)
tree6eefab3ee058ca672f82f8996061fee8148d768f /chrome
parenta17a034a71a63dbc8eadaf6d27c647f46b584bd2 (diff)
downloadchromium_src-f7a684345d7bfa3ebcabdadecef3c720c7ac6812.zip
chromium_src-f7a684345d7bfa3ebcabdadecef3c720c7ac6812.tar.gz
chromium_src-f7a684345d7bfa3ebcabdadecef3c720c7ac6812.tar.bz2
Added automation messages and corresponding handlers to support operations like
1. SelectAll 2. Cut/Copy/Paste 3. Reload :- Added an asynchronous version of this IPC 4. Stop. Review URL: http://codereview.chromium.org/159609 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_provider.cc141
-rw-r--r--chrome/browser/automation/automation_provider.h15
-rw-r--r--chrome/test/automation/automation_messages_internal.h17
-rw-r--r--chrome/test/automation/tab_proxy.cc24
-rw-r--r--chrome/test/automation/tab_proxy.h13
5 files changed, 177 insertions, 33 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 4bb2d65..ecfcc96 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1067,6 +1067,12 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
SetEnableExtensionAutomation)
IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility)
IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount)
+ IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll)
+ IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut)
+ IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy)
+ IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste)
+ IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync)
+ IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync)
IPC_END_MESSAGE_MAP()
}
@@ -2658,43 +2664,29 @@ void AutomationProvider::OnMessageFromExternalHost(int handle,
const std::string& message,
const std::string& origin,
const std::string& target) {
- if (tab_tracker_->ContainsHandle(handle)) {
- NavigationController* tab = tab_tracker_->GetResource(handle);
- if (!tab) {
- NOTREACHED();
- return;
- }
-
- TabContents* tab_contents = tab->tab_contents();
- if (!tab_contents) {
- NOTREACHED();
- return;
- }
-
- RenderViewHost* view_host = tab_contents->render_view_host();
- if (!view_host) {
- return;
- }
-
- if (AutomationExtensionFunction::InterceptMessageFromExternalHost(
- view_host, message, origin, target)) {
- // Message was diverted.
- return;
- }
+ RenderViewHost* view_host = GetViewForTab(handle);
+ if (!view_host) {
+ return;
+ }
- if (ExtensionPortContainer::InterceptMessageFromExternalHost(message,
- origin, target, this, view_host, handle)) {
- // Message was diverted.
- return;
- }
+ if (AutomationExtensionFunction::InterceptMessageFromExternalHost(
+ view_host, message, origin, target)) {
+ // Message was diverted.
+ return;
+ }
- if (InterceptBrowserEventMessageFromExternalHost(message, origin, target)) {
- // Message was diverted.
- return;
- }
+ if (ExtensionPortContainer::InterceptMessageFromExternalHost(message,
+ origin, target, this, view_host, handle)) {
+ // Message was diverted.
+ return;
+ }
- view_host->ForwardMessageFromExternalHost(message, origin, target);
+ if (InterceptBrowserEventMessageFromExternalHost(message, origin, target)) {
+ // Message was diverted.
+ return;
}
+
+ view_host->ForwardMessageFromExternalHost(message, origin, target);
}
bool AutomationProvider::InterceptBrowserEventMessageFromExternalHost(
@@ -3039,3 +3031,86 @@ void AutomationProvider::GetBlockedPopupCount(int handle, int* count) {
}
}
}
+
+void AutomationProvider::SelectAll(int tab_handle) {
+ RenderViewHost* view = GetViewForTab(tab_handle);
+ if (!view) {
+ NOTREACHED();
+ return;
+ }
+
+ view->SelectAll();
+}
+
+void AutomationProvider::Cut(int tab_handle) {
+ RenderViewHost* view = GetViewForTab(tab_handle);
+ if (!view) {
+ NOTREACHED();
+ return;
+ }
+
+ view->Cut();
+}
+
+void AutomationProvider::Copy(int tab_handle) {
+ RenderViewHost* view = GetViewForTab(tab_handle);
+ if (!view) {
+ NOTREACHED();
+ return;
+ }
+
+ view->Copy();
+}
+
+void AutomationProvider::Paste(int tab_handle) {
+ RenderViewHost* view = GetViewForTab(tab_handle);
+ if (!view) {
+ NOTREACHED();
+ return;
+ }
+
+ view->Paste();
+}
+
+void AutomationProvider::ReloadAsync(int tab_handle) {
+ if (tab_tracker_->ContainsHandle(tab_handle)) {
+ NavigationController* tab = tab_tracker_->GetResource(tab_handle);
+ if (!tab) {
+ NOTREACHED();
+ return;
+ }
+
+ tab->Reload(false);
+ }
+}
+
+void AutomationProvider::StopAsync(int tab_handle) {
+ RenderViewHost* view = GetViewForTab(tab_handle);
+ if (!view) {
+ NOTREACHED();
+ return;
+ }
+
+ view->Stop();
+}
+
+RenderViewHost* AutomationProvider::GetViewForTab(int tab_handle) {
+ if (tab_tracker_->ContainsHandle(tab_handle)) {
+ NavigationController* tab = tab_tracker_->GetResource(tab_handle);
+ if (!tab) {
+ NOTREACHED();
+ return NULL;
+ }
+
+ TabContents* tab_contents = tab->tab_contents();
+ if (!tab_contents) {
+ NOTREACHED();
+ return NULL;
+ }
+
+ RenderViewHost* view_host = tab_contents->render_view_host();
+ return view_host;
+ }
+
+ return NULL;
+}
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index c28cb1c..1c92be6 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -444,6 +444,17 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
// Returns the number of blocked popups in the tab |handle|.
void GetBlockedPopupCount(int handle, int* count);
+ // Selects all contents on the page.
+ void SelectAll(int tab_handle);
+
+ // Edit operations on the page.
+ void Cut(int tab_handle);
+ void Copy(int tab_handle);
+ void Paste(int tab_handle);
+
+ void ReloadAsync(int tab_handle);
+ void StopAsync(int tab_handle);
+
// Convert a tab handle into a TabContents. If |tab| is non-NULL a pointer
// to the tab is also returned. Returns NULL in case of failure or if the tab
// is not of the TabContents type.
@@ -464,6 +475,10 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
const std::string& origin,
const std::string& target);
+ // Returns the associated view for the tab handle passed in.
+ // Returns NULL on failure.
+ RenderViewHost* GetViewForTab(int tab_handle);
+
typedef ObserverList<NotificationObserver> NotificationObserverList;
typedef std::map<NavigationController*, LoginHandler*> LoginHandlerMap;
typedef std::map<int, ExtensionPortContainer*> PortContainerMap;
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 39ce010..9d67065 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -965,4 +965,21 @@ IPC_BEGIN_MESSAGES(Automation)
GURL /* url */,
std::string /* cookie */)
+ IPC_MESSAGE_ROUTED1(AutomationMsg_SelectAll,
+ int /* tab handle */)
+
+ IPC_MESSAGE_ROUTED1(AutomationMsg_Cut,
+ int /* tab handle */)
+
+ IPC_MESSAGE_ROUTED1(AutomationMsg_Copy,
+ int /* tab handle */)
+
+ IPC_MESSAGE_ROUTED1(AutomationMsg_Paste,
+ int /* tab handle */)
+
+ IPC_MESSAGE_ROUTED1(AutomationMsg_ReloadAsync,
+ int /* tab handle */)
+
+ IPC_MESSAGE_ROUTED1(AutomationMsg_StopAsync,
+ int /* tab handle */)
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 89bbf26..f52f16f 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -637,6 +637,30 @@ void TabProxy::SendContextMenuCommand(int selected_command) {
#endif // defined(OS_WIN)
+void TabProxy::SelectAll() {
+ sender_->Send(new AutomationMsg_SelectAll(0, handle_));
+}
+
+void TabProxy::Cut() {
+ sender_->Send(new AutomationMsg_Cut(0, handle_));
+}
+
+void TabProxy::Copy() {
+ sender_->Send(new AutomationMsg_Copy(0, handle_));
+}
+
+void TabProxy::Paste() {
+ sender_->Send(new AutomationMsg_Paste(0, handle_));
+}
+
+void TabProxy::ReloadAsync() {
+ sender_->Send(new AutomationMsg_ReloadAsync(0, handle_));
+}
+
+void TabProxy::StopAsync() {
+ sender_->Send(new AutomationMsg_StopAsync(0, handle_));
+}
+
void TabProxy::AddObserver(TabProxyDelegate* observer) {
AutoLock lock(list_lock_);
observers_list_.AddObserver(observer);
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index a04f496..5e83227 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -300,6 +300,19 @@ class TabProxy : public AutomationResourceProxy {
#endif // defined(OS_WIN)
+ // Selects all contents on the page.
+ void SelectAll();
+
+ // Edit operations on the page.
+ void Cut();
+ void Copy();
+ void Paste();
+
+ // These handlers issue asynchronous Reload and Stop notifications to the
+ // chrome instance.
+ void ReloadAsync();
+ void StopAsync();
+
// Calls delegates
void AddObserver(TabProxyDelegate* observer);
void RemoveObserver(TabProxyDelegate* observer);