Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / chrome / browser / ui / extensions / accelerator_priority.cc
blob3ae21d387155435155adb7a4604659621924343b
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.
5 #include "chrome/browser/ui/extensions/accelerator_priority.h"
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"
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;
24 return ui::AcceleratorManager::kHighPriority;
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));