OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command.h" | 5 #include "chrome/common/extensions/command.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_manifest_constants.h" | |
14 #include "extensions/common/error_utils.h" | 13 #include "extensions/common/error_utils.h" |
| 14 #include "extensions/common/manifest_constants.h" |
15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 | 17 |
18 namespace errors = extension_manifest_errors; | 18 namespace extensions { |
19 namespace keys = extensions::manifest_keys; | |
20 namespace values = extension_manifest_values; | |
21 | 19 |
22 using extensions::ErrorUtils; | 20 namespace errors = manifest_errors; |
23 using extensions::Command; | 21 namespace keys = manifest_keys; |
| 22 namespace values = manifest_values; |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 static const char kMissing[] = "Missing"; | 26 static const char kMissing[] = "Missing"; |
28 | 27 |
29 static const char kCommandKeyNotSupported[] = | 28 static const char kCommandKeyNotSupported[] = |
30 "Command key is not supported. Note: Ctrl means Command on Mac"; | 29 "Command key is not supported. Note: Ctrl means Command on Mac"; |
31 | 30 |
32 bool IsNamedCommand(const std::string& command_name) { | 31 bool IsNamedCommand(const std::string& command_name) { |
33 return command_name != values::kPageActionCommandEvent && | 32 return command_name != values::kPageActionCommandEvent && |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (tokens[i] == values::kKeyCtrl) | 243 if (tokens[i] == values::kKeyCtrl) |
245 tokens[i] = values::kKeyCommand; | 244 tokens[i] = values::kKeyCommand; |
246 else if (tokens[i] == values::kKeyMacCtrl) | 245 else if (tokens[i] == values::kKeyMacCtrl) |
247 tokens[i] = values::kKeyCtrl; | 246 tokens[i] = values::kKeyCtrl; |
248 } | 247 } |
249 return JoinString(tokens, '+'); | 248 return JoinString(tokens, '+'); |
250 } | 249 } |
251 | 250 |
252 } // namespace | 251 } // namespace |
253 | 252 |
254 namespace extensions { | |
255 | |
256 Command::Command() {} | 253 Command::Command() {} |
257 | 254 |
258 Command::Command(const std::string& command_name, | 255 Command::Command(const std::string& command_name, |
259 const string16& description, | 256 const string16& description, |
260 const std::string& accelerator) | 257 const std::string& accelerator) |
261 : command_name_(command_name), | 258 : command_name_(command_name), |
262 description_(description) { | 259 description_(description) { |
263 string16 error; | 260 string16 error; |
264 accelerator_ = ParseImpl(accelerator, CommandPlatform(), 0, | 261 accelerator_ = ParseImpl(accelerator, CommandPlatform(), 0, |
265 IsNamedCommand(command_name), &error); | 262 IsNamedCommand(command_name), &error); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 extension_data->SetString("description", command_description); | 515 extension_data->SetString("description", command_description); |
519 extension_data->SetBoolean("active", active); | 516 extension_data->SetBoolean("active", active); |
520 extension_data->SetString("keybinding", accelerator().GetShortcutText()); | 517 extension_data->SetString("keybinding", accelerator().GetShortcutText()); |
521 extension_data->SetString("command_name", command_name()); | 518 extension_data->SetString("command_name", command_name()); |
522 extension_data->SetString("extension_id", extension->id()); | 519 extension_data->SetString("extension_id", extension->id()); |
523 | 520 |
524 return extension_data; | 521 return extension_data; |
525 } | 522 } |
526 | 523 |
527 } // namespace extensions | 524 } // namespace extensions |
OLD | NEW |