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

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

Issue 10824307: Port Extension Commands to Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
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/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_keybinding_registry.h" 9 #include "chrome/browser/extensions/extension_keybinding_registry.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (accelerator.key_code() == ui::VKEY_UNKNOWN) 118 if (accelerator.key_code() == ui::VKEY_UNKNOWN)
119 return false; 119 return false;
120 120
121 DictionaryPrefUpdate updater(profile_->GetPrefs(), 121 DictionaryPrefUpdate updater(profile_->GetPrefs(),
122 prefs::kExtensionCommands); 122 prefs::kExtensionCommands);
123 DictionaryValue* bindings = updater.Get(); 123 DictionaryValue* bindings = updater.Get();
124 124
125 std::string key = GetPlatformKeybindingKeyForAccelerator(accelerator); 125 std::string key = GetPlatformKeybindingKeyForAccelerator(accelerator);
126 126
127 if (!allow_overrides && bindings->HasKey(key)) 127 if (!allow_overrides && bindings->HasKey(key))
128 return false; // Already taken. 128 return false; // Already taken.
129 129
130 DictionaryValue* keybinding = new DictionaryValue(); 130 DictionaryValue* keybinding = new DictionaryValue();
131 keybinding->SetString(kExtension, extension_id); 131 keybinding->SetString(kExtension, extension_id);
132 keybinding->SetString(kCommandName, command_name); 132 keybinding->SetString(kCommandName, command_name);
133 133
134 bindings->Set(key, keybinding); 134 bindings->Set(key, keybinding);
135 135
136 std::pair<const std::string, const std::string> details = 136 std::pair<const std::string, const std::string> details =
137 std::make_pair(extension_id, command_name); 137 std::make_pair(extension_id, command_name);
138 content::NotificationService::current()->Notify( 138 content::NotificationService::current()->Notify(
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return false; 327 return false;
328 328
329 *command = *requested_command; 329 *command = *requested_command;
330 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) 330 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN)
331 command->set_accelerator(shortcut_assigned); 331 command->set_accelerator(shortcut_assigned);
332 332
333 return true; 333 return true;
334 } 334 }
335 335
336 } // namespace extensions 336 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698