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