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

Side by Side Diff: trunk/src/chrome/browser/extensions/api/commands/command_service.cc

Issue 14096026: Revert 194594 "Make sure manifest specified shortcut for Extensi..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 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 | trunk/src/chrome/browser/extensions/extension_keybinding_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
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 #include "chrome/browser/extensions/api/commands/command_service.h" 5 #include "chrome/browser/extensions/api/commands/command_service.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/api/commands/commands.h" 10 #include "chrome/browser/extensions/api/commands/commands.h"
11 #include "chrome/browser/extensions/extension_function_registry.h" 11 #include "chrome/browser/extensions/extension_function_registry.h"
12 #include "chrome/browser/extensions/extension_keybinding_registry.h" 12 #include "chrome/browser/extensions/extension_keybinding_registry.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_system.h" 14 #include "chrome/browser/extensions/extension_system.h"
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" 15 #include "chrome/browser/prefs/scoped_user_pref_update.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/accelerator_utils.h"
18 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/extensions/api/commands/commands_handler.h" 18 #include "chrome/common/extensions/api/commands/commands_handler.h"
20 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
21 #include "components/user_prefs/pref_registry_syncable.h" 20 #include "components/user_prefs/pref_registry_syncable.h"
22 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
24 23
25 using extensions::Extension; 24 using extensions::Extension;
26 25
27 namespace { 26 namespace {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 225 }
227 226
228 void CommandService::AssignInitialKeybindings(const Extension* extension) { 227 void CommandService::AssignInitialKeybindings(const Extension* extension) {
229 const extensions::CommandMap* commands = 228 const extensions::CommandMap* commands =
230 CommandsInfo::GetNamedCommands(extension); 229 CommandsInfo::GetNamedCommands(extension);
231 if (!commands) 230 if (!commands)
232 return; 231 return;
233 232
234 extensions::CommandMap::const_iterator iter = commands->begin(); 233 extensions::CommandMap::const_iterator iter = commands->begin();
235 for (; iter != commands->end(); ++iter) { 234 for (; iter != commands->end(); ++iter) {
236 if (!chrome::IsChromeAccelerator( 235 AddKeybindingPref(iter->second.accelerator(),
237 iter->second.accelerator(), profile_)) { 236 extension->id(),
238 AddKeybindingPref(iter->second.accelerator(), 237 iter->second.command_name(),
239 extension->id(), 238 false); // Overwriting not allowed.
240 iter->second.command_name(),
241 false); // Overwriting not allowed.
242 }
243 } 239 }
244 240
245 const extensions::Command* browser_action_command = 241 const extensions::Command* browser_action_command =
246 CommandsInfo::GetBrowserActionCommand(extension); 242 CommandsInfo::GetBrowserActionCommand(extension);
247 if (browser_action_command) { 243 if (browser_action_command) {
248 if (!chrome::IsChromeAccelerator( 244 AddKeybindingPref(browser_action_command->accelerator(),
249 browser_action_command->accelerator(), profile_)) { 245 extension->id(),
250 AddKeybindingPref(browser_action_command->accelerator(), 246 browser_action_command->command_name(),
251 extension->id(), 247 false); // Overwriting not allowed.
252 browser_action_command->command_name(),
253 false); // Overwriting not allowed.
254 }
255 } 248 }
256 249
257 const extensions::Command* page_action_command = 250 const extensions::Command* page_action_command =
258 CommandsInfo::GetPageActionCommand(extension); 251 CommandsInfo::GetPageActionCommand(extension);
259 if (page_action_command) { 252 if (page_action_command) {
260 if (!chrome::IsChromeAccelerator( 253 AddKeybindingPref(page_action_command->accelerator(),
261 page_action_command->accelerator(), profile_)) { 254 extension->id(),
262 AddKeybindingPref(page_action_command->accelerator(), 255 page_action_command->command_name(),
263 extension->id(), 256 false); // Overwriting not allowed.
264 page_action_command->command_name(),
265 false); // Overwriting not allowed.
266 }
267 } 257 }
268 258
269 const extensions::Command* script_badge_command = 259 const extensions::Command* script_badge_command =
270 CommandsInfo::GetScriptBadgeCommand(extension); 260 CommandsInfo::GetScriptBadgeCommand(extension);
271 if (script_badge_command) { 261 if (script_badge_command) {
272 if (!chrome::IsChromeAccelerator( 262 AddKeybindingPref(script_badge_command->accelerator(),
273 script_badge_command->accelerator(), profile_)) { 263 extension->id(),
274 AddKeybindingPref(script_badge_command->accelerator(), 264 script_badge_command->command_name(),
275 extension->id(), 265 false); // Overwriting not allowed.
276 script_badge_command->command_name(),
277 false); // Overwriting not allowed.
278 }
279 } 266 }
280 } 267 }
281 268
282 void CommandService::RemoveKeybindingPrefs(const std::string& extension_id, 269 void CommandService::RemoveKeybindingPrefs(const std::string& extension_id,
283 const std::string& command_name) { 270 const std::string& command_name) {
284 DictionaryPrefUpdate updater(profile_->GetPrefs(), 271 DictionaryPrefUpdate updater(profile_->GetPrefs(),
285 prefs::kExtensionCommands); 272 prefs::kExtensionCommands);
286 DictionaryValue* bindings = updater.Get(); 273 DictionaryValue* bindings = updater.Get();
287 274
288 typedef std::vector<std::string> KeysToRemove; 275 typedef std::vector<std::string> KeysToRemove;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return false; 353 return false;
367 354
368 *command = *requested_command; 355 *command = *requested_command;
369 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) 356 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN)
370 command->set_accelerator(shortcut_assigned); 357 command->set_accelerator(shortcut_assigned);
371 358
372 return true; 359 return true;
373 } 360 }
374 361
375 } // namespace extensions 362 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | trunk/src/chrome/browser/extensions/extension_keybinding_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698