| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui_controls.h" | 5 #include "chrome/browser/automation/ui_controls.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/task.h" | 11 #include "base/task.h" |
| 11 #include "ui/base/keycodes/keyboard_codes.h" | 12 #include "ui/base/keycodes/keyboard_codes.h" |
| 12 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 13 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
| 13 #include "views/view.h" | 14 #include "views/view.h" |
| 14 | 15 |
| 15 namespace ui_controls { | 16 namespace ui_controls { |
| 16 | 17 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 void InputDispatcher::DispatchedMessage(WPARAM message) { | 121 void InputDispatcher::DispatchedMessage(WPARAM message) { |
| 121 if (message == message_waiting_for_) | 122 if (message == message_waiting_for_) |
| 122 MatchingMessageFound(); | 123 MatchingMessageFound(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void InputDispatcher::MatchingMessageFound() { | 126 void InputDispatcher::MatchingMessageFound() { |
| 126 UninstallHook(this); | 127 UninstallHook(this); |
| 127 // At the time we're invoked the event has not actually been processed. | 128 // At the time we're invoked the event has not actually been processed. |
| 128 // Use PostTask to make sure the event has been processed before notifying. | 129 // Use PostTask to make sure the event has been processed before notifying. |
| 129 MessageLoop::current()->PostDelayedTask( | 130 MessageLoop::current()->PostTask( |
| 130 FROM_HERE, NewRunnableMethod(this, &InputDispatcher::NotifyTask), 0); | 131 FROM_HERE, base::Bind(&InputDispatcher::NotifyTask, this)); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void InputDispatcher::NotifyTask() { | 134 void InputDispatcher::NotifyTask() { |
| 134 task_->Run(); | 135 task_->Run(); |
| 135 Release(); | 136 Release(); |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Private functions ---------------------------------------------------------- | 139 // Private functions ---------------------------------------------------------- |
| 139 | 140 |
| 140 // Populate the INPUT structure with the appropriate keyboard event | 141 // Populate the INPUT structure with the appropriate keyboard event |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 Task* task) { | 373 Task* task) { |
| 373 DCHECK(view); | 374 DCHECK(view); |
| 374 DCHECK(view->GetWidget()); | 375 DCHECK(view->GetWidget()); |
| 375 gfx::Point view_center(view->width() / 2, view->height() / 2); | 376 gfx::Point view_center(view->width() / 2, view->height() / 2); |
| 376 views::View::ConvertPointToScreen(view, &view_center); | 377 views::View::ConvertPointToScreen(view, &view_center); |
| 377 SendMouseMove(view_center.x(), view_center.y()); | 378 SendMouseMove(view_center.x(), view_center.y()); |
| 378 SendMouseEventsNotifyWhenDone(button, state, task); | 379 SendMouseEventsNotifyWhenDone(button, state, task); |
| 379 } | 380 } |
| 380 | 381 |
| 381 } // ui_controls | 382 } // ui_controls |
| OLD | NEW |