| 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 <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 EventWaiter(Task* task, GdkEventType type, int count) | 34 EventWaiter(Task* task, GdkEventType type, int count) |
| 35 : task_(task), | 35 : task_(task), |
| 36 type_(type), | 36 type_(type), |
| 37 count_(count) { | 37 count_(count) { |
| 38 MessageLoopForUI::current()->AddObserver(this); | 38 MessageLoopForUI::current()->AddObserver(this); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual ~EventWaiter() { | 41 virtual ~EventWaiter() { |
| 42 MessageLoopForUI::current()->RemoveObserver(this); | 42 MessageLoopForUI::current()->RemoveObserver(this); |
| 43 } | 43 } |
| 44 #if defined(TOUCH_UI) |
| 45 // MessageLoop::Observer implementation: |
| 46 virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) { |
| 47 NOTIMPLEMENTED(); |
| 48 return base::EVENT_CONTINUE; |
| 49 } |
| 44 | 50 |
| 51 virtual void DidProcessEvent(const base::NativeEvent& event) { |
| 52 } |
| 53 #else |
| 45 // MessageLoop::Observer implementation: | 54 // MessageLoop::Observer implementation: |
| 46 virtual void WillProcessEvent(GdkEvent* event) { | 55 virtual void WillProcessEvent(GdkEvent* event) { |
| 47 if ((event->type == type_) && (--count_ == 0)) { | 56 if ((event->type == type_) && (--count_ == 0)) { |
| 48 // At the time we're invoked the event has not actually been processed. | 57 // At the time we're invoked the event has not actually been processed. |
| 49 // Use PostTask to make sure the event has been processed before | 58 // Use PostTask to make sure the event has been processed before |
| 50 // notifying. | 59 // notifying. |
| 51 // NOTE: if processing a message results in running a nested message | 60 // NOTE: if processing a message results in running a nested message |
| 52 // loop, then DidProcessEvent isn't immediately sent. As such, we do | 61 // loop, then DidProcessEvent isn't immediately sent. As such, we do |
| 53 // the processing in WillProcessEvent rather than DidProcessEvent. | 62 // the processing in WillProcessEvent rather than DidProcessEvent. |
| 54 MessageLoop::current()->PostTask(FROM_HERE, task_); | 63 MessageLoop::current()->PostTask(FROM_HERE, task_); |
| 55 delete this; | 64 delete this; |
| 56 } | 65 } |
| 57 } | 66 } |
| 58 | 67 |
| 59 virtual void DidProcessEvent(GdkEvent* event) { | 68 virtual void DidProcessEvent(GdkEvent* event) { |
| 60 // No-op. | 69 // No-op. |
| 61 } | 70 } |
| 71 #endif |
| 62 | 72 |
| 63 private: | 73 private: |
| 64 // We pass ownership of task_ to MessageLoop when the current event is | 74 // We pass ownership of task_ to MessageLoop when the current event is |
| 65 // received. | 75 // received. |
| 66 Task* task_; | 76 Task* task_; |
| 67 GdkEventType type_; | 77 GdkEventType type_; |
| 68 // The number of events of this type to wait for. | 78 // The number of events of this type to wait for. |
| 69 int count_; | 79 int count_; |
| 70 }; | 80 }; |
| 71 | 81 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 int state, | 309 int state, |
| 300 Task* task) { | 310 Task* task) { |
| 301 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); | 311 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); |
| 302 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, | 312 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, |
| 303 bounds.y() + bounds.height() / 2, | 313 bounds.y() + bounds.height() / 2, |
| 304 new ClickTask(button, state, task)); | 314 new ClickTask(button, state, task)); |
| 305 } | 315 } |
| 306 #endif | 316 #endif |
| 307 | 317 |
| 308 } // namespace ui_controls | 318 } // namespace ui_controls |
| OLD | NEW |