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

Unified Diff: ui/base/accelerators/accelerator_manager.h

Issue 9402018: Experimental Extension Keybinding (first cut). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | « chrome/common/extensions/manifest.cc ('k') | ui/base/accelerators/accelerator_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/accelerators/accelerator_manager.h
===================================================================
--- ui/base/accelerators/accelerator_manager.h (revision 123221)
+++ ui/base/accelerators/accelerator_manager.h (working copy)
@@ -8,6 +8,7 @@
#include <list>
#include <map>
+#include <utility>
#include "base/basictypes.h"
#include "ui/base/accelerators/accelerator.h"
@@ -19,19 +20,34 @@
// The AcceleratorManger is used to handle keyboard accelerators.
class UI_EXPORT AcceleratorManager {
public:
+ enum HandlerPriority {
+ kNormalPriority,
+ kHighPriority,
+ };
+
AcceleratorManager();
~AcceleratorManager();
// Register a keyboard accelerator for the specified target. If multiple
// targets are registered for an accelerator, a target registered later has
// higher priority.
+ // |accelerator| is the accelerator to register.
+ // |priority| denotes the priority of the handler.
+ // NOTE: In almost all cases, you should specify kPriorityNormal for this
+ // parameter. Setting it to kPriorityHigh prevents Chrome from sending the
+ // shortcut to the webpage if the renderer has focus, which is not desirable
+ // except for very isolated cases.
+ // |target| is the AcceleratorTarget that handles the event once the
+ // accelerator is pressed.
// Note that we are currently limited to accelerators that are either:
// - a key combination including Ctrl or Alt
// - the escape key
// - the enter key
// - any F key (F1, F2, F3 ...)
// - any browser specific keys (as available on special keyboards)
- void Register(const Accelerator& accelerator, AcceleratorTarget* target);
+ void Register(const Accelerator& accelerator,
+ HandlerPriority priority,
+ AcceleratorTarget* target);
// Unregister the specified keyboard accelerator for the specified target.
void Unregister(const Accelerator& accelerator, AcceleratorTarget* target);
@@ -52,12 +68,18 @@
// accelerator.
AcceleratorTarget* GetCurrentTarget(const Accelerator& accelertor) const;
+ // Whether the given |accelerator| has a priority handler associated with it.
+ bool HasPriorityHandler(const Accelerator& accelerator) const;
+
private:
bool ShouldHandle(const Accelerator& accelerator) const;
// The accelerators and associated targets.
typedef std::list<AcceleratorTarget*> AcceleratorTargetList;
- typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap;
+ // This construct pairs together a |bool| (denoting whether the list contains
+ // a priority_handler at the front) with the list of AcceleratorTargets.
+ typedef std::pair<bool, AcceleratorTargetList> AcceleratorTargets;
+ typedef std::map<Accelerator, AcceleratorTargets> AcceleratorMap;
AcceleratorMap accelerators_;
// An event passed to Process() last time.
« no previous file with comments | « chrome/common/extensions/manifest.cc ('k') | ui/base/accelerators/accelerator_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698