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/extension_keybinding_registry.h" | 5 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 8 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/extensions/command.h" | 10 #include "chrome/common/extensions/command.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 ExtensionKeybindingRegistry::ExtensionKeybindingRegistry( | 24 ExtensionKeybindingRegistry::ExtensionKeybindingRegistry( |
25 content::BrowserContext* context, | 25 content::BrowserContext* context, |
26 ExtensionFilter extension_filter, | 26 ExtensionFilter extension_filter, |
27 Delegate* delegate) | 27 Delegate* delegate) |
28 : browser_context_(context), | 28 : browser_context_(context), |
29 extension_filter_(extension_filter), | 29 extension_filter_(extension_filter), |
30 delegate_(delegate), | 30 delegate_(delegate), |
31 extension_registry_observer_(this) { | 31 extension_registry_observer_(this), |
| 32 shortcut_handling_suspended_(false) { |
32 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); | 33 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); |
33 | 34 |
34 Profile* profile = Profile::FromBrowserContext(browser_context_); | 35 Profile* profile = Profile::FromBrowserContext(browser_context_); |
35 registrar_.Add(this, | 36 registrar_.Add(this, |
36 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, | 37 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, |
37 content::Source<Profile>(profile->GetOriginalProfile())); | 38 content::Source<Profile>(profile->GetOriginalProfile())); |
38 registrar_.Add(this, | 39 registrar_.Add(this, |
39 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, | 40 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, |
40 content::Source<Profile>(profile->GetOriginalProfile())); | 41 content::Source<Profile>(profile->GetOriginalProfile())); |
41 } | 42 } |
42 | 43 |
43 ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() { | 44 ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() { |
44 } | 45 } |
45 | 46 |
| 47 void ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(bool suspended) { |
| 48 shortcut_handling_suspended_ = suspended; |
| 49 OnShortcutHandlingSuspended(suspended); |
| 50 } |
| 51 |
46 void ExtensionKeybindingRegistry::RemoveExtensionKeybinding( | 52 void ExtensionKeybindingRegistry::RemoveExtensionKeybinding( |
47 const Extension* extension, | 53 const Extension* extension, |
48 const std::string& command_name) { | 54 const std::string& command_name) { |
49 EventTargets::iterator it = event_targets_.begin(); | 55 EventTargets::iterator it = event_targets_.begin(); |
50 while (it != event_targets_.end()) { | 56 while (it != event_targets_.end()) { |
51 TargetList& target_list = it->second; | 57 TargetList& target_list = it->second; |
52 TargetList::iterator target = target_list.begin(); | 58 TargetList::iterator target = target_list.begin(); |
53 while (target != target_list.end()) { | 59 while (target != target_list.end()) { |
54 if (target->first == extension->id() && | 60 if (target->first == extension->id() && |
55 (command_name.empty() || command_name == target->second)) | 61 (command_name.empty() || command_name == target->second)) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 if (extension_id.empty() || it->first == extension_id) { | 254 if (extension_id.empty() || it->first == extension_id) { |
249 CommandExecuted(it->first, it->second); | 255 CommandExecuted(it->first, it->second); |
250 executed = true; | 256 executed = true; |
251 } | 257 } |
252 } | 258 } |
253 | 259 |
254 return executed; | 260 return executed; |
255 } | 261 } |
256 | 262 |
257 } // namespace extensions | 263 } // namespace extensions |
OLD | NEW |