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

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

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/pref_registry_syncable.h"
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" 16 #include "chrome/browser/prefs/scoped_user_pref_update.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/extensions/api/commands/commands_handler.h" 19 #include "chrome/common/extensions/api/commands/commands_handler.h"
20 #include "chrome/common/extensions/extension_manifest_constants.h"
21 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.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 {
28 27
29 const char kExtension[] = "extension"; 28 const char kExtension[] = "extension";
30 const char kCommandName[] = "command_name"; 29 const char kCommandName[] = "command_name";
31 30
32 std::string GetPlatformKeybindingKeyForAccelerator( 31 std::string GetPlatformKeybindingKeyForAccelerator(
33 const ui::Accelerator& accelerator) { 32 const ui::Accelerator& accelerator) {
34 return extensions::Command::CommandPlatform() + ":" + 33 return extensions::Command::CommandPlatform() + ":" +
35 UTF16ToUTF8(accelerator.GetShortcutText()); 34 UTF16ToUTF8(accelerator.GetShortcutText());
36 } 35 }
37 36
38 } // namespace 37 } // namespace
39 38
40 namespace extensions { 39 namespace extensions {
41 40
42 // static 41 // static
43 void CommandService::RegisterUserPrefs(PrefRegistrySyncable* registry) { 42 void CommandService::RegisterUserPrefs(PrefRegistrySyncable* registry) {
44 registry->RegisterDictionaryPref(prefs::kExtensionCommands, 43 registry->RegisterDictionaryPref(prefs::kExtensionCommands,
45 PrefRegistrySyncable::SYNCABLE_PREF); 44 PrefRegistrySyncable::SYNCABLE_PREF);
46 } 45 }
47 46
48 CommandService::CommandService(Profile* profile) 47 CommandService::CommandService(Profile* profile)
49 : profile_(profile) { 48 : profile_(profile) {
50 ManifestHandler::Register(extension_manifest_keys::kCommands, 49 (new CommandsHandler)->Register();
51 make_linked_ptr(new CommandsHandler));
52 50
53 ExtensionFunctionRegistry::GetInstance()-> 51 ExtensionFunctionRegistry::GetInstance()->
54 RegisterFunction<GetAllCommandsFunction>(); 52 RegisterFunction<GetAllCommandsFunction>();
55 53
56 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
57 content::Source<Profile>(profile)); 55 content::Source<Profile>(profile));
58 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 56 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
59 content::Source<Profile>(profile)); 57 content::Source<Profile>(profile));
60 } 58 }
61 59
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return false; 356 return false;
359 357
360 *command = *requested_command; 358 *command = *requested_command;
361 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) 359 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN)
362 command->set_accelerator(shortcut_assigned); 360 command->set_accelerator(shortcut_assigned);
363 361
364 return true; 362 return true;
365 } 363 }
366 364
367 } // namespace extensions 365 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698