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

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

Issue 12965009: Remove the limit of number of commands per extension, but keep the limit of 4 shortcuts per extensi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/commands/commands_manifest_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/api/commands/commands_handler.cc
===================================================================
--- chrome/common/extensions/api/commands/commands_handler.cc (revision 190361)
+++ chrome/common/extensions/api/commands/commands_handler.cc (working copy)
@@ -15,9 +15,9 @@
namespace extensions {
namespace {
-// The maximum number of commands (including page action/browser actions) an
-// extension can have.
-const size_t kMaxCommandsPerExtension = 4;
+// The maximum number of commands (including page action/browser actions) with a
+// keybinding an extension can have.
+const int kMaxCommandsWithKeybindingPerExtension = 4;
} // namespace
CommandsInfo::CommandsInfo() {
@@ -76,16 +76,10 @@
return false;
}
- if (dict->size() > kMaxCommandsPerExtension) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- extension_manifest_errors::kInvalidKeyBindingTooMany,
- base::IntToString(kMaxCommandsPerExtension));
- return false;
- }
-
scoped_ptr<CommandsInfo> commands_info(new CommandsInfo);
int command_index = 0;
+ int keybindings_found = 0;
for (DictionaryValue::Iterator iter(*dict); !iter.IsAtEnd();
iter.Advance()) {
++command_index;
@@ -102,6 +96,15 @@
if (!binding->Parse(command, iter.key(), command_index, error))
return false; // |error| already set.
+ if (binding->accelerator().key_code() != ui::VKEY_UNKNOWN) {
+ if (++keybindings_found > kMaxCommandsWithKeybindingPerExtension) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ extension_manifest_errors::kInvalidKeyBindingTooMany,
+ base::IntToString(kMaxCommandsWithKeybindingPerExtension));
+ return false;
+ }
+ }
+
std::string command_name = binding->command_name();
if (command_name == extension_manifest_values::kBrowserActionCommandEvent) {
commands_info->browser_action_command.reset(binding.release());
« no previous file with comments | « no previous file | chrome/common/extensions/api/commands/commands_manifest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698