summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-11-16 13:47:29 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-16 21:48:55 +0000
commit246c564da980b3dbbd0a062688ec65539b4b2c35 (patch)
tree81c60249e1062a54fc42c70c9fe2b95ee8bdc0a8
parent049217061cbe1c5bfcda950cab2a054725678c73 (diff)
downloadchromium_src-246c564da980b3dbbd0a062688ec65539b4b2c35.zip
chromium_src-246c564da980b3dbbd0a062688ec65539b4b2c35.tar.gz
chromium_src-246c564da980b3dbbd0a062688ec65539b4b2c35.tar.bz2
Componentize about_flags::FeatureEntry in flags_ui component.
Move FeatureEntry structure definition to components/flags_ui so that it can be shared with iOS and move the helper macros to a secondary header file for the same reason. Move IDS_GENERIC_EXPERIMENT_CHOICE_* strings to flags_ui.grdp. BUG=551954 Review URL: https://codereview.chromium.org/1415953005 Cr-Commit-Position: refs/heads/master@{#359927}
-rw-r--r--build/ios/grit_whitelist.txt4
-rw-r--r--chrome/app/generated_resources.grd12
-rw-r--r--chrome/browser/about_flags.cc65
-rw-r--r--chrome/browser/about_flags.h106
-rw-r--r--chrome/browser/about_flags_unittest.cc8
-rw-r--r--chrome/browser/profiles/profile_window.cc4
-rw-r--r--components/flags_ui.gypi9
-rw-r--r--components/flags_ui/BUILD.gn5
-rw-r--r--components/flags_ui/DEPS4
-rw-r--r--components/flags_ui/OWNERS1
-rw-r--r--components/flags_ui/feature_entry.cc51
-rw-r--r--components/flags_ui/feature_entry.h123
-rw-r--r--components/flags_ui/feature_entry_macros.h34
-rw-r--r--components/flags_ui_strings.grdp12
14 files changed, 255 insertions, 183 deletions
diff --git a/build/ios/grit_whitelist.txt b/build/ios/grit_whitelist.txt
index 943929d..af3c962 100644
--- a/build/ios/grit_whitelist.txt
+++ b/build/ios/grit_whitelist.txt
@@ -426,10 +426,6 @@ IDS_FLAGS_WALLET_SERVICE_USE_SANDBOX_NAME
IDS_FLAGS_WARNING_HEADER
IDS_FLAGS_WARNING_TEXT
IDS_FULLSCREEN
-IDS_GENERIC_EXPERIMENT_CHOICE_AUTOMATIC
-IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT
-IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED
-IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED
IDS_GROUP_BY_DOMAIN_LABEL
IDS_GUEST_PROFILE_NAME
IDS_HARMFUL_V3_EXPLANATION_PARAGRAPH
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index afee6e7..757f7a6 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5755,18 +5755,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
</message>
</if>
- <message name="IDS_GENERIC_EXPERIMENT_CHOICE_AUTOMATIC" desc="Generic 'Automatic' experiment choice option name.">
- Automatic
- </message>
- <message name="IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT" desc="Generic 'Default' experiment choice option name. E.G. shown in multi value options in about:flags.">
- Default
- </message>
- <message name="IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED" desc="Generic 'Enabled' experiment choice option name. E.G. shown in multi value options in about:flags.">
- Enabled
- </message>
- <message name="IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED" desc="Generic 'Disabled' experiment choice option name. E.G. shown in multi value options in about:flags.">
- Disabled
- </message>
<message name="IDS_FLAGS_DISABLE_JAVASCRIPT_HARMONY_SHIPPING_NAME" desc="Title for the flag to disable latest (non-experimental) JavaScript fatures">
Disable latest stable JavaScript features
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 2abd33b..64ba5f8 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -31,6 +31,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/enhanced_bookmarks/enhanced_bookmark_switches.h"
+#include "components/flags_ui/feature_entry_macros.h"
#include "components/flags_ui/flags_storage.h"
#include "components/metrics/metrics_hashes.h"
#include "components/nacl/common/nacl_switches.h"
@@ -45,6 +46,7 @@
#include "components/version_info/version_info.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_switches.h"
+#include "grit/components_strings.h"
#include "media/base/media_switches.h"
#include "media/midi/midi_switches.h"
#include "ui/base/l10n/l10n_util.h"
@@ -86,33 +88,9 @@
#include "ui/ozone/public/ozone_switches.h"
#endif
-namespace about_flags {
+using flags_ui::FeatureEntry;
-// Macros to simplify specifying the type. Please refer to the comments on
-// FeatureEntry::Type in the header file, which explain the different entry
-// types and when they should be used.
-#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
- FeatureEntry::SINGLE_VALUE, command_line_switch, switch_value, nullptr, \
- nullptr, nullptr, nullptr, 0
-#define SINGLE_VALUE_TYPE(command_line_switch) \
- SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
-#define SINGLE_DISABLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
- FeatureEntry::SINGLE_DISABLE_VALUE, command_line_switch, switch_value, \
- nullptr, nullptr, nullptr, nullptr, 0
-#define SINGLE_DISABLE_VALUE_TYPE(command_line_switch) \
- SINGLE_DISABLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
-#define ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, enable_value, \
- disable_switch, disable_value) \
- FeatureEntry::ENABLE_DISABLE_VALUE, enable_switch, enable_value, \
- disable_switch, disable_value, nullptr, nullptr, 3
-#define ENABLE_DISABLE_VALUE_TYPE(enable_switch, disable_switch) \
- ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, "", disable_switch, "")
-#define MULTI_VALUE_TYPE(choices) \
- FeatureEntry::MULTI_VALUE, nullptr, nullptr, nullptr, nullptr, nullptr, \
- choices, arraysize(choices)
-#define FEATURE_VALUE_TYPE(feature) \
- FeatureEntry::FEATURE_VALUE, nullptr, nullptr, nullptr, nullptr, \
- &feature, nullptr, 3
+namespace about_flags {
namespace {
@@ -2452,35 +2430,6 @@ base::Value* CreateChoiceData(
} // namespace
-std::string FeatureEntry::NameForChoice(int index) const {
- DCHECK(type == FeatureEntry::MULTI_VALUE ||
- type == FeatureEntry::ENABLE_DISABLE_VALUE ||
- type == FeatureEntry::FEATURE_VALUE);
- DCHECK_LT(index, num_choices);
- return std::string(internal_name) + testing::kMultiSeparator +
- base::IntToString(index);
-}
-
-base::string16 FeatureEntry::DescriptionForChoice(int index) const {
- DCHECK(type == FeatureEntry::MULTI_VALUE ||
- type == FeatureEntry::ENABLE_DISABLE_VALUE ||
- type == FeatureEntry::FEATURE_VALUE);
- DCHECK_LT(index, num_choices);
- int description_id;
- if (type == FeatureEntry::ENABLE_DISABLE_VALUE ||
- type == FeatureEntry::FEATURE_VALUE) {
- const int kEnableDisableDescriptionIds[] = {
- IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
- IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
- IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
- };
- description_id = kEnableDisableDescriptionIds[index];
- } else {
- description_id = choices[index].description_id;
- }
- return l10n_util::GetStringUTF16(description_id);
-}
-
void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
base::CommandLine* command_line,
SentinelsMode sentinels) {
@@ -2729,7 +2678,7 @@ bool FlagsState::IsRestartNeededToCommitChanges() {
void FlagsState::SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
const std::string& internal_name,
bool enable) {
- size_t at_index = internal_name.find(testing::kMultiSeparator);
+ size_t at_index = internal_name.find(flags_ui::testing::kMultiSeparator);
if (at_index != std::string::npos) {
DCHECK(enable);
// We're being asked to enable a multi-choice entry. Disable the
@@ -2956,10 +2905,6 @@ void FlagsState::MergeFeatureCommandLineSwitch(
namespace testing {
-// WARNING: '@' is also used in the html file. If you update this constant you
-// also need to update the html file.
-const char kMultiSeparator[] = "@";
-
const base::HistogramBase::Sample kBadSwitchFormatHistogramId = 0;
void ClearState() {
diff --git a/chrome/browser/about_flags.h b/chrome/browser/about_flags.h
index 70fd642..d16274c 100644
--- a/chrome/browser/about_flags.h
+++ b/chrome/browser/about_flags.h
@@ -14,11 +14,11 @@
#include "base/command_line.h"
#include "base/metrics/histogram_base.h"
#include "base/strings/string16.h"
+#include "components/flags_ui/feature_entry.h"
class PrefService;
namespace base {
-struct Feature;
class ListValue;
}
@@ -28,102 +28,6 @@ class FlagsStorage;
namespace about_flags {
-// FeatureEntry is used by about_flags to describe an experimental feature.
-//
-// Note that features should eventually be either turned on by default with no
-// about_flags entries or deleted. Most feature entries should only be around
-// for a few milestones, until their full launch.
-//
-// This is exposed only for testing.
-struct FeatureEntry {
- enum Type {
- // A feature with a single flag value. This is typically what you want.
- SINGLE_VALUE,
-
- // A default enabled feature with a single flag value to disable it. Please
- // consider whether you really need a flag to disable the feature, and even
- // if so remove the disable flag as soon as it is no longer needed.
- SINGLE_DISABLE_VALUE,
-
- // The feature has multiple values only one of which is ever enabled.
- // The first of the values should correspond to a deactivated state for this
- // feature (i.e. no command line option). For MULTI_VALUE entries, the
- // command_line of the FeatureEntry is not used. If the experiment is
- // enabled the command line of the selected Choice is enabled.
- MULTI_VALUE,
-
- // The feature has three possible values: Default, Enabled and Disabled.
- // This should be used for features that may have their own logic to decide
- // if the feature should be on when not explicitly specified via about
- // flags - for example via FieldTrials.
- ENABLE_DISABLE_VALUE,
-
- // Corresponds to a base::Feature, per base/feature_list.h. The entry will
- // have three states: Default, Enabled, Disabled. When not specified or set
- // to Default, the normal default value of the feature is used.
- FEATURE_VALUE,
- };
-
- // Used for MULTI_VALUE types to describe one of the possible values the user
- // can select.
- struct Choice {
- // ID of the message containing the choice name.
- int description_id;
-
- // Command line switch and value to enabled for this choice.
- const char* command_line_switch;
- // Simple switches that have no value should use "" for command_line_value.
- const char* command_line_value;
- };
-
- // The internal name of the feature entry. This is never shown to the user.
- // It _is_ however stored in the prefs file, so you shouldn't change the
- // name of existing flags.
- const char* internal_name;
-
- // String id of the message containing the feature's name.
- int visible_name_id;
-
- // String id of the message containing the feature's description.
- int visible_description_id;
-
- // The platforms the feature is available on.
- // Needs to be more than a compile-time #ifdef because of profile sync.
- unsigned supported_platforms; // bitmask
-
- // Type of entry.
- Type type;
-
- // The commandline switch and value that are added when this flag is active.
- // This is different from |internal_name| so that the commandline flag can be
- // renamed without breaking the prefs file.
- // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE.
- const char* command_line_switch;
- // Simple switches that have no value should use "" for command_line_value.
- const char* command_line_value;
-
- // For ENABLE_DISABLE_VALUE, the command line switch and value to explicitly
- // disable the feature.
- const char* disable_command_line_switch;
- const char* disable_command_line_value;
-
- // For FEATURE_VALUE, the base::Feature this entry corresponds to.
- const base::Feature* feature;
-
- // This is used if type is MULTI_VALUE.
- const Choice* choices;
-
- // Number of |choices|.
- // This is used if type is MULTI_VALUE.
- int num_choices;
-
- // Returns the name used in prefs for the choice at the specified |index|.
- std::string NameForChoice(int index) const;
-
- // Returns the human readable description for the choice at |index|.
- base::string16 DescriptionForChoice(int index) const;
-};
-
// A flag controlling the behavior of the |ConvertFlagsToSwitches| function -
// whether it should add the sentinel switches around flags.
enum SentinelsMode { kNoSentinels, kAddSentinels };
@@ -200,14 +104,10 @@ void ClearState();
// Sets the list of feature entries. Pass in null to use the default set. This
// does NOT take ownership of the supplied |entries|.
-void SetFeatureEntries(const FeatureEntry* entries, size_t count);
+void SetFeatureEntries(const flags_ui::FeatureEntry* entries, size_t count);
// Returns the current set of feature entries.
-const FeatureEntry* GetFeatureEntries(size_t* count);
-
-// Separator used for multi values. Multi values are represented in prefs as
-// name-of-experiment + kMultiSeparator + selected_index.
-extern const char kMultiSeparator[];
+const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count);
// This value is reported as switch histogram ID if switch name has unknown
// format.
diff --git a/chrome/browser/about_flags_unittest.cc b/chrome/browser/about_flags_unittest.cc
index ca5ebb9..0fbe0d9 100644
--- a/chrome/browser/about_flags_unittest.cc
+++ b/chrome/browser/about_flags_unittest.cc
@@ -26,6 +26,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libxml/chromium/libxml_utils.h"
+using flags_ui::FeatureEntry;
+
namespace about_flags {
namespace {
@@ -528,7 +530,8 @@ TEST_F(AboutFlagsTest, RemoveFlagSwitches_Features) {
testing::ClearState();
const std::string entry_name = base::StringPrintf(
- "%s%s%d", kFlags7, testing::kMultiSeparator, cases[i].enabled_choice);
+ "%s%s%d", kFlags7, flags_ui::testing::kMultiSeparator,
+ cases[i].enabled_choice);
SetFeatureEntryEnabled(&flags_storage_, entry_name, true);
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels);
@@ -813,7 +816,8 @@ TEST_F(AboutFlagsTest, NoSeparators) {
const FeatureEntry* entries = testing::GetFeatureEntries(&count);
for (size_t i = 0; i < count; ++i) {
std::string name = entries[i].internal_name;
- EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i;
+ EXPECT_EQ(std::string::npos, name.find(flags_ui::testing::kMultiSeparator))
+ << i;
}
}
diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc
index 99332cb..b9edb8a 100644
--- a/chrome/browser/profiles/profile_window.cc
+++ b/chrome/browser/profiles/profile_window.cc
@@ -467,12 +467,12 @@ void EnableNewProfileManagementPreview(Profile* profile) {
#else
// TODO(rogerta): instead of setting experiment flags and command line
// args, we should set a profile preference.
- const about_flags::FeatureEntry entry = {
+ const flags_ui::FeatureEntry entry = {
kNewProfileManagementExperimentInternalName,
0, // string id for title of experiment
0, // string id for description of experiment
0, // supported platforms
- about_flags::FeatureEntry::ENABLE_DISABLE_VALUE,
+ flags_ui::FeatureEntry::ENABLE_DISABLE_VALUE,
switches::kEnableNewProfileManagement,
"", // not used with ENABLE_DISABLE_VALUE type
switches::kDisableNewProfileManagement,
diff --git a/components/flags_ui.gypi b/components/flags_ui.gypi
index a6ab42c..3293221 100644
--- a/components/flags_ui.gypi
+++ b/components/flags_ui.gypi
@@ -11,8 +11,17 @@
'include_dirs': [
'..',
],
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../base/base.gyp:base_prefs',
+ '../components/components_strings.gyp:components_strings',
+ '../ui/base/ui_base.gyp:ui_base',
+ ],
'sources': [
# Note: sources list duplicated in GN build.
+ 'flags_ui/feature_entry.cc',
+ 'flags_ui/feature_entry.h',
+ 'flags_ui/feature_entry_macros.h',
'flags_ui/flags_ui_constants.cc',
'flags_ui/flags_ui_constants.h',
'flags_ui/flags_ui_pref_names.cc',
diff --git a/components/flags_ui/BUILD.gn b/components/flags_ui/BUILD.gn
index 5226765..0678f20 100644
--- a/components/flags_ui/BUILD.gn
+++ b/components/flags_ui/BUILD.gn
@@ -4,6 +4,9 @@
source_set("flags_ui") {
sources = [
+ "feature_entry.cc",
+ "feature_entry.h",
+ "feature_entry_macros.h",
"flags_storage.h",
"flags_ui_constants.cc",
"flags_ui_constants.h",
@@ -16,5 +19,7 @@ source_set("flags_ui") {
deps = [
"//base",
"//base:prefs",
+ "//components/strings",
+ "//ui/base",
]
}
diff --git a/components/flags_ui/DEPS b/components/flags_ui/DEPS
new file mode 100644
index 0000000..112ca0e
--- /dev/null
+++ b/components/flags_ui/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+grit/components_strings.h",
+ "+ui/base",
+]
diff --git a/components/flags_ui/OWNERS b/components/flags_ui/OWNERS
index 4298fad..b31ddc1 100644
--- a/components/flags_ui/OWNERS
+++ b/components/flags_ui/OWNERS
@@ -1,3 +1,4 @@
+asvitkine@chromium.org
bauerb@chromium.org
dbeam@chromium.org
estade@chromium.org
diff --git a/components/flags_ui/feature_entry.cc b/components/flags_ui/feature_entry.cc
new file mode 100644
index 0000000..b755697
--- /dev/null
+++ b/components/flags_ui/feature_entry.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/flags_ui/feature_entry.h"
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "grit/components_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace flags_ui {
+
+std::string FeatureEntry::NameForChoice(int index) const {
+ DCHECK(type == FeatureEntry::MULTI_VALUE ||
+ type == FeatureEntry::ENABLE_DISABLE_VALUE ||
+ type == FeatureEntry::FEATURE_VALUE);
+ DCHECK_LT(index, num_choices);
+ return std::string(internal_name) + testing::kMultiSeparator +
+ base::IntToString(index);
+}
+
+base::string16 FeatureEntry::DescriptionForChoice(int index) const {
+ DCHECK(type == FeatureEntry::MULTI_VALUE ||
+ type == FeatureEntry::ENABLE_DISABLE_VALUE ||
+ type == FeatureEntry::FEATURE_VALUE);
+ DCHECK_LT(index, num_choices);
+ int description_id;
+ if (type == FeatureEntry::ENABLE_DISABLE_VALUE ||
+ type == FeatureEntry::FEATURE_VALUE) {
+ const int kEnableDisableDescriptionIds[] = {
+ IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
+ IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
+ IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
+ };
+ description_id = kEnableDisableDescriptionIds[index];
+ } else {
+ description_id = choices[index].description_id;
+ }
+ return l10n_util::GetStringUTF16(description_id);
+}
+
+namespace testing {
+
+// WARNING: '@' is also used in the html file. If you update this constant you
+// also need to update the html file.
+const char kMultiSeparator[] = "@";
+
+} // namespace testing
+
+} // namespace flags_ui
diff --git a/components/flags_ui/feature_entry.h b/components/flags_ui/feature_entry.h
new file mode 100644
index 0000000..4f7f081
--- /dev/null
+++ b/components/flags_ui/feature_entry.h
@@ -0,0 +1,123 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_
+#define COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_
+
+#include <string>
+
+#include "base/strings/string16.h"
+
+namespace base {
+struct Feature;
+}
+
+namespace flags_ui {
+
+// FeatureEntry is used to describe an experimental feature.
+//
+// Note that features should eventually be either turned on by default with no
+// about_flags entries or deleted. Most feature entries should only be around
+// for a few milestones, until their full launch.
+struct FeatureEntry {
+ enum Type {
+ // A feature with a single flag value. This is typically what you want.
+ SINGLE_VALUE,
+
+ // A default enabled feature with a single flag value to disable it. Please
+ // consider whether you really need a flag to disable the feature, and even
+ // if so remove the disable flag as soon as it is no longer needed.
+ SINGLE_DISABLE_VALUE,
+
+ // The feature has multiple values only one of which is ever enabled.
+ // The first of the values should correspond to a deactivated state for this
+ // feature (i.e. no command line option). For MULTI_VALUE entries, the
+ // command_line of the FeatureEntry is not used. If the experiment is
+ // enabled the command line of the selected Choice is enabled.
+ MULTI_VALUE,
+
+ // The feature has three possible values: Default, Enabled and Disabled.
+ // This should be used for features that may have their own logic to decide
+ // if the feature should be on when not explicitly specified via about
+ // flags - for example via FieldTrials.
+ ENABLE_DISABLE_VALUE,
+
+ // Corresponds to a base::Feature, per base/feature_list.h. The entry will
+ // have three states: Default, Enabled, Disabled. When not specified or set
+ // to Default, the normal default value of the feature is used.
+ FEATURE_VALUE,
+ };
+
+ // Used for MULTI_VALUE types to describe one of the possible values the user
+ // can select.
+ struct Choice {
+ // ID of the message containing the choice name.
+ int description_id;
+
+ // Command line switch and value to enabled for this choice.
+ const char* command_line_switch;
+ // Simple switches that have no value should use "" for command_line_value.
+ const char* command_line_value;
+ };
+
+ // The internal name of the feature entry. This is never shown to the user.
+ // It _is_ however stored in the prefs file, so you shouldn't change the
+ // name of existing flags.
+ const char* internal_name;
+
+ // String id of the message containing the feature's name.
+ int visible_name_id;
+
+ // String id of the message containing the feature's description.
+ int visible_description_id;
+
+ // The platforms the feature is available on.
+ // Needs to be more than a compile-time #ifdef because of profile sync.
+ unsigned supported_platforms; // bitmask
+
+ // Type of entry.
+ Type type;
+
+ // The commandline switch and value that are added when this flag is active.
+ // This is different from |internal_name| so that the commandline flag can be
+ // renamed without breaking the prefs file.
+ // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE.
+ const char* command_line_switch;
+
+ // Simple switches that have no value should use "" for command_line_value.
+ const char* command_line_value;
+
+ // For ENABLE_DISABLE_VALUE, the command line switch and value to explicitly
+ // disable the feature.
+ const char* disable_command_line_switch;
+ const char* disable_command_line_value;
+
+ // For FEATURE_VALUE, the base::Feature this entry corresponds to.
+ const base::Feature* feature;
+
+ // This is used if type is MULTI_VALUE.
+ const Choice* choices;
+
+ // Number of |choices|.
+ // This is used if type is MULTI_VALUE.
+ int num_choices;
+
+ // Returns the name used in prefs for the choice at the specified |index|.
+ std::string NameForChoice(int index) const;
+
+ // Returns the human readable description for the choice at |index|.
+ base::string16 DescriptionForChoice(int index) const;
+};
+
+namespace testing {
+
+// Separator used for multi values. Multi values are represented in prefs as
+// name-of-experiment + kMultiSeparator + selected_index.
+extern const char kMultiSeparator[];
+
+} // namespace
+
+} // namespace flag_ui
+
+#endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_
diff --git a/components/flags_ui/feature_entry_macros.h b/components/flags_ui/feature_entry_macros.h
new file mode 100644
index 0000000..cb36560
--- /dev/null
+++ b/components/flags_ui/feature_entry_macros.h
@@ -0,0 +1,34 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_FLAGS_UI_FEATURE_ENTRY_MACROS_H_
+#define COMPONENTS_FLAGS_UI_FEATURE_ENTRY_MACROS_H_
+
+// Macros to simplify specifying the type of FeatureEntry. Please refer to
+// the comments on FeatureEntry::Type in feature_entry.h, which explain the
+// different entry types and when they should be used.
+#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
+ flags_ui::FeatureEntry::SINGLE_VALUE, command_line_switch, switch_value, \
+ nullptr, nullptr, nullptr, nullptr, 0
+#define SINGLE_VALUE_TYPE(command_line_switch) \
+ SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
+#define SINGLE_DISABLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
+ flags_ui::FeatureEntry::SINGLE_DISABLE_VALUE, command_line_switch, \
+ switch_value, nullptr, nullptr, nullptr, nullptr, 0
+#define SINGLE_DISABLE_VALUE_TYPE(command_line_switch) \
+ SINGLE_DISABLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
+#define ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, enable_value, \
+ disable_switch, disable_value) \
+ flags_ui::FeatureEntry::ENABLE_DISABLE_VALUE, enable_switch, enable_value, \
+ disable_switch, disable_value, nullptr, nullptr, 3
+#define ENABLE_DISABLE_VALUE_TYPE(enable_switch, disable_switch) \
+ ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, "", disable_switch, "")
+#define MULTI_VALUE_TYPE(choices) \
+ flags_ui::FeatureEntry::MULTI_VALUE, nullptr, nullptr, nullptr, nullptr, \
+ nullptr, choices, arraysize(choices)
+#define FEATURE_VALUE_TYPE(feature) \
+ flags_ui::FeatureEntry::FEATURE_VALUE, nullptr, nullptr, nullptr, nullptr, \
+ &feature, nullptr, 3
+
+#endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_MACROS_H_
diff --git a/components/flags_ui_strings.grdp b/components/flags_ui_strings.grdp
index 87e70ec..3453b02 100644
--- a/components/flags_ui_strings.grdp
+++ b/components/flags_ui_strings.grdp
@@ -49,4 +49,16 @@
Flags that apply system-wide can only be set by the owner: <ph name="OWNER_EMAIL">$1<ex>owner@example.com</ex></ph>.
</message>
</if>
+ <message name="IDS_GENERIC_EXPERIMENT_CHOICE_AUTOMATIC" desc="Generic 'Automatic' experiment choice option name.">
+ Automatic
+ </message>
+ <message name="IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT" desc="Generic 'Default' experiment choice option name. E.G. shown in multi value options in about:flags.">
+ Default
+ </message>
+ <message name="IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED" desc="Generic 'Enabled' experiment choice option name. E.G. shown in multi value options in about:flags.">
+ Enabled
+ </message>
+ <message name="IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED" desc="Generic 'Disabled' experiment choice option name. E.G. shown in multi value options in about:flags.">
+ Disabled
+ </message>
</grit-part>