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 #include "ui/views/controls/menu/nested_dispatcher_gtk.h" | |
6 | |
7 namespace views { | |
8 | |
9 NestedDispatcherGtk::NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, | |
10 bool allow_nested_task) | |
11 : creator_(creator), | |
12 allow_nested_task_(allow_nested_task) { | |
13 } | |
14 | |
15 bool NestedDispatcherGtk::RunAndSelfDestruct() { | |
16 bool nestable = MessageLoopForUI::current()->NestableTasksAllowed(); | |
17 if (allow_nested_task_) | |
18 MessageLoopForUI::current()->SetNestableTasksAllowed(true); | |
19 MessageLoopForUI::current()->RunWithDispatcher(this); | |
20 if (allow_nested_task_) | |
21 MessageLoopForUI::current()->SetNestableTasksAllowed(nestable); | |
22 bool creator_is_deleted = creator_ == NULL; | |
23 delete this; | |
24 return creator_is_deleted; | |
25 } | |
26 | |
27 void NestedDispatcherGtk::CreatorDestroyed() { | |
28 creator_ = NULL; | |
29 } | |
30 | |
31 bool NestedDispatcherGtk::Dispatch(GdkEvent* event) { | |
32 return creator_ && creator_->Dispatch(event); | |
33 } | |
34 | |
35 } // namespace views | |
OLD | NEW |