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/lazy_instance.h" |
7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 10 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/extensions/extension_manifest_constants.h" | 16 #include "chrome/common/extensions/extension_manifest_constants.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
(...skipping 27 matching lines...) Expand all Loading... |
44 : profile_(profile) { | 45 : profile_(profile) { |
45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 46 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
46 content::Source<Profile>(profile)); | 47 content::Source<Profile>(profile)); |
47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
48 content::Source<Profile>(profile)); | 49 content::Source<Profile>(profile)); |
49 } | 50 } |
50 | 51 |
51 CommandService::~CommandService() { | 52 CommandService::~CommandService() { |
52 } | 53 } |
53 | 54 |
| 55 static base::LazyInstance<ProfileKeyedAPIFactory<CommandService> > |
| 56 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 57 |
| 58 // static |
| 59 ProfileKeyedAPIFactory<CommandService>* CommandService::GetFactoryInstance() { |
| 60 return &g_factory.Get(); |
| 61 } |
| 62 |
| 63 // static |
| 64 CommandService* CommandService::Get(Profile* profile) { |
| 65 return ProfileKeyedAPIFactory<CommandService>::GetForProfile(profile); |
| 66 } |
| 67 |
54 bool CommandService::GetBrowserActionCommand( | 68 bool CommandService::GetBrowserActionCommand( |
55 const std::string& extension_id, | 69 const std::string& extension_id, |
56 QueryType type, | 70 QueryType type, |
57 extensions::Command* command, | 71 extensions::Command* command, |
58 bool* active) { | 72 bool* active) { |
59 return GetExtensionActionCommand( | 73 return GetExtensionActionCommand( |
60 extension_id, type, command, active, BROWSER_ACTION); | 74 extension_id, type, command, active, BROWSER_ACTION); |
61 } | 75 } |
62 | 76 |
63 bool CommandService::GetPageActionCommand( | 77 bool CommandService::GetPageActionCommand( |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return false; | 343 return false; |
330 | 344 |
331 *command = *requested_command; | 345 *command = *requested_command; |
332 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) | 346 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) |
333 command->set_accelerator(shortcut_assigned); | 347 command->set_accelerator(shortcut_assigned); |
334 | 348 |
335 return true; | 349 return true; |
336 } | 350 } |
337 | 351 |
338 } // namespace extensions | 352 } // namespace extensions |
OLD | NEW |