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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 13 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
14 #include "ui/base/accelerators/accelerator_gtk.h" | 14 #include "ui/base/accelerators/accelerator_gtk.h" |
15 #include "ui/base/gtk/gtk_signal.h" | 15 #include "ui/base/gtk/gtk_signal.h" |
16 | 16 |
| 17 class Profile; |
| 18 |
| 19 namespace extensions { |
17 class Extension; | 20 class Extension; |
18 class Profile; | 21 } |
19 | 22 |
20 typedef struct _GtkAccelGroup GtkAccelGroup; | 23 typedef struct _GtkAccelGroup GtkAccelGroup; |
21 typedef struct _GdkEventKey GdkEventKey; | 24 typedef struct _GdkEventKey GdkEventKey; |
22 | 25 |
23 // The ExtensionKeybindingRegistryGtk is the GTK specialization of the | 26 // The ExtensionKeybindingRegistryGtk is the GTK specialization of the |
24 // ExtensionKeybindingRegistry class that handles turning keyboard shortcuts | 27 // ExtensionKeybindingRegistry class that handles turning keyboard shortcuts |
25 // into events that get sent to the extension. | 28 // into events that get sent to the extension. |
26 | 29 |
27 // ExtensionKeybindingRegistryGtk is a class that handles GTK-specific | 30 // ExtensionKeybindingRegistryGtk is a class that handles GTK-specific |
28 // implemenation of the Extension Keybinding shortcuts (keyboard accelerators). | 31 // implemenation of the Extension Keybinding shortcuts (keyboard accelerators). |
29 // Note: It keeps track of browserAction and pageAction commands, but does not | 32 // Note: It keeps track of browserAction and pageAction commands, but does not |
30 // route the events to them -- that is handled elsewhere. This class registers | 33 // route the events to them -- that is handled elsewhere. This class registers |
31 // the accelerators on behalf of the extensions and routes the commands to them | 34 // the accelerators on behalf of the extensions and routes the commands to them |
32 // via the BrowserEventRouter. | 35 // via the BrowserEventRouter. |
33 class ExtensionKeybindingRegistryGtk | 36 class ExtensionKeybindingRegistryGtk |
34 : public extensions::ExtensionKeybindingRegistry { | 37 : public extensions::ExtensionKeybindingRegistry { |
35 public: | 38 public: |
36 ExtensionKeybindingRegistryGtk(Profile* profile, gfx::NativeWindow window); | 39 ExtensionKeybindingRegistryGtk(Profile* profile, gfx::NativeWindow window); |
37 virtual ~ExtensionKeybindingRegistryGtk(); | 40 virtual ~ExtensionKeybindingRegistryGtk(); |
38 | 41 |
39 // Whether this class has any registered keyboard shortcuts that correspond | 42 // Whether this class has any registered keyboard shortcuts that correspond |
40 // to |event|. | 43 // to |event|. |
41 gboolean HasPriorityHandler(const GdkEventKey* event) const; | 44 gboolean HasPriorityHandler(const GdkEventKey* event) const; |
42 | 45 |
43 protected: | 46 protected: |
44 // Overridden from ExtensionKeybindingRegistry: | 47 // Overridden from ExtensionKeybindingRegistry: |
45 virtual void AddExtensionKeybinding(const Extension* extension) OVERRIDE; | 48 virtual void AddExtensionKeybinding( |
46 virtual void RemoveExtensionKeybinding(const Extension* extension) OVERRIDE; | 49 const extensions::Extension* extension) OVERRIDE; |
| 50 virtual void RemoveExtensionKeybinding( |
| 51 const extensions::Extension* extension) OVERRIDE; |
47 | 52 |
48 private: | 53 private: |
49 // The accelerator handler for when the extension command shortcuts are | 54 // The accelerator handler for when the extension command shortcuts are |
50 // struck. | 55 // struck. |
51 CHROMEG_CALLBACK_3(ExtensionKeybindingRegistryGtk, gboolean, OnGtkAccelerator, | 56 CHROMEG_CALLBACK_3(ExtensionKeybindingRegistryGtk, gboolean, OnGtkAccelerator, |
52 GtkAccelGroup*, GObject*, guint, GdkModifierType); | 57 GtkAccelGroup*, GObject*, guint, GdkModifierType); |
53 | 58 |
54 // Weak pointer to the our profile. Not owned by us. | 59 // Weak pointer to the our profile. Not owned by us. |
55 Profile* profile_; | 60 Profile* profile_; |
56 | 61 |
(...skipping 11 matching lines...) Expand all Loading... |
68 std::pair<std::string, std::string> > EventTargets; | 73 std::pair<std::string, std::string> > EventTargets; |
69 EventTargets event_targets_; | 74 EventTargets event_targets_; |
70 | 75 |
71 // The content notification registrar for listening to extension events. | 76 // The content notification registrar for listening to extension events. |
72 content::NotificationRegistrar registrar_; | 77 content::NotificationRegistrar registrar_; |
73 | 78 |
74 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryGtk); | 79 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistryGtk); |
75 }; | 80 }; |
76 | 81 |
77 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ | 82 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_ |
OLD | NEW |