Chromium Code Reviews| 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/extension_keybinding_registry.h" | 8 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/extensions/accelerator_priority.h" | 10 #include "chrome/browser/ui/extensions/accelerator_priority.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "ui/views/focus/focus_manager.h" | 12 #include "ui/views/focus/focus_manager.h" |
| 13 | 13 |
| 14 // static | |
| 15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | |
| 16 bool suspended) { | |
| 17 views::FocusManager::set_shortcut_handling_suspended(suspended); | |
| 18 } | |
| 19 | |
| 20 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( | 14 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( |
| 21 Profile* profile, | 15 Profile* profile, |
| 22 views::FocusManager* focus_manager, | 16 views::FocusManager* focus_manager, |
| 23 ExtensionFilter extension_filter, | 17 ExtensionFilter extension_filter, |
| 24 Delegate* delegate) | 18 Delegate* delegate) |
| 25 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), | 19 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), |
| 26 profile_(profile), | 20 profile_(profile), |
| 27 focus_manager_(focus_manager) { | 21 focus_manager_(focus_manager), |
| 22 shortcut_handling_suspended_callback_(base::Bind( | |
| 23 &ExtensionKeybindingRegistry::IsShortcutHandlingSuspended)) { | |
| 28 Init(); | 24 Init(); |
| 25 focus_manager_->set_shortcut_handling_suspended_callback( | |
|
Devlin
2015/01/14 21:55:18
Finnur and Scott know this code better, so I'll de
Andre
2015/01/14 22:01:58
Thanks!
I explored this idea earlier, but didn't k
Devlin
2015/01/15 00:22:08
So, you don't need _all_ the registry instances -
Finnur
2015/01/15 15:02:34
I *think* you are right. :)
The keys go through t
Devlin
2015/01/15 16:36:51
Was more a question for Andre. :) The ExtensionKe
Andre
2015/01/15 22:26:12
Thanks!
registry_for_active_window() is the missin
| |
| 26 &shortcut_handling_suspended_callback_); | |
| 29 } | 27 } |
| 30 | 28 |
| 31 ExtensionKeybindingRegistryViews::~ExtensionKeybindingRegistryViews() { | 29 ExtensionKeybindingRegistryViews::~ExtensionKeybindingRegistryViews() { |
| 32 focus_manager_->UnregisterAccelerators(this); | 30 focus_manager_->UnregisterAccelerators(this); |
| 31 focus_manager_->set_shortcut_handling_suspended_callback(nullptr); | |
| 33 } | 32 } |
| 34 | 33 |
| 35 void ExtensionKeybindingRegistryViews::AddExtensionKeybindings( | 34 void ExtensionKeybindingRegistryViews::AddExtensionKeybindings( |
| 36 const extensions::Extension* extension, | 35 const extensions::Extension* extension, |
| 37 const std::string& command_name) { | 36 const std::string& command_name) { |
| 38 // This object only handles named commands, not browser/page actions. | 37 // This object only handles named commands, not browser/page actions. |
| 39 if (ShouldIgnoreCommand(command_name)) | 38 if (ShouldIgnoreCommand(command_name)) |
| 40 return; | 39 return; |
| 41 | 40 |
| 42 extensions::CommandService* command_service = | 41 extensions::CommandService* command_service = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 GetAcceleratorPriorityById(accelerator, extension_id, browser_context()); | 77 GetAcceleratorPriorityById(accelerator, extension_id, browser_context()); |
| 79 // Normal priority shortcuts must be handled via standard browser commands to | 78 // Normal priority shortcuts must be handled via standard browser commands to |
| 80 // be processed at the proper time. | 79 // be processed at the proper time. |
| 81 return (priority == ui::AcceleratorManager::kHighPriority) && | 80 return (priority == ui::AcceleratorManager::kHighPriority) && |
| 82 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); | 81 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); |
| 83 } | 82 } |
| 84 | 83 |
| 85 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { | 84 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { |
| 86 return true; | 85 return true; |
| 87 } | 86 } |
| OLD | NEW |