| 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 17 matching lines...) Expand all Loading... |
| 28 const ui::Accelerator& accelerator) { | 28 const ui::Accelerator& accelerator) { |
| 29 return extensions::Command::CommandPlatform() + ":" + | 29 return extensions::Command::CommandPlatform() + ":" + |
| 30 UTF16ToUTF8(accelerator.GetShortcutText()); | 30 UTF16ToUTF8(accelerator.GetShortcutText()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 namespace extensions { | 35 namespace extensions { |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 void CommandService::RegisterUserPrefs( | 38 void CommandService::RegisterUserPrefs(PrefServiceSyncable* user_prefs) { |
| 39 PrefService* user_prefs) { | 39 user_prefs->RegisterDictionaryPref(prefs::kExtensionCommands, |
| 40 user_prefs->RegisterDictionaryPref(prefs::kExtensionCommands, | 40 PrefServiceSyncable::SYNCABLE_PREF); |
| 41 PrefService::SYNCABLE_PREF); | |
| 42 } | 41 } |
| 43 | 42 |
| 44 CommandService::CommandService(Profile* profile) | 43 CommandService::CommandService(Profile* profile) |
| 45 : profile_(profile) { | 44 : profile_(profile) { |
| 46 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 47 content::Source<Profile>(profile)); | 46 content::Source<Profile>(profile)); |
| 48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 49 content::Source<Profile>(profile)); | 48 content::Source<Profile>(profile)); |
| 50 } | 49 } |
| 51 | 50 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return false; | 329 return false; |
| 331 | 330 |
| 332 *command = *requested_command; | 331 *command = *requested_command; |
| 333 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) | 332 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) |
| 334 command->set_accelerator(shortcut_assigned); | 333 command->set_accelerator(shortcut_assigned); |
| 335 | 334 |
| 336 return true; | 335 return true; |
| 337 } | 336 } |
| 338 | 337 |
| 339 } // namespace extensions | 338 } // namespace extensions |
| OLD | NEW |