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