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

Unified Diff: chrome/browser/ui/extensions/accelerator_priority.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: address comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/extensions/accelerator_priority.cc
diff --git a/chrome/browser/ui/extensions/accelerator_priority.cc b/chrome/browser/ui/extensions/accelerator_priority.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3ae21d387155435155adb7a4604659621924343b
--- /dev/null
+++ b/chrome/browser/ui/extensions/accelerator_priority.cc
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/extensions/accelerator_priority.h"
+
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/ui/accelerator_utils.h"
+#include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
+#include "extensions/browser/extension_registry.h"
+#include "ui/base/accelerators/accelerator.h"
+
+ui::AcceleratorManager::HandlerPriority GetAcceleratorPriority(
+ const ui::Accelerator& accelerator,
+ const extensions::Extension* extension) {
+ // Extensions overriding the bookmark shortcut need normal priority to
+ // preserve the built-in processing order of the key and not override
+ // WebContents key handling.
+ if (accelerator ==
+ chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE) &&
+ extensions::UIOverrides::RemovesBookmarkShortcut(extension))
+ return ui::AcceleratorManager::kNormalPriority;
+
+ 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.
+}
+
+ui::AcceleratorManager::HandlerPriority GetAcceleratorPriorityById(
+ const ui::Accelerator& accelerator,
+ const std::string& extension_id,
+ content::BrowserContext* browser_context) {
+ return GetAcceleratorPriority(
+ accelerator,
+ extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions().
+ GetByID(extension_id));
+}

Powered by Google App Engine
This is Rietveld 408576698