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 #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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 ui::Accelerator accelerator = Command::StringToAccelerator(keystroke); | 163 ui::Accelerator accelerator = Command::StringToAccelerator(keystroke); |
164 AddKeybindingPref(accelerator, extension_id, command_name, true); | 164 AddKeybindingPref(accelerator, extension_id, command_name, true); |
165 } | 165 } |
166 | 166 |
167 ui::Accelerator CommandService::FindShortcutForCommand( | 167 ui::Accelerator CommandService::FindShortcutForCommand( |
168 const std::string& extension_id, const std::string& command) { | 168 const std::string& extension_id, const std::string& command) { |
169 const DictionaryValue* bindings = | 169 const DictionaryValue* bindings = |
170 profile_->GetPrefs()->GetDictionary(prefs::kExtensionKeybindings); | 170 profile_->GetPrefs()->GetDictionary(prefs::kExtensionKeybindings); |
171 for (DictionaryValue::key_iterator it = bindings->begin_keys(); | 171 for (DictionaryValue::key_iterator it = bindings->begin_keys(); |
172 it != bindings->end_keys(); ++it) { | 172 it != bindings->end_keys(); ++it) { |
173 DictionaryValue* item = NULL; | 173 const DictionaryValue* item = NULL; |
174 bindings->GetDictionary(*it, &item); | 174 bindings->GetDictionary(*it, &item); |
175 | 175 |
176 std::string extension; | 176 std::string extension; |
177 item->GetString(kExtension, &extension); | 177 item->GetString(kExtension, &extension); |
178 if (extension != extension_id) | 178 if (extension != extension_id) |
179 continue; | 179 continue; |
180 std::string command_name; | 180 std::string command_name; |
181 item->GetString(kCommandName, &command_name); | 181 item->GetString(kCommandName, &command_name); |
182 if (command != command_name) | 182 if (command != command_name) |
183 continue; | 183 continue; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return false; | 296 return false; |
297 | 297 |
298 *command = *requested_command; | 298 *command = *requested_command; |
299 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) | 299 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) |
300 command->set_accelerator(shortcut_assigned); | 300 command->set_accelerator(shortcut_assigned); |
301 | 301 |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 } // namespace extensions | 305 } // namespace extensions |
OLD | NEW |