OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/extensions/accelerator_priority.h" | |
6 | |
7 #include "chrome/app/chrome_command_ids.h" | |
8 #include "chrome/browser/ui/accelerator_utils.h" | |
9 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" | |
10 #include "extensions/browser/extension_registry.h" | |
11 #include "ui/base/accelerators/accelerator.h" | |
12 | |
13 ui::AcceleratorManager::HandlerPriority GetAcceleratorPriority( | |
14 const ui::Accelerator& accelerator, | |
15 const extensions::Extension* extension) { | |
16 // Extensions overriding the bookmark shortcut need normal priority to | |
17 // preserve the built-in processing order of the key and not override | |
18 // WebContents key handling. | |
19 if (accelerator == | |
20 chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE) && | |
21 extensions::UIOverrides::RemovesBookmarkShortcut(extension)) | |
22 return ui::AcceleratorManager::kNormalPriority; | |
23 | |
24 return ui::AcceleratorManager::kHighPriority; | |
Peter Kasting
2014/07/07 23:47:10
It seems surprising to me that IDC_BOOKMARK_PAGE i
Finnur
2014/07/08 10:35:02
The intent here is to allow extensions to override
Peter Kasting
2014/07/08 19:30:36
Cool. This is helpful info. Consider putting som
Mike Wittman
2014/07/08 22:15:21
Added a comment in the header.
| |
25 } | |
26 | |
27 ui::AcceleratorManager::HandlerPriority GetAcceleratorPriorityById( | |
28 const ui::Accelerator& accelerator, | |
29 const std::string& extension_id, | |
30 content::BrowserContext* browser_context) { | |
31 return GetAcceleratorPriority( | |
32 accelerator, | |
33 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions(). | |
34 GetByID(extension_id)); | |
35 } | |
OLD | NEW |