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" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/chrome_notification_types.h" | |
16 #include "chrome/browser/extensions/api/commands/commands.h" | 15 #include "chrome/browser/extensions/api/commands/commands.h" |
17 #include "chrome/browser/extensions/extension_commands_global_registry.h" | 16 #include "chrome/browser/extensions/extension_commands_global_registry.h" |
18 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 17 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/accelerator_utils.h" | 19 #include "chrome/browser/ui/accelerator_utils.h" |
21 #include "chrome/common/extensions/api/commands/commands_handler.h" | 20 #include "chrome/common/extensions/api/commands/commands_handler.h" |
22 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" | 21 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" |
23 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
24 #include "components/pref_registry/pref_registry_syncable.h" | 23 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
27 #include "extensions/browser/extension_function_registry.h" | 26 #include "extensions/browser/extension_function_registry.h" |
28 #include "extensions/browser/extension_prefs.h" | 27 #include "extensions/browser/extension_prefs.h" |
29 #include "extensions/browser/extension_registry.h" | 28 #include "extensions/browser/extension_registry.h" |
30 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
| 30 #include "extensions/browser/notification_types.h" |
31 #include "extensions/common/feature_switch.h" | 31 #include "extensions/common/feature_switch.h" |
32 #include "extensions/common/manifest_constants.h" | 32 #include "extensions/common/manifest_constants.h" |
33 #include "extensions/common/permissions/permissions_data.h" | 33 #include "extensions/common/permissions/permissions_data.h" |
34 | 34 |
35 namespace extensions { | 35 namespace extensions { |
36 namespace { | 36 namespace { |
37 | 37 |
38 const char kExtension[] = "extension"; | 38 const char kExtension[] = "extension"; |
39 const char kCommandName[] = "command_name"; | 39 const char kCommandName[] = "command_name"; |
40 const char kGlobal[] = "global"; | 40 const char kGlobal[] = "global"; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 scoped_ptr<base::DictionaryValue> suggested_key_prefs( | 279 scoped_ptr<base::DictionaryValue> suggested_key_prefs( |
280 new base::DictionaryValue); | 280 new base::DictionaryValue); |
281 suggested_key_prefs->Set(command_name, command_keys.release()); | 281 suggested_key_prefs->Set(command_name, command_keys.release()); |
282 MergeSuggestedKeyPrefs(extension_id, | 282 MergeSuggestedKeyPrefs(extension_id, |
283 ExtensionPrefs::Get(profile_), | 283 ExtensionPrefs::Get(profile_), |
284 suggested_key_prefs.Pass()); | 284 suggested_key_prefs.Pass()); |
285 | 285 |
286 std::pair<const std::string, const std::string> details = | 286 std::pair<const std::string, const std::string> details = |
287 std::make_pair(extension_id, command_name); | 287 std::make_pair(extension_id, command_name); |
288 content::NotificationService::current()->Notify( | 288 content::NotificationService::current()->Notify( |
289 chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED, | 289 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, |
290 content::Source<Profile>(profile_), | 290 content::Source<Profile>(profile_), |
291 content::Details< | 291 content::Details<std::pair<const std::string, const std::string> >( |
292 std::pair<const std::string, const std::string> >(&details)); | 292 &details)); |
293 | 293 |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 void CommandService::OnExtensionWillBeInstalled( | 297 void CommandService::OnExtensionWillBeInstalled( |
298 content::BrowserContext* browser_context, | 298 content::BrowserContext* browser_context, |
299 const Extension* extension, | 299 const Extension* extension, |
300 bool is_update, | 300 bool is_update, |
301 bool from_ephemeral, | 301 bool from_ephemeral, |
302 const std::string& old_name) { | 302 const std::string& old_name) { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 } | 797 } |
798 | 798 |
799 for (KeysToRemove::const_iterator it = keys_to_remove.begin(); | 799 for (KeysToRemove::const_iterator it = keys_to_remove.begin(); |
800 it != keys_to_remove.end(); ++it) { | 800 it != keys_to_remove.end(); ++it) { |
801 std::string key = *it; | 801 std::string key = *it; |
802 bindings->Remove(key, NULL); | 802 bindings->Remove(key, NULL); |
803 | 803 |
804 std::pair<const std::string, const std::string> details = | 804 std::pair<const std::string, const std::string> details = |
805 std::make_pair(extension_id, command_name); | 805 std::make_pair(extension_id, command_name); |
806 content::NotificationService::current()->Notify( | 806 content::NotificationService::current()->Notify( |
807 chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED, | 807 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, |
808 content::Source<Profile>(profile_), | 808 content::Source<Profile>(profile_), |
809 content::Details< | 809 content::Details<std::pair<const std::string, const std::string> >( |
810 std::pair<const std::string, const std::string> >(&details)); | 810 &details)); |
811 } | 811 } |
812 } | 812 } |
813 | 813 |
814 bool CommandService::GetExtensionActionCommand( | 814 bool CommandService::GetExtensionActionCommand( |
815 const std::string& extension_id, | 815 const std::string& extension_id, |
816 QueryType query_type, | 816 QueryType query_type, |
817 Command* command, | 817 Command* command, |
818 bool* active, | 818 bool* active, |
819 ExtensionCommandType action_type) const { | 819 ExtensionCommandType action_type) const { |
820 const ExtensionSet& extensions = | 820 const ExtensionSet& extensions = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 return true; | 859 return true; |
860 } | 860 } |
861 | 861 |
862 template <> | 862 template <> |
863 void | 863 void |
864 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 864 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
865 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 865 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
866 } | 866 } |
867 | 867 |
868 } // namespace extensions | 868 } // namespace extensions |
OLD | NEW |