| 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_API_COMMANDS_COMMAND_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // |allow_overrides| is false, the keybinding must be free for the change to | 102 // |allow_overrides| is false, the keybinding must be free for the change to |
| 103 // be recorded (as determined by the master list in |user_prefs|). If | 103 // be recorded (as determined by the master list in |user_prefs|). If |
| 104 // |allow_overwrites| is true, any previously recorded keybinding for this | 104 // |allow_overwrites| is true, any previously recorded keybinding for this |
| 105 // |accelerator| will be overwritten. Returns true if the change was | 105 // |accelerator| will be overwritten. Returns true if the change was |
| 106 // successfully recorded. | 106 // successfully recorded. |
| 107 bool AddKeybindingPref(const ui::Accelerator& accelerator, | 107 bool AddKeybindingPref(const ui::Accelerator& accelerator, |
| 108 std::string extension_id, | 108 std::string extension_id, |
| 109 std::string command_name, | 109 std::string command_name, |
| 110 bool allow_overrides); | 110 bool allow_overrides); |
| 111 | 111 |
| 112 // Removes all keybindings for a given extension by its |extension_id|. |
| 113 // |command_name| is optional and if specified, causes only the command with |
| 114 // the name |command_name| to be removed. |
| 115 void RemoveKeybindingPrefs(const std::string& extension_id, |
| 116 const std::string& command_name); |
| 117 |
| 112 // Update the keybinding prefs (for a command with a matching |extension_id| | 118 // Update the keybinding prefs (for a command with a matching |extension_id| |
| 113 // and |command_name|) to |keystroke|. If the command had another key assigned | 119 // and |command_name|) to |keystroke|. If the command had another key assigned |
| 114 // that key assignment will be removed. | 120 // that key assignment will be removed. |
| 115 void UpdateKeybindingPrefs(const std::string& extension_id, | 121 void UpdateKeybindingPrefs(const std::string& extension_id, |
| 116 const std::string& command_name, | 122 const std::string& command_name, |
| 117 const std::string& keystroke); | 123 const std::string& keystroke); |
| 118 | 124 |
| 119 // Finds the shortcut assigned to a command with the name |command_name| | 125 // Finds the shortcut assigned to a command with the name |command_name| |
| 120 // within an extension with id |extension_id|. Returns an empty Accelerator | 126 // within an extension with id |extension_id|. Returns an empty Accelerator |
| 121 // object (with keycode VKEY_UNKNOWN) if no shortcut is assigned or the | 127 // object (with keycode VKEY_UNKNOWN) if no shortcut is assigned or the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 144 SCRIPT_BADGE, | 150 SCRIPT_BADGE, |
| 145 }; | 151 }; |
| 146 | 152 |
| 147 // Assigns initial keybinding for a given |extension|'s page action, browser | 153 // Assigns initial keybinding for a given |extension|'s page action, browser |
| 148 // action and named commands. In each case, if the suggested keybinding is | 154 // action and named commands. In each case, if the suggested keybinding is |
| 149 // free, it will be taken by this extension. If not, that keybinding request | 155 // free, it will be taken by this extension. If not, that keybinding request |
| 150 // is ignored. |user_pref| is the PrefService used to record the new | 156 // is ignored. |user_pref| is the PrefService used to record the new |
| 151 // keybinding assignment. | 157 // keybinding assignment. |
| 152 void AssignInitialKeybindings(const extensions::Extension* extension); | 158 void AssignInitialKeybindings(const extensions::Extension* extension); |
| 153 | 159 |
| 154 // Removes all keybindings for a given extension by its |extension_id|. | |
| 155 // |command_name| is optional and if specified, causes only the command with | |
| 156 // the name |command_name| to be removed. | |
| 157 void RemoveKeybindingPrefs(const std::string& extension_id, | |
| 158 const std::string& command_name); | |
| 159 | |
| 160 bool GetExtensionActionCommand(const std::string& extension_id, | 160 bool GetExtensionActionCommand(const std::string& extension_id, |
| 161 QueryType query_type, | 161 QueryType query_type, |
| 162 extensions::Command* command, | 162 extensions::Command* command, |
| 163 bool* active, | 163 bool* active, |
| 164 ExtensionActionType action_type); | 164 ExtensionActionType action_type); |
| 165 | 165 |
| 166 // The content notification registrar for listening to extension events. | 166 // The content notification registrar for listening to extension events. |
| 167 content::NotificationRegistrar registrar_; | 167 content::NotificationRegistrar registrar_; |
| 168 | 168 |
| 169 // A weak pointer to the profile we are associated with. Not owned by us. | 169 // A weak pointer to the profile we are associated with. Not owned by us. |
| 170 Profile* profile_; | 170 Profile* profile_; |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(CommandService); | 172 DISALLOW_COPY_AND_ASSIGN(CommandService); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace extensions | 175 } // namespace extensions |
| 176 | 176 |
| 177 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 177 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
| OLD | NEW |