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

Side by Side Diff: ui/base/accelerator_manager.h

Issue 8508056: Split a part of code managing accelerators from views::FocusManager. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/base/accelerator_manager.cc » ('j') | views/focus/focus_manager.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_BASE_ACCELERATOR_MANAGER_H_
6 #define UI_BASE_ACCELERATOR_MANAGER_H_
7 #pragma once
8
9 #include <list>
10 #include <map>
11
12 #include "ui/base/models/accelerator.h"
13 #include "ui/base/ui_export.h"
14
15 namespace ui {
16
17 // The AcceleratorManger is used to handle keyboard accelerators.
18 class UI_EXPORT AcceleratorManager {
19 public:
20 AcceleratorManager();
21 ~AcceleratorManager();
22
23 // Register a keyboard accelerator for the specified target. If multiple
24 // targets are registered for an accelerator, a target registered later has
25 // higher priority.
26 // Note that we are currently limited to accelerators that are either:
27 // - a key combination including Ctrl or Alt
28 // - the escape key
29 // - the enter key
30 // - any F key (F1, F2, F3 ...)
31 // - any browser specific keys (as available on special keyboards)
32 void Register(const Accelerator& accelerator, AcceleratorTarget* target);
33
34 // Unregister the specified keyboard accelerator for the specified target.
35 void Unregister(const Accelerator& accelerator, AcceleratorTarget* target);
36
37 // Unregister all keyboard accelerator for the specified target.
38 void UnregisterAll(AcceleratorTarget* target);
39
40 // Activate the target associated with the specified accelerator.
41 // First, AcceleratorPressed handler of the most recently registered target
42 // is called, and if that handler processes the event (i.e. returns true),
43 // this method immediately returns. If not, we do the same thing on the next
44 // target, and so on.
45 // Returns true if an accelerator was activated.
46 bool Process(const Accelerator& accelerator);
47
48 // Returns the AcceleratorTarget that should be activated for the specified
49 // keyboard accelerator, or NULL if no view is registered for that keyboard
50 // accelerator.
51 AcceleratorTarget* GetCurrentTarget(const Accelerator& accelertor) const;
52
53 private:
54 // The accelerators and associated targets.
55 typedef std::list<AcceleratorTarget*> AcceleratorTargetList;
56 typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap;
57 AcceleratorMap accelerators_;
58 };
tfarina 2011/11/14 15:57:50 nit: add DISALLOW_COPY_AND_ASSIGN here? if yes, do
mazda 2011/11/14 19:16:54 Done.
59
60 } // namespace ui
61
62 #endif // UI_BASE_ACCELERATOR_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/accelerator_manager.cc » ('j') | views/focus/focus_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698