Chromium Code Reviews| Index: athena/input/public/accelerator_manager.h |
| diff --git a/athena/input/public/accelerator_manager.h b/athena/input/public/accelerator_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..db0cad4c99d144a1fae297565844f6b40808b4bc |
| --- /dev/null |
| +++ b/athena/input/public/accelerator_manager.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
| +#define ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
| + |
| +#include "athena/athena_export.h" |
| +#include "ui/events/keycodes/keyboard_codes.h" |
| + |
| +namespace ui { |
| +class Accelerator; |
| +} |
| + |
| +namespace athena { |
| + |
| +enum TriggerEvent { |
| + TRIGGER_ON_PRESS, |
| + TRIGGER_ON_RELEASE, |
| +}; |
| + |
| +// Accelerator flags. |
| +enum AcceleratorFlags { |
| + AF_NONE = 0, |
| + AF_NON_AUTO_REPEATABLE = 1 << 0, |
| + AF_RESERVED = 1 << 1, |
| + AF_DEBUG = 1 << 2, |
| +}; |
| + |
| +struct AcceleratorData { |
| + // true if the accelerator should be triggered upon ui::ET_KEY_PRESSED |
| + TriggerEvent trigger_event; |
| + ui::KeyboardCode keycode; // KeyEvent event flags. |
| + int keyevent_flags; // Combination of ui::KeyEventFlags |
| + int command_id; // ID to distinguish |
| + int accelerator_flags; // Combination of AcceleratorFlags; |
| +}; |
| + |
| +// An interface that implements behavior for the set of |
| +// accelerators. |
| +class ATHENA_EXPORT AcceleratorHandler { |
| + public: |
| + virtual ~AcceleratorHandler() {} |
| + |
| + virtual bool IsCommandEnabled(int command_id) const = 0; |
| + virtual bool OnAcceleratorFired(int command_id, |
| + const ui::Accelerator& accelerator) = 0; |
| +}; |
| + |
| +class AcceleratorManager { |
|
sadrul
2014/06/04 04:31:48
Can we use the existing ui:AcceleratorManager and
|
| + public: |
| + virtual ~AcceleratorManager() {} |
| + |
| + // Register accelerators and its handler that will be invoked when |
| + // one of accelerator is fired. |
| + virtual void RegisterAccelerators(const AcceleratorData accelerators[], |
| + size_t num_accelerators, |
| + AcceleratorHandler* handler) = 0; |
| + |
| + // Enables accelerators that has a AF_DEBUG flag. |
| + virtual void EnableDebugAccelerators() = 0; |
| +}; |
| + |
| +} // namespace athena |
| + |
| +#endif // ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |