| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ | |
| 6 #define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class MessagePumpDispatcher; | |
| 14 class RunLoop; | |
| 15 } | |
| 16 | |
| 17 namespace ui { | |
| 18 class KeyEvent; | |
| 19 } | |
| 20 | |
| 21 namespace ash { | |
| 22 | |
| 23 // Dispatcher for handling accelerators from menu. | |
| 24 // | |
| 25 // Wraps a nested dispatcher to which control is passed if no accelerator key | |
| 26 // has been pressed. If the nested dispatcher is NULL, then the control is | |
| 27 // passed back to the default dispatcher. | |
| 28 // TODO(pkotwicz): Add support for a |nested_dispatcher| which sends | |
| 29 // events to a system IME. | |
| 30 class ASH_EXPORT AcceleratorDispatcher { | |
| 31 public: | |
| 32 virtual ~AcceleratorDispatcher() {} | |
| 33 | |
| 34 static scoped_ptr<AcceleratorDispatcher> Create( | |
| 35 base::MessagePumpDispatcher* nested_dispatcher); | |
| 36 | |
| 37 // Creates a base::RunLoop object to run a nested message loop. | |
| 38 virtual scoped_ptr<base::RunLoop> CreateRunLoop() = 0; | |
| 39 | |
| 40 protected: | |
| 41 AcceleratorDispatcher() {} | |
| 42 | |
| 43 // Closes any open menu if the key-event could potentially be a system | |
| 44 // accelerator. | |
| 45 // Returns whether a menu was closed. | |
| 46 bool MenuClosedForPossibleAccelerator(const ui::KeyEvent& key_event); | |
| 47 | |
| 48 // Attempts to trigger an accelerator for the key-event. | |
| 49 // Returns whether an accelerator was triggered. | |
| 50 bool AcceleratorProcessedForKeyEvent(const ui::KeyEvent& key_event); | |
| 51 | |
| 52 private: | |
| 53 DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher); | |
| 54 }; | |
| 55 | |
| 56 } // namespace ash | |
| 57 | |
| 58 #endif // ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ | |
| OLD | NEW |