| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 prefs::kExtensionCommands, | 141 prefs::kExtensionCommands, |
| 142 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 142 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 143 } | 143 } |
| 144 | 144 |
| 145 CommandService::CommandService(content::BrowserContext* context) | 145 CommandService::CommandService(content::BrowserContext* context) |
| 146 : profile_(Profile::FromBrowserContext(context)) { | 146 : profile_(Profile::FromBrowserContext(context)) { |
| 147 ExtensionFunctionRegistry::GetInstance()-> | 147 ExtensionFunctionRegistry::GetInstance()-> |
| 148 RegisterFunction<GetAllCommandsFunction>(); | 148 RegisterFunction<GetAllCommandsFunction>(); |
| 149 | 149 |
| 150 registrar_.Add(this, | 150 registrar_.Add(this, |
| 151 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 151 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, |
| 152 content::Source<Profile>(profile_)); | 152 content::Source<Profile>(profile_)); |
| 153 registrar_.Add(this, | 153 registrar_.Add(this, |
| 154 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 154 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 155 content::Source<Profile>(profile_)); | 155 content::Source<Profile>(profile_)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 CommandService::~CommandService() { | 158 CommandService::~CommandService() { |
| 159 } | 159 } |
| 160 | 160 |
| 161 static base::LazyInstance<BrowserContextKeyedAPIFactory<CommandService> > | 161 static base::LazyInstance<BrowserContextKeyedAPIFactory<CommandService> > |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 std::pair<const std::string, const std::string> >(&details)); | 318 std::pair<const std::string, const std::string> >(&details)); |
| 319 | 319 |
| 320 return true; | 320 return true; |
| 321 } | 321 } |
| 322 | 322 |
| 323 void CommandService::Observe( | 323 void CommandService::Observe( |
| 324 int type, | 324 int type, |
| 325 const content::NotificationSource& source, | 325 const content::NotificationSource& source, |
| 326 const content::NotificationDetails& details) { | 326 const content::NotificationDetails& details) { |
| 327 switch (type) { | 327 switch (type) { |
| 328 case chrome::NOTIFICATION_EXTENSION_INSTALLED: | 328 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: |
| 329 AssignInitialKeybindings( | 329 AssignInitialKeybindings( |
| 330 content::Details<const InstalledExtensionInfo>(details)->extension); | 330 content::Details<const InstalledExtensionInfo>(details)->extension); |
| 331 break; | 331 break; |
| 332 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 332 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
| 333 RemoveKeybindingPrefs( | 333 RemoveKeybindingPrefs( |
| 334 content::Details<const Extension>(details)->id(), | 334 content::Details<const Extension>(details)->id(), |
| 335 std::string()); | 335 std::string()); |
| 336 break; | 336 break; |
| 337 default: | 337 default: |
| 338 NOTREACHED(); | 338 NOTREACHED(); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 return true; | 622 return true; |
| 623 } | 623 } |
| 624 | 624 |
| 625 template <> | 625 template <> |
| 626 void | 626 void |
| 627 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 627 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
| 628 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 628 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
| 629 } | 629 } |
| 630 | 630 |
| 631 } // namespace extensions | 631 } // namespace extensions |
| OLD | NEW |