1 // Copyright (c) 2012 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.
5 #ifndef ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
6 #define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_
8 #include "ash/ash_export.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
13 class MessagePumpDispatcher;
23 // Dispatcher for handling accelerators from menu.
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 {
32 virtual ~AcceleratorDispatcher() {}
34 static scoped_ptr<AcceleratorDispatcher> Create(
35 base::MessagePumpDispatcher* nested_dispatcher);
37 // Creates a base::RunLoop object to run a nested message loop.
38 virtual scoped_ptr<base::RunLoop> CreateRunLoop() = 0;
41 AcceleratorDispatcher() {}
43 // Closes any open menu if the key-event could potentially be a system
45 // Returns whether a menu was closed.
46 bool MenuClosedForPossibleAccelerator(const ui::KeyEvent& key_event);
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);
53 DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher);
58 #endif // ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_