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..e0a1ad447bd7bc1454c9f637f791ded0bd6cf40c |
--- /dev/null |
+++ b/athena/input/public/accelerator_manager.h |
@@ -0,0 +1,72 @@ |
+// 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, |
+ // Used for accelerators that should not be fired on auto repeated |
+ // key event, such as toggling fullscrren. |
+ AF_NON_AUTO_REPEATABLE = 1 << 0, |
+ // Most key events are sent to applications first as they may |
+ // want to consume them. Reserverd accelerators are reserved for OS |
+ // and cannot be consumed by apps. (such as window cycling) |
+ AF_RESERVED = 1 << 1, |
+ // Used for accelerators that are useful only in debug mode. |
+ 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 { |
+ 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_ |