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

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

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again; base::File changes conflicted. Created 7 years, 10 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/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/pref_registry_syncable.h"
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" 16 #include "chrome/browser/prefs/scoped_user_pref_update.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/extensions/api/commands/commands_handler.h" 19 #include "chrome/common/extensions/api/commands/commands_handler.h"
19 #include "chrome/common/extensions/extension_manifest_constants.h" 20 #include "chrome/common/extensions/extension_manifest_constants.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
23 24
24 using extensions::Extension; 25 using extensions::Extension;
25 26
26 namespace { 27 namespace {
27 28
28 const char kExtension[] = "extension"; 29 const char kExtension[] = "extension";
29 const char kCommandName[] = "command_name"; 30 const char kCommandName[] = "command_name";
30 31
31 std::string GetPlatformKeybindingKeyForAccelerator( 32 std::string GetPlatformKeybindingKeyForAccelerator(
32 const ui::Accelerator& accelerator) { 33 const ui::Accelerator& accelerator) {
33 return extensions::Command::CommandPlatform() + ":" + 34 return extensions::Command::CommandPlatform() + ":" +
34 UTF16ToUTF8(accelerator.GetShortcutText()); 35 UTF16ToUTF8(accelerator.GetShortcutText());
35 } 36 }
36 37
37 } // namespace 38 } // namespace
38 39
39 namespace extensions { 40 namespace extensions {
40 41
41 // static 42 // static
42 void CommandService::RegisterUserPrefs(PrefServiceSyncable* user_prefs) { 43 void CommandService::RegisterUserPrefs(PrefRegistrySyncable* registry) {
43 user_prefs->RegisterDictionaryPref(prefs::kExtensionCommands, 44 registry->RegisterDictionaryPref(prefs::kExtensionCommands,
44 PrefServiceSyncable::SYNCABLE_PREF); 45 PrefRegistrySyncable::SYNCABLE_PREF);
45 } 46 }
46 47
47 CommandService::CommandService(Profile* profile) 48 CommandService::CommandService(Profile* profile)
48 : profile_(profile) { 49 : profile_(profile) {
49 ManifestHandler::Register(extension_manifest_keys::kCommands, 50 ManifestHandler::Register(extension_manifest_keys::kCommands,
50 make_linked_ptr(new CommandsHandler)); 51 make_linked_ptr(new CommandsHandler));
51 52
52 ExtensionFunctionRegistry::GetInstance()-> 53 ExtensionFunctionRegistry::GetInstance()->
53 RegisterFunction<GetAllCommandsFunction>(); 54 RegisterFunction<GetAllCommandsFunction>();
54 55
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return false; 358 return false;
358 359
359 *command = *requested_command; 360 *command = *requested_command;
360 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) 361 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN)
361 command->set_accelerator(shortcut_assigned); 362 command->set_accelerator(shortcut_assigned);
362 363
363 return true; 364 return true;
364 } 365 }
365 366
366 } // namespace extensions 367 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/commands/command_service.h ('k') | chrome/browser/extensions/api/tabs/tabs_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698