| 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" | 8 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 9 #include "chrome/browser/extensions/browser_event_router.h" | |
| 10 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 14 #include "ui/views/focus/focus_manager.h" | 13 #include "ui/views/focus/focus_manager.h" |
| 15 | 14 |
| 16 // static | 15 // static |
| 17 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | 16 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( |
| 18 bool suspended) { | 17 bool suspended) { |
| 19 views::FocusManager::set_shortcut_handling_suspended(suspended); | 18 views::FocusManager::set_shortcut_handling_suspended(suspended); |
| 20 } | 19 } |
| 21 | 20 |
| 22 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( | 21 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( |
| 23 Profile* profile, | 22 Profile* profile, |
| 24 views::FocusManager* focus_manager, | 23 views::FocusManager* focus_manager, |
| 25 ExtensionFilter extension_filter) | 24 ExtensionFilter extension_filter, |
| 26 : ExtensionKeybindingRegistry(profile, extension_filter), | 25 Delegate* delegate) |
| 26 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), |
| 27 profile_(profile), | 27 profile_(profile), |
| 28 focus_manager_(focus_manager) { | 28 focus_manager_(focus_manager) { |
| 29 Init(); | 29 Init(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 ExtensionKeybindingRegistryViews::~ExtensionKeybindingRegistryViews() { | 32 ExtensionKeybindingRegistryViews::~ExtensionKeybindingRegistryViews() { |
| 33 EventTargets::const_iterator iter; | 33 EventTargets::const_iterator iter; |
| 34 for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) | 34 for (iter = event_targets_.begin(); iter != event_targets_.end(); ++iter) |
| 35 focus_manager_->UnregisterAccelerator(iter->first, this); | 35 focus_manager_->UnregisterAccelerator(iter->first, this); |
| 36 } | 36 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 focus_manager_->UnregisterAccelerator(iter->first, this); | 81 focus_manager_->UnregisterAccelerator(iter->first, this); |
| 82 | 82 |
| 83 EventTargets::iterator old = iter++; | 83 EventTargets::iterator old = iter++; |
| 84 event_targets_.erase(old); | 84 event_targets_.erase(old); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( | 88 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( |
| 89 const ui::Accelerator& accelerator) { | 89 const ui::Accelerator& accelerator) { |
| 90 ExtensionService* service = profile_->GetExtensionService(); | |
| 91 | |
| 92 EventTargets::iterator it = event_targets_.find(accelerator); | 90 EventTargets::iterator it = event_targets_.find(accelerator); |
| 93 if (it == event_targets_.end()) { | 91 if (it == event_targets_.end()) { |
| 94 NOTREACHED(); // Shouldn't get this event for something not registered. | 92 NOTREACHED(); // Shouldn't get this event for something not registered. |
| 95 return false; | 93 return false; |
| 96 } | 94 } |
| 97 | 95 |
| 98 service->browser_event_router()->CommandExecuted( | 96 CommandExecuted(it->second.first, it->second.second); |
| 99 profile_, it->second.first, it->second.second); | |
| 100 | 97 |
| 101 return true; | 98 return true; |
| 102 } | 99 } |
| 103 | 100 |
| 104 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { | 101 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { |
| 105 return true; | 102 return true; |
| 106 } | 103 } |
| OLD | NEW |