blob: b7556970cad778a9cef605e67d8c6bd5dcfa802e [file] [log] [blame]
sdefresne246c5642015-11-16 21:47:291// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/flags_ui/feature_entry.h"
6
7#include "base/logging.h"
8#include "base/strings/string_number_conversions.h"
9#include "grit/components_strings.h"
10#include "ui/base/l10n/l10n_util.h"
11
12namespace flags_ui {
13
14std::string FeatureEntry::NameForChoice(int index) const {
15 DCHECK(type == FeatureEntry::MULTI_VALUE ||
16 type == FeatureEntry::ENABLE_DISABLE_VALUE ||
17 type == FeatureEntry::FEATURE_VALUE);
18 DCHECK_LT(index, num_choices);
19 return std::string(internal_name) + testing::kMultiSeparator +
20 base::IntToString(index);
21}
22
23base::string16 FeatureEntry::DescriptionForChoice(int index) const {
24 DCHECK(type == FeatureEntry::MULTI_VALUE ||
25 type == FeatureEntry::ENABLE_DISABLE_VALUE ||
26 type == FeatureEntry::FEATURE_VALUE);
27 DCHECK_LT(index, num_choices);
28 int description_id;
29 if (type == FeatureEntry::ENABLE_DISABLE_VALUE ||
30 type == FeatureEntry::FEATURE_VALUE) {
31 const int kEnableDisableDescriptionIds[] = {
32 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
33 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
34 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
35 };
36 description_id = kEnableDisableDescriptionIds[index];
37 } else {
38 description_id = choices[index].description_id;
39 }
40 return l10n_util::GetStringUTF16(description_id);
41}
42
43namespace testing {
44
45// WARNING: '@' is also used in the html file. If you update this constant you
46// also need to update the html file.
47const char kMultiSeparator[] = "@";
48
49} // namespace testing
50
51} // namespace flags_ui