Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/flags_ui/feature_entry.h" | 5 #include "components/flags_ui/feature_entry.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/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "grit/components_strings.h" | 10 #include "grit/components_strings.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 const int kEnableDisableDescriptionIds[] = { | 34 const int kEnableDisableDescriptionIds[] = { |
| 35 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, | 35 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, |
| 36 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, | 36 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, |
| 37 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, | 37 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, |
| 38 }; | 38 }; |
| 39 description_id = kEnableDisableDescriptionIds[index]; | 39 description_id = kEnableDisableDescriptionIds[index]; |
| 40 } else if (type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE) { | 40 } else if (type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE) { |
| 41 if (index == 0) { | 41 if (index == 0) { |
| 42 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT; | 42 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT; |
| 43 } else if (index == 1) { | 43 } else if (index == 1) { |
| 44 // Variation 1: the default enabled variation => "Enabled". | |
| 45 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED; | 44 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED; |
| 46 } else if (index < num_options - 1) { | 45 } else if (index < num_options - 1) { |
| 47 // Variations 2 .. n => "Enabled <description_text>". | 46 // First two options do not correspond to variations. |
|
Alexei Svitkine (slow)
2016/07/13 14:07:13
Nit: I would actually rephrase this slightly, i.e.
| |
| 48 int variation_index = index - 1; | 47 int variation_index = index - 2; |
| 49 return l10n_util::GetStringUTF16(IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED) + | 48 return l10n_util::GetStringUTF16(IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED) + |
| 50 base::ASCIIToUTF16(" ") + | 49 base::ASCIIToUTF16(" ") + |
| 51 base::ASCIIToUTF16( | 50 base::ASCIIToUTF16( |
| 52 feature_variations[variation_index].description_text); | 51 feature_variations[variation_index].description_text); |
| 53 } else { | 52 } else { |
| 54 DCHECK_EQ(num_options - 1, index); | 53 DCHECK_EQ(num_options - 1, index); |
| 55 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED; | 54 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED; |
| 56 } | 55 } |
| 57 } else { | 56 } else { |
| 58 description_id = choices[index].description_id; | 57 description_id = choices[index].description_id; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 79 else | 78 else |
| 80 return FeatureEntry::FeatureState::ENABLED; | 79 return FeatureEntry::FeatureState::ENABLED; |
| 81 } | 80 } |
| 82 | 81 |
| 83 const FeatureEntry::FeatureVariation* FeatureEntry::VariationForOption( | 82 const FeatureEntry::FeatureVariation* FeatureEntry::VariationForOption( |
| 84 int index) const { | 83 int index) const { |
| 85 DCHECK(type == FeatureEntry::FEATURE_VALUE || | 84 DCHECK(type == FeatureEntry::FEATURE_VALUE || |
| 86 type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE); | 85 type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE); |
| 87 DCHECK_LT(index, num_options); | 86 DCHECK_LT(index, num_options); |
| 88 | 87 |
| 89 if (type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE && index > 0 && | 88 if (type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE && index > 1 && |
| 90 index < num_options - 1) { | 89 index < num_options - 1) { |
| 91 // We have no variations for FEATURE_VALUE type. Option at |index| | 90 // We have no variations for FEATURE_VALUE type. Option at |index| |
| 92 // corresponds to variation at |index| - 1 as the first option is "Default". | 91 // corresponds to variation at |index| - 2 as the list starts with "Default" |
| 93 return &feature_variations[index - 1]; | 92 // and "Enabled" (with default parameters). |
| 93 return &feature_variations[index - 2]; | |
| 94 } | 94 } |
| 95 return nullptr; | 95 return nullptr; |
| 96 } | 96 } |
| 97 | 97 |
| 98 namespace testing { | 98 namespace testing { |
| 99 | 99 |
| 100 // WARNING: '@' is also used in the html file. If you update this constant you | 100 // WARNING: '@' is also used in the html file. If you update this constant you |
| 101 // also need to update the html file. | 101 // also need to update the html file. |
| 102 const char kMultiSeparator[] = "@"; | 102 const char kMultiSeparator[] = "@"; |
| 103 | 103 |
| 104 } // namespace testing | 104 } // namespace testing |
| 105 | 105 |
| 106 } // namespace flags_ui | 106 } // namespace flags_ui |
| OLD | NEW |