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

Unified Diff: chrome/common/extensions/api/commands/commands_handler.cc

Issue 180783012: Media Keys should not count towards the max of four shortcuts per extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move IsMediaKey from c/b/e/a/c/command_service.h &&.cc to c/c/e/command.h && .cc Created 6 years, 10 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/common/extensions/api/commands/commands_handler.cc
diff --git a/chrome/common/extensions/api/commands/commands_handler.cc b/chrome/common/extensions/api/commands/commands_handler.cc
index d49a1056240f4ad8f3c57c01532116b8c1eb1b25..8d0788b121ceacf37f640f0e2fb5da74e2b154c9 100644
--- a/chrome/common/extensions/api/commands/commands_handler.cc
+++ b/chrome/common/extensions/api/commands/commands_handler.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/common/extensions/command.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
@@ -90,7 +91,13 @@ bool CommandsHandler::Parse(Extension* extension, base::string16* error) {
return false; // |error| already set.
if (binding->accelerator().key_code() != ui::VKEY_UNKNOWN) {
- if (++keybindings_found > kMaxCommandsWithKeybindingPerExtension) {
+ // Only media keys are allowed to work without modifiers, and because
+ // media keys aren't registered exclusively they should not count towards
+ // the max of four shortcuts per extension.
+ if (!Command::IsMediaKey(binding->accelerator()))
+ ++keybindings_found;
+
+ if (keybindings_found > kMaxCommandsWithKeybindingPerExtension) {
*error = ErrorUtils::FormatErrorMessageUTF16(
manifest_errors::kInvalidKeyBindingTooMany,
base::IntToString(kMaxCommandsWithKeybindingPerExtension));

Powered by Google App Engine
This is Rietveld 408576698