OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 GetNormalBrowserWindowCount) | 275 GetNormalBrowserWindowCount) |
276 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) | 276 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) |
277 IPC_MESSAGE_HANDLER(AutomationMsg_GetBrowserLocale, GetBrowserLocale) | 277 IPC_MESSAGE_HANDLER(AutomationMsg_GetBrowserLocale, GetBrowserLocale) |
278 IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, | 278 IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, |
279 GetLastActiveBrowserWindow) | 279 GetLastActiveBrowserWindow) |
280 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) | 280 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) |
281 IPC_MESSAGE_HANDLER(AutomationMsg_FindNormalBrowserWindow, | 281 IPC_MESSAGE_HANDLER(AutomationMsg_FindNormalBrowserWindow, |
282 FindNormalBrowserWindow) | 282 FindNormalBrowserWindow) |
283 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) | 283 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) |
284 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) | 284 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) |
285 #if defined(OS_WIN) | 285 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowMaximized, IsWindowMaximized) |
286 IPC_MESSAGE_HANDLER(AutomationMsg_WindowHWND, GetWindowHWND) | |
287 #endif // defined(OS_WIN) | |
288 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, | 286 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, |
289 ExecuteBrowserCommandAsync) | 287 ExecuteBrowserCommandAsync) |
290 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, | 288 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, |
291 ExecuteBrowserCommand) | 289 ExecuteBrowserCommand) |
| 290 IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) |
292 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) | 291 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) |
| 292 IPC_MESSAGE_HANDLER(AutomationMsg_GetWindowBounds, GetWindowBounds) |
293 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) | 293 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) |
294 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) | 294 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) |
295 #if !defined(OS_MACOSX) | 295 #if !defined(OS_MACOSX) |
296 IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) | 296 IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) |
297 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) | 297 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) |
298 #endif // !defined(OS_MACOSX) | 298 #endif // !defined(OS_MACOSX) |
299 #if defined(OS_WIN) | 299 #if defined(OS_WIN) || defined(OS_LINUX) |
300 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, | 300 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, |
301 WindowSimulateDrag) | 301 WindowSimulateDrag) |
302 #endif // defined(OS_WIN) | 302 #endif // defined(OS_WIN) || defined(OS_LINUX) |
303 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) | 303 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) |
304 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) | 304 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) |
305 #if defined(OS_WIN) | 305 #if defined(OS_WIN) |
306 IPC_MESSAGE_HANDLER(AutomationMsg_TabHWND, GetTabHWND) | 306 IPC_MESSAGE_HANDLER(AutomationMsg_TabHWND, GetTabHWND) |
307 #endif // defined(OS_WIN) | 307 #endif // defined(OS_WIN) |
308 IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) | 308 IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) |
309 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) | 309 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) |
310 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) | 310 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) |
311 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) | 311 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) |
312 IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) | 312 IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) |
(...skipping 27 matching lines...) Expand all Loading... |
340 IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, | 340 IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, |
341 HideInterstitialPage) | 341 HideInterstitialPage) |
342 #if defined(OS_WIN) | 342 #if defined(OS_WIN) |
343 IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, | 343 IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, |
344 ProcessUnhandledAccelerator) | 344 ProcessUnhandledAccelerator) |
345 #endif | 345 #endif |
346 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, | 346 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, |
347 WaitForTabToBeRestored) | 347 WaitForTabToBeRestored) |
348 IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) | 348 IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) |
349 #if defined(OS_WIN) | 349 #if defined(OS_WIN) |
350 IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition) | |
351 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome, | 350 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome, |
352 OnForwardContextMenuCommandToChrome) | 351 OnForwardContextMenuCommandToChrome) |
353 #endif | 352 #endif |
354 IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) | 353 IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) |
355 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) | 354 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) |
356 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, | 355 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, |
357 ActionOnSSLBlockingPage) | 356 ActionOnSSLBlockingPage) |
358 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) | 357 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) |
359 IPC_MESSAGE_HANDLER(AutomationMsg_IsPageMenuCommandEnabled, | 358 IPC_MESSAGE_HANDLER(AutomationMsg_IsPageMenuCommandEnabled, |
360 IsPageMenuCommandEnabled) | 359 IsPageMenuCommandEnabled) |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 virtual void Run() { | 807 virtual void Run() { |
809 MessageLoop::current()->PostTask(FROM_HERE, task_); | 808 MessageLoop::current()->PostTask(FROM_HERE, task_); |
810 } | 809 } |
811 | 810 |
812 private: | 811 private: |
813 Task* task_; | 812 Task* task_; |
814 | 813 |
815 DISALLOW_COPY_AND_ASSIGN(InvokeTaskLaterTask); | 814 DISALLOW_COPY_AND_ASSIGN(InvokeTaskLaterTask); |
816 }; | 815 }; |
817 | 816 |
818 #if defined(OS_WIN) | |
819 // TODO(port): Replace POINT and other windowsisms. | |
820 | |
821 // This task sends a WindowDragResponse message with the appropriate | |
822 // routing ID to the automation proxy. This is implemented as a task so that | |
823 // we know that the mouse events (and any tasks that they spawn on the message | |
824 // loop) have been processed by the time this is sent. | |
825 class WindowDragResponseTask : public Task { | |
826 public: | |
827 WindowDragResponseTask(AutomationProvider* provider, | |
828 IPC::Message* reply_message) | |
829 : provider_(provider), reply_message_(reply_message) {} | |
830 virtual ~WindowDragResponseTask() {} | |
831 | |
832 virtual void Run() { | |
833 DCHECK(reply_message_ != NULL); | |
834 AutomationMsg_WindowDrag::WriteReplyParams(reply_message_, true); | |
835 provider_->Send(reply_message_); | |
836 } | |
837 | |
838 private: | |
839 AutomationProvider* provider_; | |
840 IPC::Message* reply_message_; | |
841 | |
842 DISALLOW_COPY_AND_ASSIGN(WindowDragResponseTask); | |
843 }; | |
844 #endif // defined(OS_WIN) | |
845 | |
846 #if defined(OS_WIN) || defined(OS_LINUX) | 817 #if defined(OS_WIN) || defined(OS_LINUX) |
847 void AutomationProvider::WindowSimulateClick(const IPC::Message& message, | 818 void AutomationProvider::WindowSimulateClick(const IPC::Message& message, |
848 int handle, | 819 int handle, |
849 const gfx::Point& click, | 820 const gfx::Point& click, |
850 int flags) { | 821 int flags) { |
851 if (window_tracker_->ContainsHandle(handle)) { | 822 if (window_tracker_->ContainsHandle(handle)) { |
852 ui_controls::SendMouseMoveNotifyWhenDone(click.x(), click.y(), | 823 ui_controls::SendMouseMoveNotifyWhenDone(click.x(), click.y(), |
853 new ClickTask(flags)); | 824 new ClickTask(flags)); |
854 } | 825 } |
855 } | 826 } |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 for (;iter != BrowserList::end(); ++iter) { | 2055 for (;iter != BrowserList::end(); ++iter) { |
2085 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle(); | 2056 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle(); |
2086 if (window == this_window) { | 2057 if (window == this_window) { |
2087 // Add() returns the existing handle for the resource if any. | 2058 // Add() returns the existing handle for the resource if any. |
2088 *browser_handle = browser_tracker_->Add(*iter); | 2059 *browser_handle = browser_tracker_->Add(*iter); |
2089 *success = true; | 2060 *success = true; |
2090 return; | 2061 return; |
2091 } | 2062 } |
2092 } | 2063 } |
2093 } | 2064 } |
OLD | NEW |