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

Unified Diff: ui/aura_shell/shell_accelerator_controller.h

Issue 8465021: Add ShellAcceleratorController that managers global keyboard accelerators. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add ShellAcceleratorController Created 9 years, 1 month 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: ui/aura_shell/shell_accelerator_controller.h
diff --git a/ui/aura_shell/shell_accelerator_controller.h b/ui/aura_shell/shell_accelerator_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..3cede6e048c3f455187ba75257434d0d4f97e81e
--- /dev/null
+++ b/ui/aura_shell/shell_accelerator_controller.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2011 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 UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_
+#define UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/aura_shell/aura_shell_export.h"
+#include "ui/base/accelerator_manager.h"
tfarina 2011/11/17 12:49:55 nit: you can forward declare this;
mazda 2011/11/17 13:10:16 Done.
+#include "ui/base/models/accelerator.h"
tfarina 2011/11/17 12:49:55 nit: I wish we could centralize all classes relate
mazda 2011/11/17 13:10:16 OK. I filed an issue for that (http://crbug.com/10
+
+namespace aura_shell {
+
+// ShellAcceleratorController provides functions for registering or
+// unregistering global keyboard accelerators, which are handled earlier than
+// any windows. It also implements several handlers as an accelerator target.
+class AURA_SHELL_EXPORT ShellAcceleratorController
+ : public ui::AcceleratorTarget {
+ public:
+ ShellAcceleratorController();
+ virtual ~ShellAcceleratorController();
+
+ // Register a global keyboard accelerator for the specified target. If
+ // multiple targets are registered for an accelerator, a target registered
+ // later has higher priority.
+ void Register(const ui::Accelerator& accelerator,
+ ui::AcceleratorTarget* target);
+
+ // Unregister the specified keyboard accelerator for the specified target.
+ void Unregister(const ui::Accelerator& accelerator,
+ ui::AcceleratorTarget* target);
+
+ // Unregister all keyboard accelerators for the specified target.
+ void UnregisterAll(ui::AcceleratorTarget* target);
+
+ // Activate the target associated with the specified accelerator.
+ // First, AcceleratorPressed handler of the most recently registered target
+ // is called, and if that handler processes the event (i.e. returns true),
+ // this method immediately returns. If not, we do the same thing on the next
+ // target, and so on.
+ // Returns true if an accelerator was activated.
+ bool Process(const ui::Accelerator& accelerator);
+
+ // Overridden from ui::AcceleratorTarget:
+ virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
+
+ private:
+ scoped_ptr<ui::AcceleratorManager> accelerator_manager_;
+ DISALLOW_COPY_AND_ASSIGN(ShellAcceleratorController);
tfarina 2011/11/17 12:49:55 nit: newline between 52-53
mazda 2011/11/17 13:10:16 Done.
+};
+
+} // namespace aura_shell
+
+#endif // UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698