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/extension_commands.h" | 5 #include "chrome/common/extensions/extension_commands.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/common/extensions/extension_error_utils.h" | 11 #include "chrome/common/extensions/extension_error_utils.h" |
12 #include "chrome/common/extensions/extension_manifest_constants.h" | 12 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" |
13 | 15 |
14 namespace errors = extension_manifest_errors; | 16 namespace errors = extension_manifest_errors; |
15 namespace keys = extension_manifest_keys; | 17 namespace keys = extension_manifest_keys; |
16 namespace values = extension_manifest_values; | 18 namespace values = extension_manifest_values; |
17 | 19 |
18 namespace extensions { | 20 namespace extensions { |
19 | 21 |
20 Command::Command() {} | 22 Command::Command() {} |
21 | 23 |
22 Command::~Command() {} | 24 Command::~Command() {} |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 errors::kInvalidKeyBindingDescription, | 209 errors::kInvalidKeyBindingDescription, |
208 base::IntToString(index)); | 210 base::IntToString(index)); |
209 return false; | 211 return false; |
210 } | 212 } |
211 } | 213 } |
212 } | 214 } |
213 } | 215 } |
214 return true; | 216 return true; |
215 } | 217 } |
216 | 218 |
| 219 DictionaryValue* Command::ToValue(const Extension* extension, |
| 220 bool active) const { |
| 221 DictionaryValue* extension_data = new DictionaryValue(); |
| 222 |
| 223 string16 command_description; |
| 224 if (command_name() == values::kBrowserActionKeybindingEvent || |
| 225 command_name() == values::kPageActionKeybindingEvent) { |
| 226 command_description = |
| 227 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_GENERIC_ACTIVATE); |
| 228 } else { |
| 229 command_description = description(); |
| 230 } |
| 231 extension_data->SetString("description", command_description); |
| 232 extension_data->SetBoolean("active", active); |
| 233 extension_data->SetString("keybinding", accelerator().GetShortcutText()); |
| 234 |
| 235 return extension_data; |
| 236 } |
| 237 |
217 } // namespace extensions | 238 } // namespace extensions |
OLD | NEW |