Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: chrome/browser/ui/views/extensions/extension_keybinding_registry_views.cc

Issue 360423002: Allow WebContents key handling to supplant extension overrides of the bookmark shortcut (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.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 14 // static
15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( 15 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(
16 bool suspended) { 16 bool suspended) {
17 views::FocusManager::set_shortcut_handling_suspended(suspended); 17 views::FocusManager::set_shortcut_handling_suspended(suspended);
18 } 18 }
19 19
20 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews( 20 ExtensionKeybindingRegistryViews::ExtensionKeybindingRegistryViews(
(...skipping 26 matching lines...) Expand all
47 if (!command_service->GetNamedCommands( 47 if (!command_service->GetNamedCommands(
48 extension->id(), 48 extension->id(),
49 extensions::CommandService::ACTIVE_ONLY, 49 extensions::CommandService::ACTIVE_ONLY,
50 extensions::CommandService::REGULAR, 50 extensions::CommandService::REGULAR,
51 &commands)) 51 &commands))
52 return; 52 return;
53 extensions::CommandMap::const_iterator iter = commands.begin(); 53 extensions::CommandMap::const_iterator iter = commands.begin();
54 for (; iter != commands.end(); ++iter) { 54 for (; iter != commands.end(); ++iter) {
55 if (!command_name.empty() && (iter->second.command_name() != command_name)) 55 if (!command_name.empty() && (iter->second.command_name() != command_name))
56 continue; 56 continue;
57 if (!IsAcceleratorRegistered(iter->second.accelerator())) { 57 const ui::Accelerator &accelerator = iter->second.accelerator();
58 focus_manager_->RegisterAccelerator(iter->second.accelerator(), 58 if (!IsAcceleratorRegistered(accelerator)) {
59 ui::AcceleratorManager::kHighPriority, 59 focus_manager_->RegisterAccelerator(
60 this); 60 accelerator, GetAcceleratorPriority(accelerator, extension), this);
61 } 61 }
62 62
63 AddEventTarget(iter->second.accelerator(), 63 AddEventTarget(accelerator, extension->id(), iter->second.command_name());
64 extension->id(),
65 iter->second.command_name());
66 } 64 }
67 } 65 }
68 66
69 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybindingImpl( 67 void ExtensionKeybindingRegistryViews::RemoveExtensionKeybindingImpl(
70 const ui::Accelerator& accelerator, 68 const ui::Accelerator& accelerator,
71 const std::string& command_name) { 69 const std::string& command_name) {
72 focus_manager_->UnregisterAccelerator(accelerator, this); 70 focus_manager_->UnregisterAccelerator(accelerator, this);
73 } 71 }
74 72
75 bool ExtensionKeybindingRegistryViews::AcceleratorPressed( 73 bool ExtensionKeybindingRegistryViews::AcceleratorPressed(
76 const ui::Accelerator& accelerator) { 74 const ui::Accelerator& accelerator) {
77 return ExtensionKeybindingRegistry::NotifyEventTargets(accelerator); 75 std::string extension_id, command_name;
76 GetFirstTarget(accelerator, &extension_id, &command_name);
77 const ui::AcceleratorManager::HandlerPriority priority =
78 GetAcceleratorPriorityById(accelerator, extension_id, browser_context());
79 // Normal priority shortcuts must be handled via standard browser commands to
80 // be processed at the proper time.
81 return (priority == ui::AcceleratorManager::kHighPriority) &&
82 ExtensionKeybindingRegistry::NotifyEventTargets(accelerator);
78 } 83 }
79 84
80 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const { 85 bool ExtensionKeybindingRegistryViews::CanHandleAccelerators() const {
81 return true; 86 return true;
82 } 87 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/accelerator_priority.cc ('k') | chrome/browser/ui/views/location_bar/page_action_image_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698