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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 148 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
149 content::Source<Profile>(profile_)); | 149 content::Source<Profile>(profile_)); |
150 registrar_.Add(this, | 150 registrar_.Add(this, |
151 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 151 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
152 content::Source<Profile>(profile_)); | 152 content::Source<Profile>(profile_)); |
153 } | 153 } |
154 | 154 |
155 CommandService::~CommandService() { | 155 CommandService::~CommandService() { |
156 } | 156 } |
157 | 157 |
158 static base::LazyInstance<ProfileKeyedAPIFactory<CommandService> > | 158 static base::LazyInstance<BrowserContextKeyedAPIFactory<CommandService> > |
159 g_factory = LAZY_INSTANCE_INITIALIZER; | 159 g_factory = LAZY_INSTANCE_INITIALIZER; |
160 | 160 |
161 // static | 161 // static |
162 ProfileKeyedAPIFactory<CommandService>* CommandService::GetFactoryInstance() { | 162 BrowserContextKeyedAPIFactory<CommandService>* |
| 163 CommandService::GetFactoryInstance() { |
163 return g_factory.Pointer(); | 164 return g_factory.Pointer(); |
164 } | 165 } |
165 | 166 |
166 // static | 167 // static |
167 CommandService* CommandService::Get(content::BrowserContext* context) { | 168 CommandService* CommandService::Get(content::BrowserContext* context) { |
168 return ProfileKeyedAPIFactory<CommandService>::GetForProfile(context); | 169 return BrowserContextKeyedAPIFactory<CommandService>::Get(context); |
169 } | 170 } |
170 | 171 |
171 // static | 172 // static |
172 bool CommandService::RemovesBookmarkShortcut( | 173 bool CommandService::RemovesBookmarkShortcut( |
173 const extensions::Extension* extension) { | 174 const extensions::Extension* extension) { |
174 using extensions::SettingsOverrides; | 175 using extensions::SettingsOverrides; |
175 const SettingsOverrides* settings_overrides = | 176 const SettingsOverrides* settings_overrides = |
176 SettingsOverrides::Get(extension); | 177 SettingsOverrides::Get(extension); |
177 | 178 |
178 return settings_overrides && | 179 return settings_overrides && |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 return false; | 592 return false; |
592 | 593 |
593 *command = *requested_command; | 594 *command = *requested_command; |
594 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) | 595 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) |
595 command->set_accelerator(shortcut_assigned); | 596 command->set_accelerator(shortcut_assigned); |
596 | 597 |
597 return true; | 598 return true; |
598 } | 599 } |
599 | 600 |
600 template <> | 601 template <> |
601 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 602 void |
| 603 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
602 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 604 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
603 } | 605 } |
604 | 606 |
605 } // namespace extensions | 607 } // namespace extensions |
OLD | NEW |