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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa.h

Issue 10824307: Port Extension Commands to Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_COCOA_H _
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_COCOA_H _
7
8 #include <map>
9 #include <string>
10
11 #include "chrome/browser/extensions/extension_keybinding_registry.h"
12 #include "ui/base/accelerators/accelerator.h"
13 #include "ui/gfx/native_widget_types.h"
14
15 class Profile;
16
17 namespace content {
18 struct NativeWebKeyboardEvent;
19 }
20 namespace extensions {
21 class Extension;
22 }
23
24 // The ExtensionKeybindingRegistryCocoa is the Cocoa specialization of the
25 // ExtensionKeybindingRegistry class that handles turning keyboard shortcuts
26 // into events that get sent to the extension.
27
28 // ExtensionKeybindingRegistryCocoa is a class that handles Cocoa-specific
29 // implemenation of the Extension Commands shortcuts (keyboard accelerators).
30 // It also routes the events to the intended recipient (ie. to the browser
31 // action button in case of browser action commands).
32 class ExtensionKeybindingRegistryCocoa
33 : public extensions::ExtensionKeybindingRegistry {
34 public:
35 ExtensionKeybindingRegistryCocoa(Profile* profile, gfx::NativeWindow window);
36 virtual ~ExtensionKeybindingRegistryCocoa();
37
38 static void set_shortcut_handling_suspended(bool suspended) {
39 shortcut_handling_suspended_ = suspended;
40 }
41 static bool shortcut_handling_suspended() {
42 return shortcut_handling_suspended_;
43 }
44
45 // For a given keyboard |event|, see if a known Extension Command registration
46 // exists and route the event to it. Returns true if the event was handled,
47 // false otherwise.
48 bool ProcessKeyEvent(const content::NativeWebKeyboardEvent& event);
49
50 protected:
51 // Overridden from ExtensionKeybindingRegistry:
52 virtual void AddExtensionKeybinding(
53 const extensions::Extension* extension,
54 const std::string& command_name) OVERRIDE;
55 virtual void RemoveExtensionKeybinding(
56 const extensions::Extension* extension,
57 const std::string& command_name) OVERRIDE;
58
59 private:
60 // Keeps track of whether shortcut handling is currently suspended. Shortcuts
61 // are suspended briefly while capturing which shortcut to assign to an
62 // extension command in the Config UI. If handling isn't suspended while
63 // capturing then trying to assign Ctrl+F to a command would instead result
64 // in the Find box opening.
65 static bool shortcut_handling_suspended_;
66
67 // Weak pointer to the our profile. Not owned by us.
68 Profile* profile_;
69
70 // The window we are associated with.
71 gfx::NativeWindow window_;
72
73 // Maps an accelerator to a string pair (extension id, command name) for
74 // commands that have been registered. Unlike its Views counterpart, this map
75 // contains browserAction and pageAction commands (but does not route those
76 // events), so that we can query priority handlers in HasPriorityHandler(...).
77 typedef std::map< ui::Accelerator,
78 std::pair<std::string, std::string> > EventTargets;
79 EventTargets event_targets_;
80
81 // The content notification registrar for listening to extension events.
82 content::NotificationRegistrar registrar_;
83
84 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryCocoa);
85 };
86
87 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_COCO A_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698