Chromium Code Reviews| 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 "extensions/common/error_utils.h" | 12 #include "extensions/common/error_utils.h" |
| 13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/feature_switch.h" | |
| 15 #include "extensions/common/manifest_constants.h" | 14 #include "extensions/common/manifest_constants.h" |
| 16 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 18 | 17 |
| 19 namespace extensions { | 18 namespace extensions { |
| 20 | 19 |
| 21 namespace errors = manifest_errors; | 20 namespace errors = manifest_errors; |
| 22 namespace keys = manifest_keys; | 21 namespace keys = manifest_keys; |
| 23 namespace values = manifest_values; | 22 namespace values = manifest_values; |
| 24 | 23 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 !suggested_key_string.empty()) { | 439 !suggested_key_string.empty()) { |
| 441 // If only a single string is provided, it must be default for all. | 440 // If only a single string is provided, it must be default for all. |
| 442 suggestions[values::kKeybindingPlatformDefault] = suggested_key_string; | 441 suggestions[values::kKeybindingPlatformDefault] = suggested_key_string; |
| 443 } else { | 442 } else { |
| 444 suggestions[values::kKeybindingPlatformDefault] = ""; | 443 suggestions[values::kKeybindingPlatformDefault] = ""; |
| 445 } | 444 } |
| 446 } | 445 } |
| 447 | 446 |
| 448 // Check if this is a global or a regular shortcut. | 447 // Check if this is a global or a regular shortcut. |
| 449 bool global = false; | 448 bool global = false; |
| 450 if (FeatureSwitch::global_commands()->IsEnabled()) | 449 command->GetBoolean(keys::kGlobal, &global); |
| 451 command->GetBoolean(keys::kGlobal, &global); | |
| 452 | 450 |
| 453 // Normalize the suggestions. | 451 // Normalize the suggestions. |
| 454 for (SuggestionMap::iterator iter = suggestions.begin(); | 452 for (SuggestionMap::iterator iter = suggestions.begin(); |
| 455 iter != suggestions.end(); ++iter) { | 453 iter != suggestions.end(); ++iter) { |
| 456 // Before we normalize Ctrl to Command we must detect when the developer | 454 // Before we normalize Ctrl to Command we must detect when the developer |
| 457 // specified Command in the Default section, which will work on Mac after | 455 // specified Command in the Default section, which will work on Mac after |
| 458 // normalization but only fail on other platforms when they try it out on | 456 // normalization but only fail on other platforms when they try it out on |
| 459 // other platforms, which is not what we want. | 457 // other platforms, which is not what we want. |
| 460 if (iter->first == values::kKeybindingPlatformDefault && | 458 if (iter->first == values::kKeybindingPlatformDefault && |
| 461 iter->second.find("Command+") != std::string::npos) { | 459 iter->second.find("Command+") != std::string::npos) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 } else { | 530 } else { |
| 533 command_description = description(); | 531 command_description = description(); |
| 534 } | 532 } |
| 535 extension_data->SetString("description", command_description); | 533 extension_data->SetString("description", command_description); |
| 536 extension_data->SetBoolean("active", active); | 534 extension_data->SetBoolean("active", active); |
| 537 extension_data->SetString("keybinding", accelerator().GetShortcutText()); | 535 extension_data->SetString("keybinding", accelerator().GetShortcutText()); |
| 538 extension_data->SetString("command_name", command_name()); | 536 extension_data->SetString("command_name", command_name()); |
| 539 extension_data->SetString("extension_id", extension->id()); | 537 extension_data->SetString("extension_id", extension->id()); |
| 540 extension_data->SetBoolean("global", global()); | 538 extension_data->SetBoolean("global", global()); |
| 541 extension_data->SetBoolean("extension_action", extension_action); | 539 extension_data->SetBoolean("extension_action", extension_action); |
| 542 | 540 extension_data->SetBoolean("scope_ui_visible", true); |
|
Finnur
2014/06/27 11:10:57
Please remove this boolean assignment as well, and
David Tseng
2014/06/28 14:17:50
Removed ln 267 and 291, and removed the boolean as
| |
| 543 if (FeatureSwitch::global_commands()->IsEnabled()) | |
| 544 extension_data->SetBoolean("scope_ui_visible", true); | |
| 545 | |
| 546 return extension_data; | 541 return extension_data; |
| 547 } | 542 } |
| 548 | 543 |
| 549 } // namespace extensions | 544 } // namespace extensions |
| OLD | NEW |