blob: a997824263e7e0a2d2be67b4b29c380d1427a4ed [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
Nazerke9c259052019-06-26 15:30:108#include "ios/chrome/browser/flags/about_flags.h"
sdefresne14900ee2015-11-27 14:43:219
Nazerke9c259052019-06-26 15:30:1010#import <UIKit/UIKit.h>
avi571943672015-12-22 02:12:4911#include <stddef.h>
12#include <stdint.h>
sdefresne14900ee2015-11-27 14:43:2113
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"
Sylvain Defresne8327a2f2019-01-17 14:19:1818#include "base/no_destructor.h"
kokihoon189a4022018-10-13 02:43:4419#include "base/stl_util.h"
sdefresne14900ee2015-11-27 14:43:2120#include "base/strings/stringprintf.h"
21#include "base/strings/sys_string_conversions.h"
Sebastien Marchand75a7cdf2018-11-13 23:47:0322#include "base/system/sys_info.h"
Mohamad Ahmadic4df81f2017-12-20 04:41:5923#include "components/autofill/core/common/autofill_features.h"
Jared Sauld998539f2019-03-19 15:11:1724#include "components/autofill/core/common/autofill_payments_features.h"
Moe Ahmadid6d5d172018-06-20 17:20:2325#include "components/autofill/core/common/autofill_switches.h"
Olivier Robin3d60411622018-02-23 10:03:2226#include "components/autofill/ios/browser/autofill_switches.h"
sdefresne14900ee2015-11-27 14:43:2127#include "components/dom_distiller/core/dom_distiller_switches.h"
Tommy Nyquistc1d6dea12017-07-26 20:37:2328#include "components/feature_engagement/public/feature_constants.h"
29#include "components/feature_engagement/public/feature_list.h"
sdefresne14900ee2015-11-27 14:43:2130#include "components/flags_ui/feature_entry.h"
31#include "components/flags_ui/feature_entry_macros.h"
32#include "components/flags_ui/flags_storage.h"
33#include "components/flags_ui/flags_ui_switches.h"
Tanja Gornakb0985dd2018-10-11 17:24:4034#include "components/invalidation/impl/invalidation_switches.h"
noyau4cfb1332016-10-25 17:05:4235#include "components/ntp_tiles/switches.h"
Justin Donnelly33d712e2017-08-23 21:32:5136#include "components/omnibox/browser/omnibox_field_trial.h"
Tomasz Wiszkowskid938a1112019-03-06 18:01:5737#include "components/omnibox/common/omnibox_features.h"
Ioana Pandeled14ce9e2017-11-28 14:41:4638#include "components/password_manager/core/common/password_manager_features.h"
mathp9b4c11d2017-07-06 20:24:1339#include "components/payments/core/features.h"
Marc Treib5fc99e1f2017-11-08 12:19:1840#include "components/search_provider_logos/switches.h"
Emily Starkbafa9062017-12-27 15:22:4641#include "components/security_state/core/features.h"
Sébastien Séguin-Gagnondcb854b2019-04-10 16:36:4442#include "components/send_tab_to_self/features.h"
Valeriya Sinevicha79dc612018-09-25 14:49:0943#include "components/signin/core/browser/account_reconcilor.h"
Jérôme Lebelc374fdd2019-09-27 10:36:4844#include "components/signin/ios/browser/features.h"
Colin Blundell3517170e2019-07-11 08:16:3445#include "components/signin/public/base/signin_switches.h"
sdefresne36579782016-02-05 11:08:2546#include "components/strings/grit/components_strings.h"
Moe Ahmadid6d5d172018-06-20 17:20:2347#include "components/sync/driver/sync_driver_switches.h"
Moe Ahmadie4cce1f2018-12-18 23:48:0148#include "components/translate/core/browser/translate_prefs.h"
Chris Lu0683adf2019-02-26 15:56:4549#include "components/ukm/ios/features.h"
Mihai Sardarescu160ec662018-07-18 21:13:5150#include "components/unified_consent/feature.h"
mrefaat4539b032018-08-02 22:25:4551#include "ios/chrome/browser/app_launcher/app_launcher_flags.h"
Sylvain Defresneae6987e2018-03-01 13:21:4052#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2153#include "ios/chrome/browser/chrome_switches.h"
Mike Doughertyb6c770d2019-09-13 22:56:4654#include "ios/chrome/browser/crash_report/breadcrumbs/features.h"
Olivier Robin2a898dc2018-10-31 14:37:0455#include "ios/chrome/browser/crash_report/crash_report_flags.h"
Jean-François Geyelin30be5912017-08-25 12:05:3856#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
Chris Lu77905ac2018-12-06 20:46:5157#include "ios/chrome/browser/find_in_page/features.h"
Nazerke21bdc45a2019-07-11 09:02:0558#include "ios/chrome/browser/flags/ios_chrome_flag_descriptions.h"
David Jean7d0bff12019-04-01 08:21:1459#include "ios/chrome/browser/passwords/password_manager_features.h"
Olivier Robin091319d2019-03-04 10:45:3460#include "ios/chrome/browser/reading_list/features.h"
Gauthier Ambard33e03302019-02-21 13:28:5861#include "ios/chrome/browser/system_flags.h"
Kurt Horimoto9165404a2018-11-13 23:48:1262#import "ios/chrome/browser/ui/dialogs/dialog_features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3563#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
sczs80a6f462018-12-05 20:37:1864#import "ios/chrome/browser/ui/infobars/infobar_feature.h"
Tanisha Mandre549612ea2019-07-17 11:36:1565#include "ios/chrome/browser/ui/settings/autofill/features.h"
sczs76b9ba02019-07-23 23:34:3066#import "ios/chrome/browser/ui/table_view/feature_flags.h"
Mark Cogan02ed6c772018-05-31 17:00:5167#import "ios/chrome/browser/ui/toolbar/public/features.h"
Kurt Horimoto79d590b2018-09-12 19:09:2868#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h"
Justin Cohen2d81c582018-01-22 14:46:4469#include "ios/chrome/browser/ui/ui_feature_flags.h"
Yi Su392b3032018-06-05 07:26:4770#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2171#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2872#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Eugene But61818bc2019-04-15 21:04:0773#include "ios/web/common/features.h"
Eugene Bute79f2742019-07-26 17:07:2274#include "ios/web/common/user_agent.h"
Eugene Butb1416232019-07-22 17:31:5875#include "ios/web/common/web_view_creation_util.h"
sdefresne14900ee2015-11-27 14:43:2176
77#if !defined(OFFICIAL_BUILD)
78#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2279#endif
stkhapuginc1be1792016-12-13 14:30:5380
81#if !defined(__has_feature) || !__has_feature(objc_arc)
82#error "This file requires ARC support."
83#endif
sdefresne14900ee2015-11-27 14:43:2184
elawrence816f6790e2017-06-16 18:19:2885using flags_ui::FeatureEntry;
86
sdefresne14900ee2015-11-27 14:43:2187namespace {
Emily Starkbafa9062017-12-27 15:22:4688
89const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
90 {security_state::features::kMarkHttpAsFeatureParameterName,
91 security_state::features::kMarkHttpAsParameterDangerous}};
Emily Starkbafa9062017-12-27 15:22:4692const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
93 {security_state::features::kMarkHttpAsFeatureParameterName,
94 security_state::features::
95 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
Emily Starkbafa9062017-12-27 15:22:4696
97const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
98 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
kokihoon189a4022018-10-13 02:43:4499 base::size(kMarkHttpAsDangerous), nullptr},
Emily Starkbafa9062017-12-27 15:22:46100 {"(mark with a Not Secure warning and dangerous on form edits)",
101 kMarkHttpAsWarningAndDangerousOnFormEdits,
Joe DeBlasio20e01fd2018-12-20 19:59:30102 base::size(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr}};
elawrence816f6790e2017-06-16 18:19:28103
Marc Treib5fc99e1f2017-11-08 12:19:18104const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
105 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
106 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
107 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
108 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
109 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
110 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
111 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
112 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
113 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
114 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
115 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
116};
Marc Treib2752e8b2017-08-04 14:12:09117
Olivier Robin3d60411622018-02-23 10:03:22118const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
119 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
120 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
121 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
122 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
123 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
124 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
125 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
126 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
127 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
128};
129
Stepan Khapugincc4e9842019-01-23 13:38:13130const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches3[] = {
131 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "3"}};
132const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches4[] = {
133 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "4"}};
134const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches5[] = {
135 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "5"}};
136const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches6[] = {
137 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "6"}};
138const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches8[] = {
139 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "8"}};
140const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches10[] = {
141 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "10"}};
142const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches12[] = {
143 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "12"}};
144
145const FeatureEntry::FeatureVariation
146 kOmniboxUIMaxAutocompleteMatchesVariations[] = {
147 {"3 matches", kOmniboxUIMaxAutocompleteMatches3,
148 base::size(kOmniboxUIMaxAutocompleteMatches3), nullptr},
149 {"4 matches", kOmniboxUIMaxAutocompleteMatches4,
150 base::size(kOmniboxUIMaxAutocompleteMatches4), nullptr},
151 {"5 matches", kOmniboxUIMaxAutocompleteMatches5,
152 base::size(kOmniboxUIMaxAutocompleteMatches5), nullptr},
153 {"6 matches", kOmniboxUIMaxAutocompleteMatches6,
154 base::size(kOmniboxUIMaxAutocompleteMatches6), nullptr},
155 {"8 matches", kOmniboxUIMaxAutocompleteMatches8,
156 base::size(kOmniboxUIMaxAutocompleteMatches8), nullptr},
157 {"10 matches", kOmniboxUIMaxAutocompleteMatches10,
158 base::size(kOmniboxUIMaxAutocompleteMatches10), nullptr},
159 {"12 matches", kOmniboxUIMaxAutocompleteMatches12,
160 base::size(kOmniboxUIMaxAutocompleteMatches12), nullptr}};
161
Gauthier Ambard2392f2a2018-10-24 16:33:27162const FeatureEntry::FeatureParam kIconForSearchButtonGrey[] = {
163 {kIconForSearchButtonFeatureParameterName,
164 kIconForSearchButtonParameterGrey}};
165const FeatureEntry::FeatureParam kIconForSearchButtonColorful[] = {
166 {kIconForSearchButtonFeatureParameterName,
167 kIconForSearchButtonParameterColorful}};
168const FeatureEntry::FeatureParam kIconForSearchButtonMagnifying[] = {
169 {kIconForSearchButtonFeatureParameterName,
170 kIconForSearchButtonParameterMagnifying}};
171
172const FeatureEntry::FeatureVariation kIconForSearchButtonVariations[] = {
173 {"Grey search engine logo", kIconForSearchButtonGrey,
174 base::size(kIconForSearchButtonGrey), nullptr},
175 {"Colorful search engine logo", kIconForSearchButtonColorful,
176 base::size(kIconForSearchButtonColorful), nullptr},
177 {"Magnifying glass", kIconForSearchButtonMagnifying,
178 base::size(kIconForSearchButtonMagnifying), nullptr}};
179
Olivier Robince9386ebd2018-11-29 09:07:38180const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout3s[] = {
181 {crash_report::kDetectMainThreadFreezeParameterName,
182 crash_report::kDetectMainThreadFreezeParameter3s}};
183const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout5s[] = {
184 {crash_report::kDetectMainThreadFreezeParameterName,
185 crash_report::kDetectMainThreadFreezeParameter5s}};
186const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout7s[] = {
187 {crash_report::kDetectMainThreadFreezeParameterName,
188 crash_report::kDetectMainThreadFreezeParameter7s}};
189const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout9s[] = {
190 {crash_report::kDetectMainThreadFreezeParameterName,
191 crash_report::kDetectMainThreadFreezeParameter9s}};
192
193const FeatureEntry::FeatureVariation kDetectMainThreadFreezeVariations[] = {
194 {"3s", kDetectMainThreadFreezeTimeout3s,
195 base::size(kDetectMainThreadFreezeTimeout3s), nullptr},
196 {"5s", kDetectMainThreadFreezeTimeout5s,
197 base::size(kDetectMainThreadFreezeTimeout5s), nullptr},
198 {"7s", kDetectMainThreadFreezeTimeout7s,
199 base::size(kDetectMainThreadFreezeTimeout7s), nullptr},
200 {"9s", kDetectMainThreadFreezeTimeout9s,
201 base::size(kDetectMainThreadFreezeTimeout9s), nullptr}};
202
Caitlin Fischer37e01232019-05-24 13:05:45203const FeatureEntry::FeatureParam
204 kAutofillUseMobileLabelDisambiguationShowAll[] = {
205 {autofill::features::kAutofillUseMobileLabelDisambiguationParameterName,
206 autofill::features::
207 kAutofillUseMobileLabelDisambiguationParameterShowAll}};
208const FeatureEntry::FeatureParam
209 kAutofillUseMobileLabelDisambiguationShowOne[] = {
210 {autofill::features::kAutofillUseMobileLabelDisambiguationParameterName,
211 autofill::features::
212 kAutofillUseMobileLabelDisambiguationParameterShowOne}};
213
214const FeatureEntry::FeatureVariation
215 kAutofillUseMobileLabelDisambiguationVariations[] = {
216 {"(show all)", kAutofillUseMobileLabelDisambiguationShowAll,
217 base::size(kAutofillUseMobileLabelDisambiguationShowAll), nullptr},
218 {"(show one)", kAutofillUseMobileLabelDisambiguationShowOne,
219 base::size(kAutofillUseMobileLabelDisambiguationShowOne), nullptr}};
220
Cooper Knaak1e026562017-07-26 05:22:28221// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21222// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28223// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
224// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21225// macro for this type supplying the command line to the macro.
226// . MULTI_VALUE: a list of choices, the first of which should correspond to a
227// deactivated state for this lab (i.e. no command line option). To specify
228// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
229// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28230// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
231// either enabled, disabled, or uses the default value of the associated
232// base::Feature instance. To specify this type of entry use the macro
233// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
234// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
235// base::Feature instance. Choices corresponding to the default state, a
236// universally enabled state, and a universally disabled state are
237// automatically included. To specify this type of entry use the macro
238// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
239// the array of choices.
240//
sdefresne14900ee2015-11-27 14:43:21241// See the documentation of FeatureEntry for details on the fields.
242//
243// When adding a new choice, add it to the end of the list.
244const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46245 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28246 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46247 FEATURE_WITH_PARAMS_VALUE_TYPE(
248 security_state::features::kMarkHttpAsFeature,
249 kMarkHttpAsFeatureVariations,
250 "MarkHttpAs")},
Cooper Knaak1e026562017-07-26 05:22:28251 {"in-product-help-demo-mode-choice",
252 flag_descriptions::kInProductHelpDemoModeName,
253 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
254 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23255 feature_engagement::kIPHDemoMode,
256 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09257 "IPH_DemoMode")},
258 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
259 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18260 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Jean-François Geyelin30be5912017-08-25 12:05:38261 {"drag_and_drop", flag_descriptions::kDragAndDropName,
262 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41263 FEATURE_VALUE_TYPE(kDragAndDrop)},
Eugene But468b6d5f02018-10-18 21:17:45264 {"ignores-viewport-scale-limits",
265 flag_descriptions::kIgnoresViewportScaleLimitsName,
266 flag_descriptions::kIgnoresViewportScaleLimitsDescription,
267 flags_ui::kOsIos,
268 FEATURE_VALUE_TYPE(web::features::kIgnoresViewportScaleLimits)},
Danyao Wang34da6ff2017-10-30 15:16:56269 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
270 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
271 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22272 {"enable-autofill-credit-card-upload",
273 flag_descriptions::kAutofillCreditCardUploadName,
274 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24275 FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
Moe Ahmadid6d5d172018-06-20 17:20:23276 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
277 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
278 SINGLE_VALUE_TYPE_AND_VALUE(
279 switches::kSyncServiceURL,
280 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
281 {"wallet-service-use-sandbox",
282 flag_descriptions::kWalletServiceUseSandboxName,
283 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
284 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
285 autofill::switches::kWalletServiceUseSandbox,
286 "1",
287 autofill::switches::kWalletServiceUseSandbox,
288 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59289 {"show-autofill-type-predictions",
290 flag_descriptions::kShowAutofillTypePredictionsName,
291 flag_descriptions::kShowAutofillTypePredictionsDescription,
292 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46293 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22294 {"autofill-ios-delay-between-fields",
295 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
296 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
297 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Sylvain Defresneae6987e2018-03-01 13:21:40298 {"new-clear-browsing-data-ui",
299 flag_descriptions::kNewClearBrowsingDataUIName,
300 flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos,
301 FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)},
Olivier Robind81475b02018-06-20 21:30:11302 {"autofill-show-all-profiles-on-prefilled-forms",
303 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsName,
304 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsDescription,
305 flags_ui::kOsIos,
306 FEATURE_VALUE_TYPE(
307 autofill::features::kAutofillShowAllSuggestionsOnPrefilledForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08308 {"autofill-restrict-formless-form-extraction",
309 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
310 flag_descriptions::
311 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
312 flags_ui::kOsIos,
313 FEATURE_VALUE_TYPE(
314 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
Roger McFarlanee193ab122018-11-22 20:55:07315 {"autofill-rich-metadata-queries",
316 flag_descriptions::kAutofillRichMetadataQueriesName,
317 flag_descriptions::kAutofillRichMetadataQueriesDescription,
318 flags_ui::kOsIos,
319 FEATURE_VALUE_TYPE(autofill::features::kAutofillRichMetadataQueries)},
Kurt Horimotodc33af32018-05-01 01:39:14320 {"fullscreen-viewport-adjustment-experiment",
Chris Lu481a9322019-09-25 22:16:53321 flag_descriptions::kFullscreenSmoothScrollingName,
322 flag_descriptions::kFullscreenSmoothScrollingDescription, flags_ui::kOsIos,
323 FEATURE_VALUE_TYPE(fullscreen::features::kSmoothScrollingDefault)},
Roger McFarlane1a37d7b2018-04-20 22:45:19324 {"autofill-enforce-min-required-fields-for-heuristics",
325 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
326 flag_descriptions::
327 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
328 flags_ui::kOsIos,
329 FEATURE_VALUE_TYPE(
330 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
331 {"autofill-enforce-min-required-fields-for-query",
332 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
333 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
334 flags_ui::kOsIos,
335 FEATURE_VALUE_TYPE(
336 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
337 {"autofill-enforce-min-required-fields-for-upload",
338 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
339 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
340 flags_ui::kOsIos,
341 FEATURE_VALUE_TYPE(
342 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Roger McFarlane2eceba982018-05-18 01:37:11343 {"autofill-cache-query-responses",
344 flag_descriptions::kAutofillCacheQueryResponsesName,
345 flag_descriptions::kAutofillCacheQueryResponsesDescription,
346 flags_ui::kOsIos,
347 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Jeffrey Cohen05cdafa392018-08-15 20:49:17348 {"autofill-enable-company-name",
349 flag_descriptions::kAutofillEnableCompanyNameName,
350 flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos,
351 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)},
Yi Su392b3032018-06-05 07:26:47352 {"webpage-text-accessibility",
353 flag_descriptions::kWebPageTextAccessibilityName,
354 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
355 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
mrefaat4539b032018-08-02 22:25:45356 {"app-launcher-refresh", flag_descriptions::kAppLauncherRefreshName,
357 flag_descriptions::kAppLauncherRefreshDescription, flags_ui::kOsIos,
358 FEATURE_VALUE_TYPE(kAppLauncherRefresh)},
Kurt Horimoto79d590b2018-09-12 19:09:28359 {"toolbar-container", flag_descriptions::kToolbarContainerName,
360 flag_descriptions::kToolbarContainerDescription, flags_ui::kOsIos,
361 FEATURE_VALUE_TYPE(toolbar_container::kToolbarContainerEnabled)},
[email protected]5b899dc2018-10-02 09:20:01362 {"omnibox-popup-shortcuts",
363 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateName,
364 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateDescription,
365 flags_ui::kOsIos,
366 FEATURE_VALUE_TYPE(omnibox::kOmniboxPopupShortcutIconsInZeroState)},
Valeriya Sinevicha79dc612018-09-25 14:49:09367 {"use-multilogin-endpoint", flag_descriptions::kUseMultiloginEndpointName,
368 flag_descriptions::kUseMultiloginEndpointDescription, flags_ui::kOsIos,
369 FEATURE_VALUE_TYPE(kUseMultiloginEndpoint)},
Ce Chen20af01c2019-07-02 19:16:36370 {"omnibox-on-device-head-suggestions",
371 flag_descriptions::kOmniboxOnDeviceHeadSuggestionsName,
372 flag_descriptions::kOmniboxOnDeviceHeadSuggestionsDescription,
373 flags_ui::kOsIos, FEATURE_VALUE_TYPE(omnibox::kOnDeviceHeadProvider)},
Stepan Khapugincc4e9842019-01-23 13:38:13374 {"omnibox-ui-max-autocomplete-matches",
375 flag_descriptions::kOmniboxUIMaxAutocompleteMatchesName,
376 flag_descriptions::kOmniboxUIMaxAutocompleteMatchesDescription,
377 flags_ui::kOsIos,
378 FEATURE_WITH_PARAMS_VALUE_TYPE(
379 omnibox::kUIExperimentMaxAutocompleteMatches,
380 kOmniboxUIMaxAutocompleteMatchesVariations,
381 "OmniboxUIMaxAutocompleteVariations")},
Gauthier Ambard2392f2a2018-10-24 16:33:27382 {"search-icon-toggle", flag_descriptions::kSearchIconToggleName,
383 flag_descriptions::kSearchIconToggleDescription, flags_ui::kOsIos,
384 FEATURE_WITH_PARAMS_VALUE_TYPE(kIconForSearchButtonFeature,
385 kIconForSearchButtonVariations,
386 "ToggleSearchButtonIcon")},
Olivier Robin2a898dc2018-10-31 14:37:04387 {"enable-breakpad-upload-no-delay",
388 flag_descriptions::kBreakpadNoDelayInitialUploadName,
389 flag_descriptions::kBreakpadNoDelayInitialUploadDescription,
390 flags_ui::kOsIos,
391 FEATURE_VALUE_TYPE(crash_report::kBreakpadNoDelayInitialUpload)},
Kurt Horimoto9165404a2018-11-13 23:48:12392 {"non-modal-dialogs", flag_descriptions::kNonModalDialogsName,
393 flag_descriptions::kNonModalDialogsDescription, flags_ui::kOsIos,
394 FEATURE_VALUE_TYPE(dialogs::kNonModalDialogs)},
Olivier Robince9386ebd2018-11-29 09:07:38395 {"detect-main-thread-freeze",
396 flag_descriptions::kDetectMainThreadFreezeName,
397 flag_descriptions::kDetectMainThreadFreezeDescription, flags_ui::kOsIos,
398 FEATURE_WITH_PARAMS_VALUE_TYPE(crash_report::kDetectMainThreadFreeze,
399 kDetectMainThreadFreezeVariations,
400 "DetectMainThreadFreeze")},
Mohamed Amir Yosef9e8a1f02018-12-03 21:41:14401 {"enable-sync-uss-bookmarks",
402 flag_descriptions::kEnableSyncUSSBookmarksName,
403 flag_descriptions::kEnableSyncUSSBookmarksDescription, flags_ui::kOsIos,
404 FEATURE_VALUE_TYPE(switches::kSyncUSSBookmarks)},
sczs80a6f462018-12-05 20:37:18405 {"infobar-ui-reboot", flag_descriptions::kInfobarUIRebootName,
406 flag_descriptions::kInfobarUIRebootDescription, flags_ui::kOsIos,
407 FEATURE_VALUE_TYPE(kInfobarUIReboot)},
Chris Lu77905ac2018-12-06 20:46:51408 {"find-in-page-iframe", flag_descriptions::kFindInPageiFrameName,
409 flag_descriptions::kFindInPageiFrameDescription, flags_ui::kOsIos,
410 FEATURE_VALUE_TYPE(kFindInPageiFrame)},
Robbie Gibson80d732e2019-01-10 10:42:49411 {"enable-clipboard-provider-text-suggestions",
412 flag_descriptions::kEnableClipboardProviderTextSuggestionsName,
413 flag_descriptions::kEnableClipboardProviderTextSuggestionsDescription,
414 flags_ui::kOsIos,
415 FEATURE_VALUE_TYPE(omnibox::kEnableClipboardProviderTextSuggestions)},
416 {"enable-clipboard-provider-image-suggestions",
417 flag_descriptions::kEnableClipboardProviderImageSuggestionsName,
418 flag_descriptions::kEnableClipboardProviderImageSuggestionsDescription,
419 flags_ui::kOsIos,
420 FEATURE_VALUE_TYPE(omnibox::kEnableClipboardProviderImageSuggestions)},
421 {"copied-content-behavior", flag_descriptions::kCopiedContentBehaviorName,
422 flag_descriptions::kCopiedContentBehaviorName, flags_ui::kOsIos,
423 FEATURE_VALUE_TYPE(kCopiedContentBehavior)},
edchin5ae0b4c2019-01-06 06:52:28424 {"snapshot-draw-view", flag_descriptions::kSnapshotDrawViewName,
425 flag_descriptions::kSnapshotDrawViewDescription, flags_ui::kOsIos,
426 FEATURE_VALUE_TYPE(kSnapshotDrawView)},
Justin Cohen20b6f072019-01-16 01:38:50427#if defined(DCHECK_IS_CONFIGURABLE)
428 {"dcheck-is-fatal", flag_descriptions::kDcheckIsFatalName,
429 flag_descriptions::kDcheckIsFatalDescription, flags_ui::kOsIos,
430 FEATURE_VALUE_TYPE(base::kDCheckIsFatalFeature)},
431#endif // defined(DCHECK_IS_CONFIGURABLE)
Gauthier Ambard5f610862019-01-17 11:43:55432 {"settings-refresh", flag_descriptions::kSettingsRefreshName,
433 flag_descriptions::kSettingsRefreshDescription, flags_ui::kOsIos,
434 FEATURE_VALUE_TYPE(kSettingsRefresh)},
Justin Cohencd633af2019-01-29 20:19:00435 {"browser-container-keeps-content-view",
436 flag_descriptions::kBrowserContainerKeepsContentViewName,
437 flag_descriptions::kBrowserContainerKeepsContentViewDescription,
438 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerKeepsContentView)},
Gauthier Ambardef4442a2019-02-15 11:14:42439 {"web-clear-browsing-data", flag_descriptions::kWebClearBrowsingDataName,
440 flag_descriptions::kWebClearBrowsingDataDescription, flags_ui::kOsIos,
Gauthier Ambard33e03302019-02-21 13:28:58441 FEATURE_VALUE_TYPE(kWebClearBrowsingData)},
Chris Lu8153e6e2019-03-26 16:28:21442 {"send-uma-cellular", flag_descriptions::kSendUmaOverAnyNetwork,
443 flag_descriptions::kSendUmaOverAnyNetworkDescription, flags_ui::kOsIos,
Chris Lu0683adf2019-02-26 15:56:45444 FEATURE_VALUE_TYPE(kUmaCellular)},
Mohamed Amir Yosef79feb7752019-03-04 09:49:37445 {"enable-sync-uss-passwords",
446 flag_descriptions::kEnableSyncUSSPasswordsName,
447 flag_descriptions::kEnableSyncUSSPasswordsDescription, flags_ui::kOsIos,
448 FEATURE_VALUE_TYPE(switches::kSyncUSSPasswords)},
Olivier Robin091319d2019-03-04 10:45:34449 {"offline-page-without-native-content",
450 flag_descriptions::kOfflineVersionWithoutNativeContentName,
451 flag_descriptions::kOfflineVersionWithoutNativeContentDescription,
452 flags_ui::kOsIos,
453 FEATURE_VALUE_TYPE(reading_list::kOfflineVersionWithoutNativeContent)},
Jared Saul8c224932019-03-12 15:01:18454 {"autofill-no-local-save-on-upload-success",
455 flag_descriptions::kAutofillNoLocalSaveOnUploadSuccessName,
456 flag_descriptions::kAutofillNoLocalSaveOnUploadSuccessDescription,
457 flags_ui::kOsIos,
458 FEATURE_VALUE_TYPE(
459 autofill::features::kAutofillNoLocalSaveOnUploadSuccess)},
Jared Saul63f598a12019-03-22 23:40:26460 {"autofill-no-local-save-on-unmask-success",
461 flag_descriptions::kAutofillNoLocalSaveOnUnmaskSuccessName,
462 flag_descriptions::kAutofillNoLocalSaveOnUnmaskSuccessDescription,
463 flags_ui::kOsIos,
464 FEATURE_VALUE_TYPE(
465 autofill::features::kAutofillNoLocalSaveOnUnmaskSuccess)},
Stepan Khapugin13b7427a2019-04-02 13:17:54466 {"new-omnibox-popup-layout", flag_descriptions::kNewOmniboxPopupLayoutName,
467 flag_descriptions::kNewOmniboxPopupLayoutDescription, flags_ui::kOsIos,
468 FEATURE_VALUE_TYPE(kNewOmniboxPopupLayout)},
jdoerrieb37f22c2019-04-02 15:50:06469 {"fill-on-account-select-http",
470 flag_descriptions::kFillOnAccountSelectHttpName,
471 flag_descriptions::kFillOnAccountSelectHttpDescription, flags_ui::kOsIos,
472 FEATURE_VALUE_TYPE(password_manager::features::kFillOnAccountSelectHttp)},
Nazerke4179c0e2019-04-11 15:43:34473 {"omnibox-use-default-search-engine-favicon",
474 flag_descriptions::kOmniboxUseDefaultSearchEngineFaviconName,
475 flag_descriptions::kOmniboxUseDefaultSearchEngineFaviconDescription,
476 flags_ui::kOsIos,
477 FEATURE_VALUE_TYPE(kOmniboxUseDefaultSearchEngineFavicon)},
Sébastien Séguin-Gagnon30481922019-04-24 21:31:00478 {"enable-send-tab-to-self-broadcast",
479 flag_descriptions::kSendTabToSelfBroadcastName,
480 flag_descriptions::kSendTabToSelfBroadcastDescription, flags_ui::kOsIos,
481 FEATURE_VALUE_TYPE(send_tab_to_self::kSendTabToSelfBroadcast)},
Caitlin Fischer43edd90a2019-05-01 13:24:30482 {"autofill-use-mobile-label-disambiguation",
483 flag_descriptions::kAutofillUseMobileLabelDisambiguationName,
484 flag_descriptions::kAutofillUseMobileLabelDisambiguationDescription,
485 flags_ui::kOsIos,
Caitlin Fischer37e01232019-05-24 13:05:45486 FEATURE_WITH_PARAMS_VALUE_TYPE(
487 autofill::features::kAutofillUseMobileLabelDisambiguation,
488 kAutofillUseMobileLabelDisambiguationVariations,
489 "AutofillUseMobileLabelDisambiguation")},
Caitlin Fischer6d609542019-05-01 21:59:21490 {"enable-autofill-prune-suggestions",
491 flag_descriptions::kAutofillPruneSuggestionsName,
492 flag_descriptions::kAutofillPruneSuggestionsDescription, flags_ui::kOsIos,
493 FEATURE_VALUE_TYPE(autofill::features::kAutofillPruneSuggestions)},
Moe Ahmadieb438742019-05-08 20:17:56494 {"language-settings", flag_descriptions::kLanguageSettingsName,
495 flag_descriptions::kLanguageSettingsDescription, flags_ui::kOsIos,
496 FEATURE_VALUE_TYPE(kLanguageSettings)},
Gauthier Ambard4d42f39d2019-06-24 13:05:33497 {"toolbar-new-tab-button", flag_descriptions::kToolbarNewTabButtonName,
498 flag_descriptions::kToolbarNewTabButtonDescription, flags_ui::kOsIos,
499 FEATURE_VALUE_TYPE(kToolbarNewTabButton)},
Yi Su3e445132019-06-28 10:18:04500 {"optional-article-thumbnail",
501 flag_descriptions::kOptionalArticleThumbnailName,
502 flag_descriptions::kOptionalArticleThumbnailDescription, flags_ui::kOsIos,
503 FEATURE_VALUE_TYPE(kOptionalArticleThumbnail)},
Maksim Moskvitin35b09c1bf2019-06-28 17:29:48504 {"enable-sync-uss-nigori", flag_descriptions::kEnableSyncUSSNigoriName,
505 flag_descriptions::kEnableSyncUSSNigoriDescription, flags_ui::kOsIos,
506 FEATURE_VALUE_TYPE(switches::kSyncUSSNigori)},
Alfonso Garza7d21aa42019-07-15 21:25:07507 {"enable-autofill-save-card-show-no-thanks",
508 flag_descriptions::kEnableAutofillSaveCardShowNoThanksName,
509 flag_descriptions::kEnableAutofillSaveCardShowNoThanksDescription,
510 flags_ui::kOsIos,
511 FEATURE_VALUE_TYPE(autofill::features::kAutofillSaveCardShowNoThanks)},
Tanisha Mandre549612ea2019-07-17 11:36:15512 {"settings-add-payment-method",
513 flag_descriptions::kSettingsAddPaymentMethodName,
514 flag_descriptions::kSettingsAddPaymentMethodDescription, flags_ui::kOsIos,
515 FEATURE_VALUE_TYPE(kSettingsAddPaymentMethod)},
sczs76b9ba02019-07-23 23:34:30516 {"collections-card-presentation-style",
517 flag_descriptions::kCollectionsCardPresentationStyleName,
518 flag_descriptions::kCollectionsCardPresentationStyleDescription,
519 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kCollectionsCardPresentationStyle)},
Jared Saul3f520c62019-09-03 23:58:12520 {"enable-autofill-credit-card-upload-editable-cardholder-name",
521 flag_descriptions::
522 kEnableAutofillCreditCardUploadEditableCardholderNameName,
523 flag_descriptions::
524 kEnableAutofillCreditCardUploadEditableCardholderNameDescription,
525 flags_ui::kOsIos,
526 FEATURE_VALUE_TYPE(
527 autofill::features::kAutofillUpstreamEditableCardholderName)},
528 {"enable-autofill-credit-card-upload-editable-expiration-date",
529 flag_descriptions::
530 kEnableAutofillCreditCardUploadEditableExpirationDateName,
531 flag_descriptions::
532 kEnableAutofillCreditCardUploadEditableExpirationDateDescription,
533 flags_ui::kOsIos,
534 FEATURE_VALUE_TYPE(
535 autofill::features::kAutofillUpstreamEditableExpirationDate)},
Tanisha Mandre3a14d382019-09-05 17:33:44536 {"credit-card-scanner", flag_descriptions::kCreditCardScannerName,
537 flag_descriptions::kCreditCardScannerDescription, flags_ui::kOsIos,
538 FEATURE_VALUE_TYPE(kCreditCardScanner)},
Mike Doughertyb6c770d2019-09-13 22:56:46539 {"ios-breadcrumbs", flag_descriptions::kLogBreadcrumbsName,
540 flag_descriptions::kLogBreadcrumbsDescription, flags_ui::kOsIos,
541 FEATURE_VALUE_TYPE(kLogBreadcrumbs)},
Ioana Pandele0a74f422019-09-25 12:27:45542 {"password-leak-detection", flag_descriptions::kPasswordLeakDetectionName,
543 flag_descriptions::kPasswordLeakDetectionDescription, flags_ui::kOsIos,
544 FEATURE_VALUE_TYPE(password_manager::features::kLeakDetection)},
Jérôme Lebelc374fdd2019-09-27 10:36:48545 {"force-startup-signin-promo",
546 flag_descriptions::kForceStartupSigninPromoName,
547 flag_descriptions::kForceStartupSigninPromoDescription, flags_ui::kOsIos,
548 FEATURE_VALUE_TYPE(signin::kForceStartupSigninPromo)},
Justin Cohenc57413a2019-09-30 19:42:29549 {"embedder-block-restore-url",
550 flag_descriptions::kEmbedderBlockRestoreUrlName,
551 flag_descriptions::kEmbedderBlockRestoreUrlDescription, flags_ui::kOsIos,
552 FEATURE_VALUE_TYPE(kEmbedderBlockRestoreUrl)},
sczs6c3202e2019-10-01 00:22:46553 {"messages-confirm-infobars",
554 flag_descriptions::kConfirmInfobarMessagesUIName,
555 flag_descriptions::kConfirmInfobarMessagesUIDescription, flags_ui::kOsIos,
556 FEATURE_VALUE_TYPE(kConfirmInfobarMessagesUI)},
David Jeana9bf62b2019-10-04 11:53:36557 {"disable-animation-on-low-battery",
558 flag_descriptions::kDisableAnimationOnLowBatteryName,
559 flag_descriptions::kDisableAnimationOnLowBatteryDescription,
560 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kDisableAnimationOnLowBattery)},
Gauthier Ambardcfd85182018-01-05 10:37:46561};
sdefresne14900ee2015-11-27 14:43:21562
563// Add all switches from experimental flags to |command_line|.
564void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
565 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
566
sdefresne14900ee2015-11-27 14:43:21567 // Set the UA flag if UseMobileSafariUA is enabled.
568 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
569 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
570 // Chrome puts its product token.
avi571943672015-12-22 02:12:49571 int32_t major = 0;
572 int32_t minor = 0;
573 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21574 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
575 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
576
577 command_line->AppendSwitchASCII(switches::kUserAgent,
578 web::BuildUserAgentFromProduct(product));
579 }
580
581 // Freeform commandline flags. These are added last, so that any flags added
582 // earlier in this function take precedence.
583 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
584 base::CommandLine::StringVector flags;
585 // Append an empty "program" argument.
586 flags.push_back("");
587
588 // The number of flags corresponds to the number of text fields in
589 // Experimental.plist.
590 const int kNumFreeformFlags = 5;
591 for (int i = 1; i <= kNumFreeformFlags; ++i) {
592 NSString* key =
593 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
594 NSString* flag = [defaults stringForKey:key];
595 if ([flag length]) {
Robbie Gibsonc91ce622019-05-20 14:44:33596 // iOS keyboard replaces -- with —, so undo that.
597 flag = [flag stringByReplacingOccurrencesOfString:@"—"
598 withString:@"--"
599 options:0
600 range:NSMakeRange(0, 1)];
601 // To make things easier, allow flags with no dashes by prepending them
602 // here. This also allows for flags that just have one dash if they
603 // exist.
604 if (![flag hasPrefix:@"-"]) {
605 flag = [@"--" stringByAppendingString:flag];
606 }
sdefresne14900ee2015-11-27 14:43:21607 flags.push_back(base::SysNSStringToUTF8(flag));
608 }
609 }
610
611 base::CommandLine temp_command_line(flags);
612 command_line->AppendArguments(temp_command_line, false);
613 }
msardafc76f662017-02-24 12:46:28614
justincohendacc85d2017-06-28 23:34:10615 // Populate command line flag for 3rd party keyboard omnibox workaround.
616 NSString* enableThirdPartyKeyboardWorkaround =
617 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
618 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
619 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
620 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
621 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
622 }
623
msardafc76f662017-02-24 12:46:28624 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
625 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21626}
627
628bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
629 return false;
630}
631
Sylvain Defresne8327a2f2019-01-17 14:19:18632flags_ui::FlagsState& GetGlobalFlagsState() {
633 static base::NoDestructor<flags_ui::FlagsState> flags_state(
634 kFeatureEntries, base::size(kFeatureEntries));
635 return *flags_state;
636}
sdefresne14900ee2015-11-27 14:43:21637} // namespace
638
639void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
640 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02641 AppendSwitchesFromExperimentalSettings(command_line);
Sylvain Defresne8327a2f2019-01-17 14:19:18642 GetGlobalFlagsState().ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11643 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53644 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21645}
646
jkrcalbf073372016-07-29 07:21:31647std::vector<std::string> RegisterAllFeatureVariationParameters(
648 flags_ui::FlagsStorage* flags_storage,
649 base::FeatureList* feature_list) {
Sylvain Defresne8327a2f2019-01-17 14:19:18650 return GetGlobalFlagsState().RegisterAllFeatureVariationParameters(
651 flags_storage, feature_list);
jkrcalbf073372016-07-29 07:21:31652}
653
sdefresne14900ee2015-11-27 14:43:21654void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
655 flags_ui::FlagAccess access,
656 base::ListValue* supported_entries,
657 base::ListValue* unsupported_entries) {
Sylvain Defresne8327a2f2019-01-17 14:19:18658 GetGlobalFlagsState().GetFlagFeatureEntries(
sdefresne14900ee2015-11-27 14:43:21659 flags_storage, access, supported_entries, unsupported_entries,
660 base::Bind(&SkipConditionalFeatureEntry));
661}
662
663void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
664 const std::string& internal_name,
665 bool enable) {
Sylvain Defresne8327a2f2019-01-17 14:19:18666 GetGlobalFlagsState().SetFeatureEntryEnabled(flags_storage, internal_name,
667 enable);
sdefresne14900ee2015-11-27 14:43:21668}
669
670void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
Sylvain Defresne8327a2f2019-01-17 14:19:18671 GetGlobalFlagsState().ResetAllFlags(flags_storage);
sdefresne14900ee2015-11-27 14:43:21672}
673
674namespace testing {
675
676const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
kokihoon189a4022018-10-13 02:43:44677 *count = base::size(kFeatureEntries);
sdefresne14900ee2015-11-27 14:43:21678 return kFeatureEntries;
679}
680
681} // namespace testing