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/ui/views/extensions/extension_keybinding_registry_views
.h" | 5 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/commands/command_service.h" | 7 #include "chrome/browser/extensions/api/commands/command_service.h" |
8 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | |
9 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 8 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
13 #include "ui/views/focus/focus_manager.h" | 12 #include "ui/views/focus/focus_manager.h" |
14 | 13 |
15 // static | 14 // static |
16 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | 15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( |
17 bool suspended) { | 16 bool suspended) { |
18 views::FocusManager::set_shortcut_handling_suspended(suspended); | 17 views::FocusManager::set_shortcut_handling_suspended(suspended); |
(...skipping 17 matching lines...) Expand all Loading... |
36 } | 35 } |
37 | 36 |
38 void ExtensionKeybindingRegistryViews::AddExtensionKeybinding( | 37 void ExtensionKeybindingRegistryViews::AddExtensionKeybinding( |
39 const extensions::Extension* extension, | 38 const extensions::Extension* extension, |
40 const std::string& command_name) { | 39 const std::string& command_name) { |
41 // This object only handles named commands, not browser/page actions. | 40 // This object only handles named commands, not browser/page actions. |
42 if (ShouldIgnoreCommand(command_name)) | 41 if (ShouldIgnoreCommand(command_name)) |
43 return; | 42 return; |
44 | 43 |
45 extensions::CommandService* command_service = | 44 extensions::CommandService* command_service = |
46 extensions::CommandServiceFactory::GetForProfile(profile_); | 45 extensions::CommandService::Get(profile_); |
47 // Add all the active keybindings (except page actions and browser actions, | 46 // Add all the active keybindings (except page actions and browser actions, |
48 // which are handled elsewhere). | 47 // which are handled elsewhere). |
49 extensions::CommandMap commands; | 48 extensions::CommandMap commands; |
50 if (!command_service->GetNamedCommands( | 49 if (!command_service->GetNamedCommands( |
51 extension->id(), extensions::CommandService::ACTIVE_ONLY, &commands)) | 50 extension->id(), extensions::CommandService::ACTIVE_ONLY, &commands)) |
52 return; | 51 return; |
53 extensions::CommandMap::const_iterator iter = commands.begin(); | 52 extensions::CommandMap::const_iterator iter = commands.begin(); |
54 for (; iter != commands.end(); ++iter) { | 53 for (; iter != commands.end(); ++iter) { |
55 if (!command_name.empty() && (iter->second.command_name() != command_name)) | 54 if (!command_name.empty() && (iter->second.command_name() != command_name)) |
56 continue; | 55 continue; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 93 } |
95 | 94 |
96 CommandExecuted(it->second.first, it->second.second); | 95 CommandExecuted(it->second.first, it->second.second); |
97 | 96 |
98 return true; | 97 return true; |
99 } | 98 } |
100 | 99 |
101 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { | 100 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { |
102 return true; | 101 return true; |
103 } | 102 } |
OLD | NEW |