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_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
7 | 7 |
8 #include <list> | |
8 #include <map> | 9 #include <map> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
13 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 const ui::Accelerator& accelerator, | 78 const ui::Accelerator& accelerator, |
78 const std::string& command_name) = 0; | 79 const std::string& command_name) = 0; |
79 | 80 |
80 // Make sure all extensions registered have keybindings added. | 81 // Make sure all extensions registered have keybindings added. |
81 void Init(); | 82 void Init(); |
82 | 83 |
83 // Whether to ignore this command. Only browserAction commands and pageAction | 84 // Whether to ignore this command. Only browserAction commands and pageAction |
84 // commands are currently ignored, since they are handled elsewhere. | 85 // commands are currently ignored, since they are handled elsewhere. |
85 bool ShouldIgnoreCommand(const std::string& command) const; | 86 bool ShouldIgnoreCommand(const std::string& command) const; |
86 | 87 |
88 // Fire event targets which the specified accelerator is binding with. Returns | |
89 // true if we can find the appropriate event targets. | |
90 bool NotifyEventTargetsByAccelerator(const ui::Accelerator& accelerator); | |
91 | |
87 // Notifies appropriate parties that a command has been executed. | 92 // Notifies appropriate parties that a command has been executed. |
88 void CommandExecuted(const std::string& extension_id, | 93 void CommandExecuted(const std::string& extension_id, |
89 const std::string& command); | 94 const std::string& command); |
90 | 95 |
91 // Maps an accelerator to a string pair (extension id, command name) for | 96 // Maps an accelerator to a list of string pair (extension id, command name) |
Finnur
2013/11/15 21:10:10
s/pair/pairs/
zhchbin
2013/11/16 01:33:31
Done.
| |
92 // commands that have been registered. This keeps track of the targets for the | 97 // for commands that have been registered. This keeps track of the targets for |
93 // keybinding event (which named command to call in which extension). On GTK, | 98 // the keybinding event (which named command to call in which extension). On |
94 // this map contains registration for pageAction and browserAction commands, | 99 // GTK this map contains registration for pageAction and browserAction |
95 // whereas on other platforms it does not. | 100 // commands, whereas on other platforms it does not. Note that normal |
96 typedef std::map< ui::Accelerator, | 101 // accelerator (which isn't media keys) has only one target, while the media |
97 std::pair<std::string, std::string> > EventTargets; | 102 // keys can have more than one. |
103 typedef std::list<std::pair<std::string, std::string> > TargetList; | |
104 typedef std::map<ui::Accelerator, TargetList> EventTargets; | |
98 EventTargets event_targets_; | 105 EventTargets event_targets_; |
99 | 106 |
100 private: | 107 private: |
101 // Returns true if the |extension| matches our extension filter. | 108 // Returns true if the |extension| matches our extension filter. |
102 bool ExtensionMatchesFilter(const extensions::Extension* extension); | 109 bool ExtensionMatchesFilter(const extensions::Extension* extension); |
103 | 110 |
104 // The content notification registrar for listening to extension events. | 111 // The content notification registrar for listening to extension events. |
105 content::NotificationRegistrar registrar_; | 112 content::NotificationRegistrar registrar_; |
106 | 113 |
107 // Weak pointer to our profile. Not owned by us. | 114 // Weak pointer to our profile. Not owned by us. |
108 Profile* profile_; | 115 Profile* profile_; |
109 | 116 |
110 // What extensions to register keybindings for. | 117 // What extensions to register keybindings for. |
111 ExtensionFilter extension_filter_; | 118 ExtensionFilter extension_filter_; |
112 | 119 |
113 // Weak pointer to our delegate. Not owned by us. Must outlive this class. | 120 // Weak pointer to our delegate. Not owned by us. Must outlive this class. |
114 Delegate* delegate_; | 121 Delegate* delegate_; |
115 | 122 |
116 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); | 123 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); |
117 }; | 124 }; |
118 | 125 |
119 } // namespace extensions | 126 } // namespace extensions |
120 | 127 |
121 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 128 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
OLD | NEW |