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

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

Issue 2586333003: Make mash register initial batch of accelerators in single shot. (Closed)
Patch Set: Change register to use accelerator vector. Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ 5 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_
6 #define UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "ui/base/accelerators/accelerator.h" 14 #include "ui/base/accelerators/accelerator.h"
14 #include "ui/base/ui_base_export.h" 15 #include "ui/base/ui_base_export.h"
15 #include "ui/events/event_constants.h" 16 #include "ui/events/event_constants.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 class AcceleratorManagerDelegate; 20 class AcceleratorManagerDelegate;
20 21
21 // AcceleratorManger handles processing of accelerators. A delegate may be 22 // AcceleratorManger handles processing of accelerators. A delegate may be
22 // supplied which is notified as unique accelerators are added and removed. 23 // supplied which is notified as unique accelerators are added and removed.
23 class UI_BASE_EXPORT AcceleratorManager { 24 class UI_BASE_EXPORT AcceleratorManager {
24 public: 25 public:
25 enum HandlerPriority { 26 enum HandlerPriority {
26 kNormalPriority, 27 kNormalPriority,
27 kHighPriority, 28 kHighPriority,
28 }; 29 };
29 30
30 explicit AcceleratorManager(AcceleratorManagerDelegate* = nullptr); 31 explicit AcceleratorManager(AcceleratorManagerDelegate* = nullptr);
31 ~AcceleratorManager(); 32 ~AcceleratorManager();
32 33
33 // Register a keyboard accelerator for the specified target. If multiple 34 // Register a keyboard accelerator for the specified target. If multiple
mfomitchev 2016/12/22 01:04:50 Update comment
thanhph 2016/12/22 20:36:02 Done.
34 // targets are registered for an accelerator, a target registered later has 35 // targets are registered for an accelerator, a target registered later has
35 // higher priority. 36 // higher priority.
36 // |accelerator| is the accelerator to register. 37 // |accelerator| is the accelerator to register.
37 // |priority| denotes the priority of the handler. 38 // |priority| denotes the priority of the handler.
38 // NOTE: In almost all cases, you should specify kNormalPriority for this 39 // NOTE: In almost all cases, you should specify kNormalPriority for this
39 // parameter. Setting it to kHighPriority prevents Chrome from sending the 40 // parameter. Setting it to kHighPriority prevents Chrome from sending the
40 // shortcut to the webpage if the renderer has focus, which is not desirable 41 // shortcut to the webpage if the renderer has focus, which is not desirable
41 // except for very isolated cases. 42 // except for very isolated cases.
42 // |target| is the AcceleratorTarget that handles the event once the 43 // |target| is the AcceleratorTarget that handles the event once the
43 // accelerator is pressed. 44 // accelerator is pressed.
44 // Note that we are currently limited to accelerators that are either: 45 // Note that we are currently limited to accelerators that are either:
45 // - a key combination including Ctrl or Alt 46 // - a key combination including Ctrl or Alt
46 // - the escape key 47 // - the escape key
47 // - the enter key 48 // - the enter key
48 // - any F key (F1, F2, F3 ...) 49 // - any F key (F1, F2, F3 ...)
49 // - any browser specific keys (as available on special keyboards) 50 // - any browser specific keys (as available on special keyboards)
50 void Register(const Accelerator& accelerator, 51 void Register(const std::vector<ui::Accelerator>& accelerators,
51 HandlerPriority priority, 52 HandlerPriority priority,
52 AcceleratorTarget* target); 53 AcceleratorTarget* target);
53 54
55 void Registers(std::vector<ui::Accelerator>& accelerators);
mfomitchev 2016/12/22 01:04:50 Don't think we are using this?
thanhph 2016/12/22 20:36:02 Done, removed!
56
54 // Unregister the specified keyboard accelerator for the specified target. 57 // Unregister the specified keyboard accelerator for the specified target.
55 void Unregister(const Accelerator& accelerator, AcceleratorTarget* target); 58 void Unregister(const Accelerator& accelerator, AcceleratorTarget* target);
56 59
57 // Unregister all keyboard accelerator for the specified target. 60 // Unregister all keyboard accelerator for the specified target.
58 void UnregisterAll(AcceleratorTarget* target); 61 void UnregisterAll(AcceleratorTarget* target);
59 62
60 // Returns whether |accelerator| is already registered. 63 // Returns whether |accelerator| is already registered.
61 bool IsRegistered(const Accelerator& accelerator) const; 64 bool IsRegistered(const Accelerator& accelerator) const;
62 65
63 // Activate the target associated with the specified accelerator. 66 // Activate the target associated with the specified accelerator.
(...skipping 22 matching lines...) Expand all
86 89
87 AcceleratorManagerDelegate* delegate_; 90 AcceleratorManagerDelegate* delegate_;
88 AcceleratorMap accelerators_; 91 AcceleratorMap accelerators_;
89 92
90 DISALLOW_COPY_AND_ASSIGN(AcceleratorManager); 93 DISALLOW_COPY_AND_ASSIGN(AcceleratorManager);
91 }; 94 };
92 95
93 } // namespace ui 96 } // namespace ui
94 97
95 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ 98 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698