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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.h

Issue 14990002: Make sure keybindings removed don't come back during extension update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moving API calls out of ExtensionPrefs class Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/commands/command_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/commands/command_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698