blob: 7c922d2509623b26679cea22803fcc9441f566e1 [file] [log] [blame]
sdefresne14900ee2015-11-27 14:43:211// Copyright 2012 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// Implementation of about_flags for iOS that sets flags based on experimental
6// settings.
7
8#include "ios/chrome/browser/about_flags.h"
9
avi571943672015-12-22 02:12:4910#include <stddef.h>
11#include <stdint.h>
sdefresne14900ee2015-11-27 14:43:2112#import <UIKit/UIKit.h>
13
Gregory Chatzinofff6523722017-11-21 01:33:5314#include "base/base_switches.h"
sdefresne14900ee2015-11-27 14:43:2115#include "base/bind.h"
16#include "base/command_line.h"
17#include "base/logging.h"
avi571943672015-12-22 02:12:4918#include "base/macros.h"
sdefresne14900ee2015-11-27 14:43:2119#include "base/memory/singleton.h"
20#include "base/strings/stringprintf.h"
21#include "base/strings/sys_string_conversions.h"
22#include "base/sys_info.h"
Mohamad Ahmadic4df81f2017-12-20 04:41:5923#include "components/autofill/core/common/autofill_features.h"
sdefresne14900ee2015-11-27 14:43:2124#include "components/dom_distiller/core/dom_distiller_switches.h"
Tommy Nyquistc1d6dea12017-07-26 20:37:2325#include "components/feature_engagement/public/feature_constants.h"
26#include "components/feature_engagement/public/feature_list.h"
sdefresne14900ee2015-11-27 14:43:2127#include "components/flags_ui/feature_entry.h"
28#include "components/flags_ui/feature_entry_macros.h"
29#include "components/flags_ui/flags_storage.h"
30#include "components/flags_ui/flags_ui_switches.h"
noyau4cfb1332016-10-25 17:05:4231#include "components/ntp_tiles/switches.h"
Justin Donnelly33d712e2017-08-23 21:32:5132#include "components/omnibox/browser/omnibox_field_trial.h"
Ioana Pandeled14ce9e2017-11-28 14:41:4633#include "components/password_manager/core/common/password_manager_features.h"
mathp9b4c11d2017-07-06 20:24:1334#include "components/payments/core/features.h"
Marc Treib5fc99e1f2017-11-08 12:19:1835#include "components/search_provider_logos/switches.h"
Emily Starkbafa9062017-12-27 15:22:4636#include "components/security_state/core/features.h"
David Rogera6c88122017-10-25 13:02:4637#include "components/signin/core/browser/signin_switches.h"
sdefresne36579782016-02-05 11:08:2538#include "components/strings/grit/components_strings.h"
Marti Wong87d31d72017-08-25 02:44:5239#include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.h"
sdefresne14900ee2015-11-27 14:43:2140#include "ios/chrome/browser/chrome_switches.h"
Jean-François Geyelin30be5912017-08-25 12:05:3841#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
vabr0215a8e2017-03-28 12:47:3442#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
Mike Doughertya5e5ad52017-08-05 00:11:5843#include "ios/chrome/browser/ssl/captive_portal_features.h"
Gregory Chatzinoff6f3a2602017-10-31 06:24:3544#include "ios/chrome/browser/ui/activity_services/canonical_url_feature.h"
Louis Romerod11747a2017-10-20 20:10:3545#include "ios/chrome/browser/ui/external_search/features.h"
Kurt Horimotoa5a922a2017-11-07 00:21:0946#include "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
sczsa0c91942017-10-26 18:39:5947#import "ios/chrome/browser/ui/history/history_base_feature.h"
Rohit Rao6a3a481d2017-09-25 19:31:4148#include "ios/chrome/browser/ui/main/main_feature_flags.h"
[email protected]9234e9c2018-01-03 13:44:2849#import "ios/chrome/browser/ui/omnibox/omnibox_clipping_feature.h"
sczs6ca1d262017-10-30 20:27:1350#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_base_feature.h"
Justin Cohenba27610e2017-11-08 19:34:4551#import "ios/chrome/browser/ui/toolbar/toolbar_private_base_feature.h"
sdefresne14900ee2015-11-27 14:43:2152#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2853#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Danyao Wang34da6ff2017-10-30 15:16:5654#include "ios/web/public/features.h"
sdefresne14900ee2015-11-27 14:43:2155#include "ios/web/public/user_agent.h"
56#include "ios/web/public/web_view_creation_util.h"
57
58#if !defined(OFFICIAL_BUILD)
59#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2260#endif
stkhapuginc1be1792016-12-13 14:30:5361
62#if !defined(__has_feature) || !__has_feature(objc_arc)
63#error "This file requires ARC support."
64#endif
sdefresne14900ee2015-11-27 14:43:2165
elawrence816f6790e2017-06-16 18:19:2866using flags_ui::FeatureEntry;
67
sdefresne14900ee2015-11-27 14:43:2168namespace {
Emily Starkbafa9062017-12-27 15:22:4669
70const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
71 {security_state::features::kMarkHttpAsFeatureParameterName,
72 security_state::features::kMarkHttpAsParameterDangerous}};
73const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = {
74 {security_state::features::kMarkHttpAsFeatureParameterName,
75 security_state::features::kMarkHttpAsParameterWarning}};
76const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
77 {security_state::features::kMarkHttpAsFeatureParameterName,
78 security_state::features::
79 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
80const FeatureEntry::FeatureParam
81 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = {
82 {security_state::features::kMarkHttpAsFeatureParameterName,
83 security_state::features::
84 kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}};
85
86const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
87 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
88 arraysize(kMarkHttpAsDangerous), nullptr},
89 {"(mark with a Not Secure warning)", kMarkHttpAsWarning,
90 arraysize(kMarkHttpAsWarning), nullptr},
91 {"(mark with a Not Secure warning and dangerous on form edits)",
92 kMarkHttpAsWarningAndDangerousOnFormEdits,
93 arraysize(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr},
94 {"(mark with a Not Secure warning and dangerous on passwords and credit "
95 "card fields)",
96 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards,
97 arraysize(kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards),
98 nullptr}};
elawrence816f6790e2017-06-16 18:19:2899
Marc Treib5fc99e1f2017-11-08 12:19:18100const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
101 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
102 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
103 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
104 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
105 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
106 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
107 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
108 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
109 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
110 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
111 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
112};
Marc Treib2752e8b2017-08-04 14:12:09113
Cooper Knaak1e026562017-07-26 05:22:28114// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21115// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28116// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
117// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21118// macro for this type supplying the command line to the macro.
119// . MULTI_VALUE: a list of choices, the first of which should correspond to a
120// deactivated state for this lab (i.e. no command line option). To specify
121// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
122// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28123// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
124// either enabled, disabled, or uses the default value of the associated
125// base::Feature instance. To specify this type of entry use the macro
126// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
127// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
128// base::Feature instance. Choices corresponding to the default state, a
129// universally enabled state, and a universally disabled state are
130// automatically included. To specify this type of entry use the macro
131// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
132// the array of choices.
133//
sdefresne14900ee2015-11-27 14:43:21134// See the documentation of FeatureEntry for details on the fields.
135//
136// When adding a new choice, add it to the end of the list.
137const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46138 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28139 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46140 FEATURE_WITH_PARAMS_VALUE_TYPE(
141 security_state::features::kMarkHttpAsFeature,
142 kMarkHttpAsFeatureVariations,
143 "MarkHttpAs")},
mathp9b4c11d2017-07-06 20:24:13144 {"web-payments", flag_descriptions::kWebPaymentsName,
145 flag_descriptions::kWebPaymentsDescription, flags_ui::kOsIos,
146 FEATURE_VALUE_TYPE(payments::features::kWebPayments)},
Randall Raymond59766ac2017-08-09 16:28:58147 {"web-payments-native-apps", flag_descriptions::kWebPaymentsNativeAppsName,
148 flag_descriptions::kWebPaymentsNativeAppsDescription, flags_ui::kOsIos,
149 FEATURE_VALUE_TYPE(payments::features::kWebPaymentsNativeApps)},
Mike Doughertya5e5ad52017-08-05 00:11:58150 {"ios-captive-portal", flag_descriptions::kCaptivePortalName,
151 flag_descriptions::kCaptivePortalDescription, flags_ui::kOsIos,
152 FEATURE_VALUE_TYPE(kCaptivePortalFeature)},
Cooper Knaak1e026562017-07-26 05:22:28153 {"in-product-help-demo-mode-choice",
154 flag_descriptions::kInProductHelpDemoModeName,
155 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
156 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23157 feature_engagement::kIPHDemoMode,
158 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09159 "IPH_DemoMode")},
160 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
161 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18162 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Justin Donnelly33d712e2017-08-23 21:32:51163 {"omnibox-ui-elide-suggestion-url-after-host",
164 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostName,
165 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostDescription,
166 flags_ui::kOsIos,
167 FEATURE_VALUE_TYPE(omnibox::kUIExperimentElideSuggestionUrlAfterHost)},
168 {"omnibox-ui-hide-suggestion-url-scheme",
169 flag_descriptions::kOmniboxUIHideSuggestionUrlSchemeName,
170 flag_descriptions::kOmniboxUIHideSuggestionUrlSchemeDescription,
171 flags_ui::kOsIos,
172 FEATURE_VALUE_TYPE(omnibox::kUIExperimentHideSuggestionUrlScheme)},
173 {"omnibox-ui-hide-suggestion-url-trivial-subdomains",
174 flag_descriptions::kOmniboxUIHideSuggestionUrlTrivialSubdomainsName,
175 flag_descriptions::kOmniboxUIHideSuggestionUrlTrivialSubdomainsDescription,
176 flags_ui::kOsIos,
177 FEATURE_VALUE_TYPE(
Marti Wong87d31d72017-08-25 02:44:52178 omnibox::kUIExperimentHideSuggestionUrlTrivialSubdomains)},
Jean-François Geyelin30be5912017-08-25 12:05:38179#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
180 {"drag_and_drop", flag_descriptions::kDragAndDropName,
181 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41182 FEATURE_VALUE_TYPE(kDragAndDrop)},
Jean-François Geyelin30be5912017-08-25 12:05:38183#endif
Rohit Rao6a3a481d2017-09-25 19:31:41184 {"tab_switcher_presents_bvc",
185 flag_descriptions::kTabSwitcherPresentsBVCName,
186 flag_descriptions::kTabSwitcherPresentsBVCDescription, flags_ui::kOsIos,
Jean-François Geyelined4cde72017-10-11 11:34:50187 FEATURE_VALUE_TYPE(kTabSwitcherPresentsBVC)},
188 {"safe_area_compatible_toolbar",
189 flag_descriptions::kSafeAreaCompatibleToolbarName,
190 flag_descriptions::kSafeAreaCompatibleToolbarDescription, flags_ui::kOsIos,
Louis Romerod11747a2017-10-20 20:10:35191 FEATURE_VALUE_TYPE(kSafeAreaCompatibleToolbar)},
192 {"external-search", flag_descriptions::kExternalSearchName,
193 flag_descriptions::kExternalSearchDescription, flags_ui::kOsIos,
194 FEATURE_VALUE_TYPE(kExternalSearch)},
sczsa0c91942017-10-26 18:39:59195 {"history-batch-updates-filter",
196 flag_descriptions::kHistoryBatchUpdatesFilterName,
197 flag_descriptions::kHistoryBatchUpdatesFilterDescription, flags_ui::kOsIos,
198 FEATURE_VALUE_TYPE(kHistoryBatchUpdatesFilter)},
Danyao Wang34da6ff2017-10-30 15:16:56199 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
200 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
201 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
Eugene Butf631e0b2017-12-12 17:27:09202 {"new-pass-kit-download", flag_descriptions::kNewPassKitDownloadName,
203 flag_descriptions::kNewPassKitDownloadDescription, flags_ui::kOsIos,
204 FEATURE_VALUE_TYPE(web::features::kNewPassKitDownload)},
Gregory Chatzinoff6f3a2602017-10-31 06:24:35205 {"ios-share-canonical-url", flag_descriptions::kShareCanonicalURLName,
206 flag_descriptions::kShareCanonicalURLDescription, flags_ui::kOsIos,
207 FEATURE_VALUE_TYPE(activity_services::kShareCanonicalURL)},
sczsdc2e8e02018-01-09 18:39:32208 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
209 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
210 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
Kurt Horimotoa5a922a2017-11-07 00:21:09211 {"new-fullscreen-controller", flag_descriptions::kNewFullscreenName,
212 flag_descriptions::kNewFullscreenDescription, flags_ui::kOsIos,
Gauthier Ambardccc4c682017-11-17 15:36:37213 FEATURE_VALUE_TYPE(fullscreen::features::kNewFullscreen)},
214 {"clean-toolbar", flag_descriptions::kCleanToolbarName,
215 flag_descriptions::kCleanToolbarDescription, flags_ui::kOsIos,
Marti Wong1b885ad2017-11-24 05:19:57216 FEATURE_VALUE_TYPE(kCleanToolbar)},
[email protected]9234e9c2018-01-03 13:44:28217 {"clipping-textfield", flag_descriptions::kClippingTextfieldName,
218 flag_descriptions::kClippingTextfieldDescription, flags_ui::kOsIos,
219 FEATURE_VALUE_TYPE(kClippingTextfield)},
Marti Wong1b885ad2017-11-24 05:19:57220 {"bookmark-new-edit-page", flag_descriptions::kBookmarkNewEditPageName,
221 flag_descriptions::kBookmarkNewEditPageDescription, flags_ui::kOsIos,
Ioana Pandeled14ce9e2017-11-28 14:41:46222 FEATURE_VALUE_TYPE(kBookmarkNewEditPage)},
nikhild70e7cb52017-12-26 07:38:20223 {"PasswordExport", flag_descriptions::kPasswordExportName,
Ioana Pandeled14ce9e2017-11-28 14:41:46224 flag_descriptions::kPasswordExportDescription, flags_ui::kOsIos,
mrefaata6501d92017-12-11 19:50:50225 FEATURE_VALUE_TYPE(password_manager::features::kPasswordExport)},
226 {"wk-http-system-cookie-store",
227 flag_descriptions::kWKHTTPSystemCookieStoreName,
228 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59229 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
230 {"show-autofill-type-predictions",
231 flag_descriptions::kShowAutofillTypePredictionsName,
232 flag_descriptions::kShowAutofillTypePredictionsDescription,
233 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46234 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
235 {"adaptive-toolbar", flag_descriptions::kAdaptiveToolbarName,
236 flag_descriptions::kAdaptiveToolbarDescription, flags_ui::kOsIos,
237 FEATURE_VALUE_TYPE(kAdaptiveToolbar)},
238};
sdefresne14900ee2015-11-27 14:43:21239
240// Add all switches from experimental flags to |command_line|.
241void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
242 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
243
sdefresne14900ee2015-11-27 14:43:21244 // Web page replay flags.
245 BOOL webPageReplayEnabled = [defaults boolForKey:@"WebPageReplayEnabled"];
246 NSString* webPageReplayProxy =
247 [defaults stringForKey:@"WebPageReplayProxyAddress"];
248 if (webPageReplayEnabled && [webPageReplayProxy length]) {
249 command_line->AppendSwitch(switches::kIOSIgnoreCertificateErrors);
250 // 80 and 443 are the default ports from web page replay.
251 command_line->AppendSwitchASCII(switches::kIOSTestingFixedHttpPort, "80");
252 command_line->AppendSwitchASCII(switches::kIOSTestingFixedHttpsPort, "443");
253 command_line->AppendSwitchASCII(
254 switches::kIOSHostResolverRules,
255 "MAP * " + base::SysNSStringToUTF8(webPageReplayProxy));
256 }
257
sdefresne14900ee2015-11-27 14:43:21258 // Set the UA flag if UseMobileSafariUA is enabled.
259 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
260 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
261 // Chrome puts its product token.
avi571943672015-12-22 02:12:49262 int32_t major = 0;
263 int32_t minor = 0;
264 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21265 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
266 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
267
268 command_line->AppendSwitchASCII(switches::kUserAgent,
269 web::BuildUserAgentFromProduct(product));
270 }
271
272 // Freeform commandline flags. These are added last, so that any flags added
273 // earlier in this function take precedence.
274 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
275 base::CommandLine::StringVector flags;
276 // Append an empty "program" argument.
277 flags.push_back("");
278
279 // The number of flags corresponds to the number of text fields in
280 // Experimental.plist.
281 const int kNumFreeformFlags = 5;
282 for (int i = 1; i <= kNumFreeformFlags; ++i) {
283 NSString* key =
284 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
285 NSString* flag = [defaults stringForKey:key];
286 if ([flag length]) {
287 flags.push_back(base::SysNSStringToUTF8(flag));
288 }
289 }
290
291 base::CommandLine temp_command_line(flags);
292 command_line->AppendArguments(temp_command_line, false);
293 }
msardafc76f662017-02-24 12:46:28294
justincohendacc85d2017-06-28 23:34:10295 // Populate command line flag for 3rd party keyboard omnibox workaround.
296 NSString* enableThirdPartyKeyboardWorkaround =
297 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
298 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
299 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
300 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
301 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
302 }
303
msardafc76f662017-02-24 12:46:28304 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
305 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21306}
307
308bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
309 return false;
310}
311
312class FlagsStateSingleton {
313 public:
314 FlagsStateSingleton()
315 : flags_state_(kFeatureEntries, arraysize(kFeatureEntries)) {}
316 ~FlagsStateSingleton() {}
317
318 static FlagsStateSingleton* GetInstance() {
319 return base::Singleton<FlagsStateSingleton>::get();
320 }
321
322 static flags_ui::FlagsState* GetFlagsState() {
323 return &GetInstance()->flags_state_;
324 }
325
326 private:
327 flags_ui::FlagsState flags_state_;
328
329 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
330};
331} // namespace
332
333void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
334 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02335 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21336 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11337 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53338 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21339}
340
jkrcalbf073372016-07-29 07:21:31341std::vector<std::string> RegisterAllFeatureVariationParameters(
342 flags_ui::FlagsStorage* flags_storage,
343 base::FeatureList* feature_list) {
344 return FlagsStateSingleton::GetFlagsState()
345 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
346}
347
sdefresne14900ee2015-11-27 14:43:21348void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
349 flags_ui::FlagAccess access,
350 base::ListValue* supported_entries,
351 base::ListValue* unsupported_entries) {
352 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
353 flags_storage, access, supported_entries, unsupported_entries,
354 base::Bind(&SkipConditionalFeatureEntry));
355}
356
357void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
358 const std::string& internal_name,
359 bool enable) {
360 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
361 flags_storage, internal_name, enable);
362}
363
364void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
365 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
366}
367
368namespace testing {
369
370const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
371 *count = arraysize(kFeatureEntries);
372 return kFeatureEntries;
373}
374
375} // namespace testing