OLD | NEW |
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 CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ |
7 | 7 |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <map> | |
10 #include <string> | 9 #include <string> |
11 | 10 |
12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
13 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 12 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
14 #include "ui/base/accelerators/accelerator.h" | 13 #include "ui/base/accelerators/accelerator.h" |
15 #include "ui/base/gtk/gtk_signal.h" | 14 #include "ui/base/gtk/gtk_signal.h" |
16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
17 | 16 |
18 class Profile; | 17 class Profile; |
19 | 18 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 51 |
53 // Whether this class has any registered keyboard shortcuts that correspond | 52 // Whether this class has any registered keyboard shortcuts that correspond |
54 // to |event|. | 53 // to |event|. |
55 gboolean HasPriorityHandler(const GdkEventKey* event) const; | 54 gboolean HasPriorityHandler(const GdkEventKey* event) const; |
56 | 55 |
57 protected: | 56 protected: |
58 // Overridden from ExtensionKeybindingRegistry: | 57 // Overridden from ExtensionKeybindingRegistry: |
59 virtual void AddExtensionKeybinding( | 58 virtual void AddExtensionKeybinding( |
60 const extensions::Extension* extension, | 59 const extensions::Extension* extension, |
61 const std::string& command_name) OVERRIDE; | 60 const std::string& command_name) OVERRIDE; |
62 virtual void RemoveExtensionKeybinding( | 61 virtual void RemoveExtensionKeybindingImpl( |
63 const extensions::Extension* extension, | 62 const ui::Accelerator& accelerator, |
64 const std::string& command_name) OVERRIDE; | 63 const std::string& command_name) OVERRIDE; |
65 | 64 |
66 private: | 65 private: |
67 // The accelerator handler for when the extension command shortcuts are | 66 // The accelerator handler for when the extension command shortcuts are |
68 // struck. | 67 // struck. |
69 CHROMEG_CALLBACK_3(ExtensionKeybindingRegistryGtk, gboolean, OnGtkAccelerator, | 68 CHROMEG_CALLBACK_3(ExtensionKeybindingRegistryGtk, gboolean, OnGtkAccelerator, |
70 GtkAccelGroup*, GObject*, guint, GdkModifierType); | 69 GtkAccelGroup*, GObject*, guint, GdkModifierType); |
71 | 70 |
72 // Keeps track of whether shortcut handling is currently suspended. Shortcuts | 71 // Keeps track of whether shortcut handling is currently suspended. Shortcuts |
73 // are suspended briefly while capturing which shortcut to assign to an | 72 // are suspended briefly while capturing which shortcut to assign to an |
74 // extension command in the Config UI. If handling isn't suspended while | 73 // extension command in the Config UI. If handling isn't suspended while |
75 // capturing then trying to assign Ctrl+F to a command would instead result | 74 // capturing then trying to assign Ctrl+F to a command would instead result |
76 // in the Find box opening. | 75 // in the Find box opening. |
77 static bool shortcut_handling_suspended_; | 76 static bool shortcut_handling_suspended_; |
78 | 77 |
79 // Weak pointer to the our profile. Not owned by us. | 78 // Weak pointer to the our profile. Not owned by us. |
80 Profile* profile_; | 79 Profile* profile_; |
81 | 80 |
82 // The browser window the accelerators are associated with. | 81 // The browser window the accelerators are associated with. |
83 gfx::NativeWindow window_; | 82 gfx::NativeWindow window_; |
84 | 83 |
85 // The accelerator group used to handle accelerators, owned by this object. | 84 // The accelerator group used to handle accelerators, owned by this object. |
86 GtkAccelGroup* accel_group_; | 85 GtkAccelGroup* accel_group_; |
87 | 86 |
88 // Maps an accelerator to a string pair (extension id, command name) for | |
89 // commands that have been registered. Unlike its Views counterpart, this map | |
90 // contains browserAction and pageAction commands (but does not route those | |
91 // events), so that we can query priority handlers in HasPriorityHandler(...). | |
92 typedef std::map< ui::Accelerator, | |
93 std::pair<std::string, std::string> > EventTargets; | |
94 EventTargets event_targets_; | |
95 | |
96 // The content notification registrar for listening to extension events. | 87 // The content notification registrar for listening to extension events. |
97 content::NotificationRegistrar registrar_; | 88 content::NotificationRegistrar registrar_; |
98 | 89 |
99 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryGtk); | 90 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryGtk); |
100 }; | 91 }; |
101 | 92 |
102 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ | 93 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ |
OLD | NEW |