diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 03:09:44 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 03:09:44 +0000 |
commit | 6790e994966a2986bab059b9ecd00ecf31e6bda6 (patch) | |
tree | 0eb8334013483d34237d69ec1aec7185e040d3a1 /chrome/browser/automation/automation_provider_win.cc | |
parent | be06d67c4742c12b2ad98bcfd7e0dbc74b627075 (diff) | |
download | chromium_src-6790e994966a2986bab059b9ecd00ecf31e6bda6.zip chromium_src-6790e994966a2986bab059b9ecd00ecf31e6bda6.tar.gz chromium_src-6790e994966a2986bab059b9ecd00ecf31e6bda6.tar.bz2 |
Revert 111850 - base::Bind: Convert the following files.
* automation_provider_win.cc
* chrome_browser_main.cc
* web_socket_proxy_controller.cc
* cookie_policy_browsertest.cc
* profile_sync_service_autofill_unittest.cc
BUG=none
TEST=none
R=csilv@chromium.org
Review URL: http://codereview.chromium.org/8727018
TBR=jhawkins@chromium.org
Review URL: http://codereview.chromium.org/8729019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/automation_provider_win.cc')
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 101 |
1 files changed, 79 insertions, 22 deletions
diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 999ae50..189ebef 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -30,16 +30,14 @@ #include "ui/views/focus/accelerator_handler.h" #include "ui/views/widget/root_view.h" -namespace { - -// This callback just adds another callback to the event queue. This is useful -// if you want to ensure that any callbacks added to the event queue after this -// one have already been processed by the time |callback| is run. -void InvokeCallbackLater(const base::Closure& callbck) { - MessageLoop::current()->PostTask(FROM_HERE, callback); +// This task just adds another task to the event queue. This is useful if +// you want to ensure that any tasks added to the event queue after this one +// have already been processed by the time |task| is run. +void InvokeTaskLater(Task* task) { + MessageLoop::current()->PostTask(FROM_HERE, task); } -void MoveMouse(const POINT& point) { +static void MoveMouse(const POINT& point) { SetCursorPos(point.x, point.y); // Now, make sure that GetMessagePos returns the values we just set by @@ -66,18 +64,78 @@ BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) { return TRUE; } -// This callback sends a WindowDragResponse message with the appropriate routing -// ID to the automation proxy. This is implemented as a task so that we know -// that the mouse events (and any tasks that they spawn on the message loop) -// have been processed by the time this is sent. -void WindowDragResponseCallback(AutomationProvider* provider, - IPC::Message* reply_message) { - DCHECK(reply_message != NULL); - AutomationMsg_WindowDrag::WriteReplyParams(reply_message, true); - provider->Send(reply_message); -} +// This task enqueues a mouse event on the event loop, so that the view +// that it's being sent to can do the requisite post-processing. +class MouseEventTask : public Task { + public: + MouseEventTask(views::View* view, + ui::EventType type, + const gfx::Point& point, + int flags) + : view_(view), type_(type), point_(point), flags_(flags) {} + virtual ~MouseEventTask() {} + + virtual void Run() { + views::MouseEvent event(type_, point_.x(), point_.y(), flags_); + // We need to set the cursor position before we process the event because + // some code (tab dragging, for instance) queries the actual cursor location + // rather than the location of the mouse event. Note that the reason why + // the drag code moved away from using mouse event locations was because + // our conversion to screen location doesn't work well with multiple + // monitors, so this only works reliably in a single monitor setup. + gfx::Point screen_location(point_.x(), point_.y()); + view_->ConvertPointToScreen(view_, &screen_location); + MoveMouse(screen_location.ToPOINT()); + switch (type_) { + case ui::ET_MOUSE_PRESSED: + view_->OnMousePressed(event); + break; + + case ui::ET_MOUSE_DRAGGED: + view_->OnMouseDragged(event); + break; + + case ui::ET_MOUSE_RELEASED: + view_->OnMouseReleased(event); + break; + + default: + NOTREACHED(); + } + } + + private: + views::View* view_; + ui::EventType type_; + gfx::Point point_; + int flags_; + + DISALLOW_COPY_AND_ASSIGN(MouseEventTask); +}; + +// This task sends a WindowDragResponse message with the appropriate +// routing ID to the automation proxy. This is implemented as a task so that +// we know that the mouse events (and any tasks that they spawn on the message +// loop) have been processed by the time this is sent. +class WindowDragResponseTask : public Task { + public: + WindowDragResponseTask(AutomationProvider* provider, + IPC::Message* reply_message) + : provider_(provider), reply_message_(reply_message) {} + virtual ~WindowDragResponseTask() {} + + virtual void Run() { + DCHECK(reply_message_ != NULL); + AutomationMsg_WindowDrag::WriteReplyParams(reply_message_, true); + provider_->Send(reply_message_); + } + + private: + AutomationProvider* provider_; + IPC::Message* reply_message_; -} // namespace + DISALLOW_COPY_AND_ASSIGN(WindowDragResponseTask); +}; void AutomationProvider::WindowSimulateDrag( int handle, @@ -155,9 +213,8 @@ void AutomationProvider::WindowSimulateDrag( MAKELPARAM(end.x, end.y)); MessageLoop::current()->PostTask( - FROM_HERE, base::Bind( - &InvokeCallbackLater, - base::Bind(&WindowDragResponseCallback, this, reply_message))); + FROM_HERE, base::Bind(&InvokeTaskLater, + new WindowDragResponseTask(this, reply_message))); } else { AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); Send(reply_message); |