Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3062)

Unified Diff: athena/input/public/accelerator_manager.h

Issue 305873002: InputManager/AcceleratorManager for athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698