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/chrome_version_info.h" // TODO(finnur): Remove. | |
13 #include "extensions/common/error_utils.h" | 12 #include "extensions/common/error_utils.h" |
14 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
15 #include "extensions/common/feature_switch.h" | 14 #include "extensions/common/feature_switch.h" |
16 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
17 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
19 | 18 |
20 namespace extensions { | 19 namespace extensions { |
21 | 20 |
22 namespace errors = manifest_errors; | 21 namespace errors = manifest_errors; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 !suggested_key_string.empty()) { | 440 !suggested_key_string.empty()) { |
442 // If only a single string is provided, it must be default for all. | 441 // If only a single string is provided, it must be default for all. |
443 suggestions[values::kKeybindingPlatformDefault] = suggested_key_string; | 442 suggestions[values::kKeybindingPlatformDefault] = suggested_key_string; |
444 } else { | 443 } else { |
445 suggestions[values::kKeybindingPlatformDefault] = ""; | 444 suggestions[values::kKeybindingPlatformDefault] = ""; |
446 } | 445 } |
447 } | 446 } |
448 | 447 |
449 // Check if this is a global or a regular shortcut. | 448 // Check if this is a global or a regular shortcut. |
450 bool global = false; | 449 bool global = false; |
451 if (FeatureSwitch::global_commands()->IsEnabled() && | 450 if (FeatureSwitch::global_commands()->IsEnabled()) |
452 chrome::VersionInfo::GetChannel() <= chrome::VersionInfo::CHANNEL_DEV) | |
453 command->GetBoolean(keys::kGlobal, &global); | 451 command->GetBoolean(keys::kGlobal, &global); |
454 | 452 |
455 // Normalize the suggestions. | 453 // Normalize the suggestions. |
456 for (SuggestionMap::iterator iter = suggestions.begin(); | 454 for (SuggestionMap::iterator iter = suggestions.begin(); |
457 iter != suggestions.end(); ++iter) { | 455 iter != suggestions.end(); ++iter) { |
458 // Before we normalize Ctrl to Command we must detect when the developer | 456 // Before we normalize Ctrl to Command we must detect when the developer |
459 // specified Command in the Default section, which will work on Mac after | 457 // specified Command in the Default section, which will work on Mac after |
460 // normalization but only fail on other platforms when they try it out on | 458 // normalization but only fail on other platforms when they try it out on |
461 // other platforms, which is not what we want. | 459 // other platforms, which is not what we want. |
462 if (iter->first == values::kKeybindingPlatformDefault && | 460 if (iter->first == values::kKeybindingPlatformDefault && |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 command_description = description(); | 533 command_description = description(); |
536 } | 534 } |
537 extension_data->SetString("description", command_description); | 535 extension_data->SetString("description", command_description); |
538 extension_data->SetBoolean("active", active); | 536 extension_data->SetBoolean("active", active); |
539 extension_data->SetString("keybinding", accelerator().GetShortcutText()); | 537 extension_data->SetString("keybinding", accelerator().GetShortcutText()); |
540 extension_data->SetString("command_name", command_name()); | 538 extension_data->SetString("command_name", command_name()); |
541 extension_data->SetString("extension_id", extension->id()); | 539 extension_data->SetString("extension_id", extension->id()); |
542 extension_data->SetBoolean("global", global()); | 540 extension_data->SetBoolean("global", global()); |
543 extension_data->SetBoolean("extension_action", extension_action); | 541 extension_data->SetBoolean("extension_action", extension_action); |
544 | 542 |
545 if (FeatureSwitch::global_commands()->IsEnabled()) { | 543 if (FeatureSwitch::global_commands()->IsEnabled()) |
546 // TODO(finnur): This is to make sure we don't show the config UI beyond | 544 extension_data->SetBoolean("scope_ui_visible", true); |
547 // dev and will be removed when we launch. | |
548 static bool stable_or_beta = | |
549 chrome::VersionInfo::GetChannel() >= chrome::VersionInfo::CHANNEL_BETA; | |
550 extension_data->SetBoolean("scope_ui_visible", !stable_or_beta); | |
551 } | |
552 | 545 |
553 return extension_data; | 546 return extension_data; |
554 } | 547 } |
555 | 548 |
556 } // namespace extensions | 549 } // namespace extensions |
OLD | NEW |