OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/api/commands/commands_handler.h" | 5 #include "chrome/common/extensions/api/commands/commands_handler.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "extensions/common/error_utils.h" | 10 #include "extensions/common/error_utils.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 manifest_errors::kInvalidKeyBindingDictionary, | 83 manifest_errors::kInvalidKeyBindingDictionary, |
84 base::IntToString(command_index)); | 84 base::IntToString(command_index)); |
85 return false; | 85 return false; |
86 } | 86 } |
87 | 87 |
88 scoped_ptr<extensions::Command> binding(new Command()); | 88 scoped_ptr<extensions::Command> binding(new Command()); |
89 if (!binding->Parse(command, iter.key(), command_index, error)) | 89 if (!binding->Parse(command, iter.key(), command_index, error)) |
90 return false; // |error| already set. | 90 return false; // |error| already set. |
91 | 91 |
92 if (binding->accelerator().key_code() != ui::VKEY_UNKNOWN) { | 92 if (binding->accelerator().key_code() != ui::VKEY_UNKNOWN) { |
93 if (++keybindings_found > kMaxCommandsWithKeybindingPerExtension) { | 93 if (binding->accelerator().modifiers() != 0) { |
94 ++keybindings_found; | |
95 } else { | |
96 // We only allow media keys to work without modifiers, and they should | |
Finnur
2014/02/28 11:02:26
s/We only allow media keys/Only media keys are all
zhchbin
2014/02/28 11:45:22
Done.
| |
97 // not count towards the max of four shotcuts per extension. See | |
Finnur
2014/02/28 11:02:26
s/shotcuts/shortcuts/
zhchbin
2014/02/28 11:45:22
Done.
| |
98 // http://crbug.com/329870. | |
Finnur
2014/02/28 11:02:26
The bug doesn't add much to the understanding of t
zhchbin
2014/02/28 11:45:22
Done.
| |
99 DCHECK(binding->accelerator().key_code() == ui::VKEY_MEDIA_NEXT_TRACK || | |
100 binding->accelerator().key_code() == ui::VKEY_MEDIA_PREV_TRACK || | |
101 binding->accelerator().key_code() == ui::VKEY_MEDIA_PLAY_PAUSE || | |
102 binding->accelerator().key_code() == ui::VKEY_MEDIA_STOP); | |
Finnur
2014/02/28 11:02:26
DCHECK(CommandService::IsMediaKey(binding->acceler
zhchbin
2014/02/28 11:45:22
I didn't use CommandService::IsMediaKey because it
Finnur
2014/02/28 12:31:00
I don't see a problem with one additional header i
zhchbin
2014/02/28 12:44:21
Actually, I got the following message when 'git cl
| |
103 } | |
104 | |
105 if (keybindings_found > kMaxCommandsWithKeybindingPerExtension) { | |
94 *error = ErrorUtils::FormatErrorMessageUTF16( | 106 *error = ErrorUtils::FormatErrorMessageUTF16( |
95 manifest_errors::kInvalidKeyBindingTooMany, | 107 manifest_errors::kInvalidKeyBindingTooMany, |
96 base::IntToString(kMaxCommandsWithKeybindingPerExtension)); | 108 base::IntToString(kMaxCommandsWithKeybindingPerExtension)); |
97 return false; | 109 return false; |
98 } | 110 } |
99 } | 111 } |
100 | 112 |
101 std::string command_name = binding->command_name(); | 113 std::string command_name = binding->command_name(); |
102 if (command_name == manifest_values::kBrowserActionCommandEvent) { | 114 if (command_name == manifest_values::kBrowserActionCommandEvent) { |
103 commands_info->browser_action_command.reset(binding.release()); | 115 commands_info->browser_action_command.reset(binding.release()); |
(...skipping 29 matching lines...) Expand all Loading... | |
133 std::string(), | 145 std::string(), |
134 false)); | 146 false)); |
135 } | 147 } |
136 } | 148 } |
137 | 149 |
138 const std::vector<std::string> CommandsHandler::Keys() const { | 150 const std::vector<std::string> CommandsHandler::Keys() const { |
139 return SingleKey(keys::kCommands); | 151 return SingleKey(keys::kCommands); |
140 } | 152 } |
141 | 153 |
142 } // namespace extensions | 154 } // namespace extensions |
OLD | NEW |