OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ |
6 #define VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ | 6 #define VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 | 10 |
11 #if defined(TOUCH_UI) | |
12 typedef union _XEvent XEvent; | |
13 #endif | |
14 | |
15 namespace views { | 11 namespace views { |
16 | 12 |
17 // A nested dispatcher that can out-live the creator of this | 13 // A nested dispatcher that can out-live the creator of this |
18 // dispatcher. This is to deal with the scenario where a menu object | 14 // dispatcher. This is to deal with the scenario where a menu object |
19 // is deleted while it's handling the message loop. Note that | 15 // is deleted while it's handling the message loop. Note that |
20 // |RunAndSelfDestruct| method always delete itself regardless of | 16 // |RunAndSelfDestruct| method always delete itself regardless of |
21 // whether or not the menu object is deleted, so a menu object should | 17 // whether or not the menu object is deleted, so a menu object should |
22 // create a new instance for each open request. | 18 // create a new instance for each open request. |
23 // http://crosbug.com/7228, http://crosbug.com/7929 | 19 // http://crosbug.com/7228, http://crosbug.com/7929 |
24 class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher { | 20 class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher { |
25 public: | 21 public: |
26 NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, | 22 NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, |
27 bool allow_nested_task); | 23 bool allow_nested_task); |
28 | 24 |
29 // Run the messsage loop and returns if the menu has been | 25 // Run the messsage loop and returns if the menu has been |
30 // deleted in the nested loop. Returns true if the menu is | 26 // deleted in the nested loop. Returns true if the menu is |
31 // deleted, or false otherwise. | 27 // deleted, or false otherwise. |
32 bool RunAndSelfDestruct(); | 28 bool RunAndSelfDestruct(); |
33 | 29 |
34 // Tells the nested dispatcher that creator has been destroyed. | 30 // Tells the nested dispatcher that creator has been destroyed. |
35 void CreatorDestroyed(); | 31 void CreatorDestroyed(); |
36 | 32 |
37 private: | 33 private: |
38 virtual ~NestedDispatcherGtk() {} | 34 virtual ~NestedDispatcherGtk() {} |
39 | 35 |
40 // Overriden from MessageLoopForUI::Dispatcher: | 36 // Overriden from MessageLoopForUI::Dispatcher: |
41 virtual bool Dispatch(GdkEvent* event); | 37 virtual bool Dispatch(GdkEvent* event); |
42 | 38 |
43 #if defined(TOUCH_UI) | |
44 virtual bool Dispatch(XEvent* xevent); | |
45 #endif | |
46 | |
47 // Creator of the nested loop. | 39 // Creator of the nested loop. |
48 MessageLoopForUI::Dispatcher* creator_; | 40 MessageLoopForUI::Dispatcher* creator_; |
49 | 41 |
50 // True to allow nested task in the message loop. | 42 // True to allow nested task in the message loop. |
51 bool allow_nested_task_; | 43 bool allow_nested_task_; |
52 | 44 |
53 DISALLOW_COPY_AND_ASSIGN(NestedDispatcherGtk); | 45 DISALLOW_COPY_AND_ASSIGN(NestedDispatcherGtk); |
54 }; | 46 }; |
55 | 47 |
56 } // namespace views | 48 } // namespace views |
57 | 49 |
58 #endif // VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ | 50 #endif // VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ |
OLD | NEW |