Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: chrome/browser/about_flags.cc

Issue 1415953005: Componentize about_flags::FeatureEntry in flags_ui component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/about_flags.h ('k') | chrome/browser/about_flags_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/about_flags.cc
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 2abd33bf65a9f41afddc70ed2944d0035f1bad5f..64ba5f852c413c71e31737b1301ce770e668a6d6 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() {
« no previous file with comments | « chrome/browser/about_flags.h ('k') | chrome/browser/about_flags_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698