Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/browser/automation/ui_controls_gtk.cc

Issue 8021009: Consolidate message observer API for win and aura (and touch). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 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 }
50 virtual void DidProcessEvent(const base::NativeEvent& event) {
51 }
52 #else
45 // MessageLoop::Observer implementation: 53 // MessageLoop::Observer implementation:
46 virtual void WillProcessEvent(GdkEvent* event) { 54 virtual void WillProcessEvent(GdkEvent* event) {
47 if ((event->type == type_) && (--count_ == 0)) { 55 if ((event->type == type_) && (--count_ == 0)) {
48 // At the time we're invoked the event has not actually been processed. 56 // 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 57 // Use PostTask to make sure the event has been processed before
50 // notifying. 58 // notifying.
51 // NOTE: if processing a message results in running a nested message 59 // NOTE: if processing a message results in running a nested message
52 // loop, then DidProcessEvent isn't immediately sent. As such, we do 60 // loop, then DidProcessEvent isn't immediately sent. As such, we do
53 // the processing in WillProcessEvent rather than DidProcessEvent. 61 // the processing in WillProcessEvent rather than DidProcessEvent.
54 MessageLoop::current()->PostTask(FROM_HERE, task_); 62 MessageLoop::current()->PostTask(FROM_HERE, task_);
55 delete this; 63 delete this;
56 } 64 }
57 } 65 }
58 66
59 virtual void DidProcessEvent(GdkEvent* event) { 67 virtual void DidProcessEvent(GdkEvent* event) {
60 // No-op. 68 // No-op.
61 } 69 }
70 #endif
62 71
63 private: 72 private:
64 // We pass ownership of task_ to MessageLoop when the current event is 73 // We pass ownership of task_ to MessageLoop when the current event is
65 // received. 74 // received.
66 Task* task_; 75 Task* task_;
67 GdkEventType type_; 76 GdkEventType type_;
68 // The number of events of this type to wait for. 77 // The number of events of this type to wait for.
69 int count_; 78 int count_;
70 }; 79 };
71 80
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 int state, 308 int state,
300 Task* task) { 309 Task* task) {
301 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); 310 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget);
302 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, 311 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2,
303 bounds.y() + bounds.height() / 2, 312 bounds.y() + bounds.height() / 2,
304 new ClickTask(button, state, task)); 313 new ClickTask(button, state, task));
305 } 314 }
306 #endif 315 #endif
307 316
308 } // namespace ui_controls 317 } // namespace ui_controls
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698