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

Unified Diff: ash/common/key_event_watcher.h

Issue 2330403002: Do not activate system tray bubble by default (Closed)
Patch Set: Do not activate system tray bubble by default Created 4 years, 3 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
« no previous file with comments | « ash/aura/wm_shell_aura.cc ('k') | ash/common/key_event_watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/key_event_watcher.h
diff --git a/ash/common/key_event_watcher.h b/ash/common/key_event_watcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..80b649ff8fed31bf331e6b2f500491438d09262f
--- /dev/null
+++ b/ash/common/key_event_watcher.h
@@ -0,0 +1,49 @@
+// Copyright 2016 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 ASH_COMMON_KEY_EVENT_WATCHER_H_
+#define ASH_COMMON_KEY_EVENT_WATCHER_H_
+
+#include <map>
+
+#include "ash/ash_export.h"
+#include "base/callback.h"
+#include "base/macros.h"
+#include "ui/base/accelerators/accelerator.h"
+
+namespace ui {
+class KeyEvent;
+}
+
+namespace ash {
+
+// This class watches the key event given in the form of accelerator
+// and calls the registered callback.
+class ASH_EXPORT KeyEventWatcher {
+ public:
+ using KeyEventCallback = base::Callback<void(const ui::KeyEvent&)>;
+
+ KeyEventWatcher();
+ virtual ~KeyEventWatcher();
+
+ // Add a callback that is called when the accelerator |accel| is
+ // matched. The key event will be consumed if a matching accelerator
+ // is found.
+ void AddKeyEventCallback(const ui::Accelerator& accel,
+ const KeyEventCallback& callback);
+
+ protected:
+ // Finds and calls the registered callback whose accelerator matches
+ // the |event|. Returns false if no accelerator is matched.
+ bool HandleKeyEvent(const ui::KeyEvent& event);
+
+ private:
+ std::map<ui::Accelerator, KeyEventCallback> callback_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyEventWatcher);
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_KEY_EVENT_WATCHER_H_
« no previous file with comments | « ash/aura/wm_shell_aura.cc ('k') | ash/common/key_event_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698