blob: 8d88b1e3bc02aef5013309832b285b2e189edbdb [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"
danakjdb9ae7942020-11-11 16:01:3516#include "base/callback_helpers.h"
Hans Wennborg3a2fb61f2020-05-11 15:51:1617#include "base/check_op.h"
sdefresne14900ee2015-11-27 14:43:2118#include "base/command_line.h"
Lei Zhangd4a2f8e2021-07-08 03:43:2819#include "base/cxx17_backports.h"
David Jean5ca263c2021-08-18 09:19:3020#import "base/mac/foundation_util.h"
Sylvain Defresne8327a2f2019-01-17 14:19:1821#include "base/no_destructor.h"
sdefresne14900ee2015-11-27 14:43:2122#include "base/strings/stringprintf.h"
23#include "base/strings/sys_string_conversions.h"
Sebastien Marchand75a7cdf2018-11-13 23:47:0324#include "base/system/sys_info.h"
Mohamad Ahmadic4df81f2017-12-20 04:41:5925#include "components/autofill/core/common/autofill_features.h"
Jared Sauld998539f2019-03-19 15:11:1726#include "components/autofill/core/common/autofill_payments_features.h"
Moe Ahmadid6d5d172018-06-20 17:20:2327#include "components/autofill/core/common/autofill_switches.h"
Olivier Robin3d60411622018-02-23 10:03:2228#include "components/autofill/ios/browser/autofill_switches.h"
Jesse McKenna85c1a59f2021-05-05 19:08:3029#include "components/breadcrumbs/core/features.h"
Robbie Gibson5e3436632020-04-27 15:48:0430#include "components/content_settings/core/common/features.h"
sdefresne14900ee2015-11-27 14:43:2131#include "components/dom_distiller/core/dom_distiller_switches.h"
Guillaume Jenkins4e6ac1e2020-11-11 16:57:4032#include "components/enterprise/browser/enterprise_switches.h"
Tommy Nyquistc1d6dea12017-07-26 20:37:2333#include "components/feature_engagement/public/feature_constants.h"
34#include "components/feature_engagement/public/feature_list.h"
edchind847c0962021-03-03 18:17:0535#include "components/feed/feed_feature_list.h"
sdefresne14900ee2015-11-27 14:43:2136#include "components/flags_ui/feature_entry.h"
37#include "components/flags_ui/feature_entry_macros.h"
38#include "components/flags_ui/flags_storage.h"
39#include "components/flags_ui/flags_ui_switches.h"
Tanja Gornakb0985dd2018-10-11 17:24:4040#include "components/invalidation/impl/invalidation_switches.h"
noyau4cfb1332016-10-25 17:05:4241#include "components/ntp_tiles/switches.h"
Justin Donnelly33d712e2017-08-23 21:32:5142#include "components/omnibox/browser/omnibox_field_trial.h"
Tomasz Wiszkowskid938a1112019-03-06 18:01:5743#include "components/omnibox/common/omnibox_features.h"
Raj T3898f032021-08-19 23:51:2744#include "components/optimization_guide/core/optimization_guide_features.h"
Ioana Pandeled14ce9e2017-11-28 14:41:4645#include "components/password_manager/core/common/password_manager_features.h"
mathp9b4c11d2017-07-06 20:24:1346#include "components/payments/core/features.h"
Guillaume Jenkinseeb7007c2020-06-25 22:55:4047#import "components/policy/core/common/policy_loader_ios_constants.h"
48#include "components/policy/policy_constants.h"
Emily Starkbafa9062017-12-27 15:22:4649#include "components/security_state/core/features.h"
Victor Hugo Vianna Silva0399402f2021-09-07 21:41:2550#import "components/send_tab_to_self/features.h"
Sébastien Séguin-Gagnondcb854b2019-04-10 16:36:4451#include "components/send_tab_to_self/features.h"
Tommy Martino0caf3362021-01-13 20:29:5852#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
Valeriya Sinevicha79dc612018-09-25 14:49:0953#include "components/signin/core/browser/account_reconcilor.h"
Jérôme Lebelc374fdd2019-09-27 10:36:4854#include "components/signin/ios/browser/features.h"
Colin Blundell3517170e2019-07-11 08:16:3455#include "components/signin/public/base/signin_switches.h"
sdefresne36579782016-02-05 11:08:2556#include "components/strings/grit/components_strings.h"
Ewann570a6302021-08-17 07:22:4257#include "components/sync/base/pref_names.h"
Rushan Suleymanov988ad372020-07-26 19:10:0858#include "components/sync/base/sync_base_switches.h"
Moe Ahmadid6d5d172018-06-20 17:20:2359#include "components/sync/driver/sync_driver_switches.h"
Moe Ahmadie4cce1f2018-12-18 23:48:0160#include "components/translate/core/browser/translate_prefs.h"
Sylvain Defresneae6987e2018-03-01 13:21:4061#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2162#include "ios/chrome/browser/chrome_switches.h"
Eugene But2823dc7e2020-07-21 18:10:3763#include "ios/chrome/browser/crash_report/features.h"
Nazerke21bdc45a2019-07-11 09:02:0564#include "ios/chrome/browser/flags/ios_chrome_flag_descriptions.h"
edchin68696842020-04-09 17:19:3165#include "ios/chrome/browser/policy/policy_features.h"
Vincent Boisselle19200bc2021-09-01 17:58:2566#include "ios/chrome/browser/policy/policy_util.h"
Sylvain Defresne9c107082020-10-27 16:39:1367#include "ios/chrome/browser/screen_time/screen_time_buildflags.h"
Gauthier Ambard33e03302019-02-21 13:28:5868#include "ios/chrome/browser/system_flags.h"
adamta22a4d502020-05-21 03:12:2169#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_feature.h"
Javier Ernesto Flores Robles209b2822021-03-25 19:16:5070#import "ios/chrome/browser/ui/default_promo/default_browser_utils.h"
Ewann1a9d33d2021-06-14 11:12:2471#import "ios/chrome/browser/ui/download/features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3572#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
adamta273568472020-12-04 23:53:5773#import "ios/chrome/browser/ui/ntp/new_tab_page_feature.h"
Tina Wang17514e2f2021-09-24 23:57:1874#import "ios/chrome/browser/ui/overlays/infobar_banner/infobar_banner_features.h"
Robbie Gibson686c56732021-10-04 17:11:4575#import "ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h"
Chris Lue45c94c62021-05-21 01:32:5976#import "ios/chrome/browser/ui/reading_list/reading_list_features.h"
gogerald0ff29e52021-02-03 18:56:1977#import "ios/chrome/browser/ui/start_surface/start_surface_features.h"
Nazerke0bf10c42020-11-12 11:17:3278#import "ios/chrome/browser/ui/tab_switcher/tab_grid/features.h"
Kurt Horimoto79d590b2018-09-12 19:09:2879#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h"
Justin Cohen2d81c582018-01-22 14:46:4480#include "ios/chrome/browser/ui/ui_feature_flags.h"
Yi Su392b3032018-06-05 07:26:4781#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2182#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2883#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Eugene But61818bc2019-04-15 21:04:0784#include "ios/web/common/features.h"
Eugene Bute79f2742019-07-26 17:07:2285#include "ios/web/common/user_agent.h"
Eugene Butb1416232019-07-22 17:31:5886#include "ios/web/common/web_view_creation_util.h"
sdefresne14900ee2015-11-27 14:43:2187
Sylvain Defresne9c107082020-10-27 16:39:1388#if BUILDFLAG(IOS_SCREEN_TIME_ENABLED)
89#include "ios/chrome/browser/screen_time/features.h"
90#endif
91
sdefresne14900ee2015-11-27 14:43:2192#if !defined(OFFICIAL_BUILD)
93#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2294#endif
stkhapuginc1be1792016-12-13 14:30:5395
96#if !defined(__has_feature) || !__has_feature(objc_arc)
97#error "This file requires ARC support."
98#endif
sdefresne14900ee2015-11-27 14:43:2199
elawrence816f6790e2017-06-16 18:19:28100using flags_ui::FeatureEntry;
101
sdefresne14900ee2015-11-27 14:43:21102namespace {
Emily Starkbafa9062017-12-27 15:22:46103
Olivier Robin3d60411622018-02-23 10:03:22104const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
105 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
106 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
107 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
108 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
109 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
110 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
111 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
112 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
113 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
114};
115
Nohemi Fernandez222d6d42020-09-30 20:35:57116const FeatureEntry::Choice kDelayThresholdMinutesToUpdateGaiaCookieChoices[] = {
117 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
118 {"0", signin::kDelayThresholdMinutesToUpdateGaiaCookie, "0"},
119 {"10", signin::kDelayThresholdMinutesToUpdateGaiaCookie, "10"},
120 {"60", signin::kDelayThresholdMinutesToUpdateGaiaCookie, "60"},
121};
122
Nohemi Fernandezc00842a2021-07-26 11:47:34123const FeatureEntry::Choice
124 kWaitThresholdMillisecondsForCapabilitiesApiChoices[] = {
125 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
126 {"200", signin::kWaitThresholdMillisecondsForCapabilitiesApi, "200"},
127 {"500", signin::kWaitThresholdMillisecondsForCapabilitiesApi, "500"},
128 {"5000", signin::kWaitThresholdMillisecondsForCapabilitiesApi, "5000"},
129};
130
Ce Chenc8d803a2020-04-27 09:31:33131const FeatureEntry::FeatureVariation
Ce Chenc8d803a2020-04-27 09:31:33132 kOmniboxOnDeviceHeadSuggestNonIncognitoExperimentVariations[] = {
133 {
134 "relevance-1000",
135 (FeatureEntry::FeatureParam[]){
136 {OmniboxFieldTrial::kOnDeviceHeadSuggestMaxScoreForNonUrlInput,
137 "1000"},
138 {OmniboxFieldTrial::kOnDeviceHeadSuggestDemoteMode,
139 "decrease-relevances"}},
140 2,
141 nullptr,
142 },
143 {
Ce Chen2616ea92021-03-10 04:13:07144 "no-delay-relevance-1000",
Ce Chenc8d803a2020-04-27 09:31:33145 (FeatureEntry::FeatureParam[]){
146 {OmniboxFieldTrial::kOnDeviceHeadSuggestDelaySuggestRequestMs,
Ce Chen2616ea92021-03-10 04:13:07147 "0"},
Ce Chenc8d803a2020-04-27 09:31:33148 {OmniboxFieldTrial::kOnDeviceHeadSuggestMaxScoreForNonUrlInput,
149 "1000"},
150 {OmniboxFieldTrial::kOnDeviceHeadSuggestDemoteMode,
151 "decrease-relevances"}},
152 3,
153 nullptr,
154 }};
Ce Chen104a5382019-12-10 01:09:05155
Stepan Khapugincc4e9842019-01-23 13:38:13156const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches3[] = {
157 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "3"}};
158const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches4[] = {
159 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "4"}};
160const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches5[] = {
161 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "5"}};
162const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches6[] = {
163 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "6"}};
164const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches8[] = {
165 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "8"}};
166const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches10[] = {
167 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "10"}};
168const FeatureEntry::FeatureParam kOmniboxUIMaxAutocompleteMatches12[] = {
169 {OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, "12"}};
170
171const FeatureEntry::FeatureVariation
172 kOmniboxUIMaxAutocompleteMatchesVariations[] = {
173 {"3 matches", kOmniboxUIMaxAutocompleteMatches3,
174 base::size(kOmniboxUIMaxAutocompleteMatches3), nullptr},
175 {"4 matches", kOmniboxUIMaxAutocompleteMatches4,
176 base::size(kOmniboxUIMaxAutocompleteMatches4), nullptr},
177 {"5 matches", kOmniboxUIMaxAutocompleteMatches5,
178 base::size(kOmniboxUIMaxAutocompleteMatches5), nullptr},
179 {"6 matches", kOmniboxUIMaxAutocompleteMatches6,
180 base::size(kOmniboxUIMaxAutocompleteMatches6), nullptr},
181 {"8 matches", kOmniboxUIMaxAutocompleteMatches8,
182 base::size(kOmniboxUIMaxAutocompleteMatches8), nullptr},
183 {"10 matches", kOmniboxUIMaxAutocompleteMatches10,
184 base::size(kOmniboxUIMaxAutocompleteMatches10), nullptr},
185 {"12 matches", kOmniboxUIMaxAutocompleteMatches12,
186 base::size(kOmniboxUIMaxAutocompleteMatches12), nullptr}};
187
Caitlin Fischer37e01232019-05-24 13:05:45188const FeatureEntry::FeatureParam
189 kAutofillUseMobileLabelDisambiguationShowAll[] = {
190 {autofill::features::kAutofillUseMobileLabelDisambiguationParameterName,
191 autofill::features::
192 kAutofillUseMobileLabelDisambiguationParameterShowAll}};
193const FeatureEntry::FeatureParam
194 kAutofillUseMobileLabelDisambiguationShowOne[] = {
195 {autofill::features::kAutofillUseMobileLabelDisambiguationParameterName,
196 autofill::features::
197 kAutofillUseMobileLabelDisambiguationParameterShowOne}};
198
199const FeatureEntry::FeatureVariation
200 kAutofillUseMobileLabelDisambiguationVariations[] = {
201 {"(show all)", kAutofillUseMobileLabelDisambiguationShowAll,
202 base::size(kAutofillUseMobileLabelDisambiguationShowAll), nullptr},
203 {"(show one)", kAutofillUseMobileLabelDisambiguationShowOne,
204 base::size(kAutofillUseMobileLabelDisambiguationShowOne), nullptr}};
205
Javier Ernesto Flores Roblese85f4a12021-02-23 18:10:10206const FeatureEntry::FeatureParam
Javier Ernesto Flores Robles159414232021-06-16 14:29:59207 kDefaultBrowserFullscreenPromoExperimentRemindMeLater[] = {
208 {kDefaultBrowserFullscreenPromoExperimentRemindMeGroupParam, "true"}};
209const FeatureEntry::FeatureVariation
210 kDefaultBrowserFullscreenPromoExperimentVariations[] = {
211 {"Remind me later",
212 kDefaultBrowserFullscreenPromoExperimentRemindMeLater,
213 base::size(kDefaultBrowserFullscreenPromoExperimentRemindMeLater),
214 nullptr}};
215
gogeralddb0d8ae2020-11-13 03:56:58216const FeatureEntry::FeatureParam kDiscoverFeedInNtpEnableNativeUI[] = {
217 {kDiscoverFeedIsNativeUIEnabled, "true"}};
218const FeatureEntry::FeatureVariation kDiscoverFeedInNtpVariations[] = {
219 {"Native UI", kDiscoverFeedInNtpEnableNativeUI,
220 base::size(kDiscoverFeedInNtpEnableNativeUI), nullptr}};
221
gogerald53c6e7a2021-04-15 22:07:35222const FeatureEntry::FeatureParam kStartSurfaceTenSecondsShrinkLogo[] = {
Chris Lu5470417c2021-03-03 18:43:08223 {kStartSurfaceShrinkLogoParam, "true"},
gogerald53c6e7a2021-04-15 22:07:35224 {kReturnToStartSurfaceInactiveDurationInSeconds, "10"}};
225const FeatureEntry::FeatureParam kStartSurfaceTenSecondsHideShortcuts[] = {
Chris Lu5470417c2021-03-03 18:43:08226 {kStartSurfaceHideShortcutsParam, "true"},
gogerald53c6e7a2021-04-15 22:07:35227 {kReturnToStartSurfaceInactiveDurationInSeconds, "10"}};
228const FeatureEntry::FeatureParam kStartSurfaceTenSecondsReturnToRecentTab[] = {
Chris Lu5470417c2021-03-03 18:43:08229 {kStartSurfaceReturnToRecentTabParam, "true"},
gogerald53c6e7a2021-04-15 22:07:35230 {kReturnToStartSurfaceInactiveDurationInSeconds, "10"}};
231const FeatureEntry::FeatureParam
232 kStartSurfaceTenSecondsShrinkLogoReturnToRecentTab[] = {
233 {kStartSurfaceShrinkLogoParam, "true"},
234 {kStartSurfaceReturnToRecentTabParam, "true"},
235 {kReturnToStartSurfaceInactiveDurationInSeconds, "10"}};
236const FeatureEntry::FeatureParam
237 kStartSurfaceTenSecondsHideShortcutsReturnToRecentTab[] = {
238 {kStartSurfaceHideShortcutsParam, "true"},
239 {kStartSurfaceReturnToRecentTabParam, "true"},
240 {kReturnToStartSurfaceInactiveDurationInSeconds, "10"}};
241const FeatureEntry::FeatureParam kStartSurfaceOneHourShrinkLogo[] = {
Chris Lu5470417c2021-03-03 18:43:08242 {kStartSurfaceShrinkLogoParam, "true"},
gogerald53c6e7a2021-04-15 22:07:35243 {kReturnToStartSurfaceInactiveDurationInSeconds, "3600"}};
244const FeatureEntry::FeatureParam kStartSurfaceOneHourHideShortcuts[] = {
245 {kStartSurfaceHideShortcutsParam, "true"},
246 {kReturnToStartSurfaceInactiveDurationInSeconds, "3600"}};
247const FeatureEntry::FeatureParam kStartSurfaceOneHourReturnToRecentTab[] = {
Chris Lu5470417c2021-03-03 18:43:08248 {kStartSurfaceReturnToRecentTabParam, "true"},
gogerald53c6e7a2021-04-15 22:07:35249 {kReturnToStartSurfaceInactiveDurationInSeconds, "3600"}};
250const FeatureEntry::FeatureParam
251 kStartSurfaceOneHourShrinkLogoReturnToRecentTab[] = {
252 {kStartSurfaceShrinkLogoParam, "true"},
253 {kStartSurfaceReturnToRecentTabParam, "true"},
254 {kReturnToStartSurfaceInactiveDurationInSeconds, "3600"}};
255const FeatureEntry::FeatureParam
256 kStartSurfaceOneHourHideShortcutsReturnToRecentTab[] = {
257 {kStartSurfaceHideShortcutsParam, "true"},
258 {kStartSurfaceReturnToRecentTabParam, "true"},
259 {kReturnToStartSurfaceInactiveDurationInSeconds, "3600"}};
Chris Lu5470417c2021-03-03 18:43:08260
gogerald0e39e3aa2021-02-10 18:41:23261const FeatureEntry::FeatureVariation kStartSurfaceVariations[] = {
gogerald53c6e7a2021-04-15 22:07:35262 {"10s:Show Return to Recent Tab tile",
263 kStartSurfaceTenSecondsReturnToRecentTab,
264 base::size(kStartSurfaceTenSecondsReturnToRecentTab), nullptr},
265 {"10s:Shrink Logo", kStartSurfaceTenSecondsShrinkLogo,
266 base::size(kStartSurfaceTenSecondsShrinkLogo), nullptr},
267 {"10s:Hide Shortcuts", kStartSurfaceTenSecondsHideShortcuts,
268 base::size(kStartSurfaceTenSecondsHideShortcuts), nullptr},
269 {"10s:Shrink Logo and show Return to Recent Tab tile",
270 kStartSurfaceTenSecondsShrinkLogoReturnToRecentTab,
271 base::size(kStartSurfaceTenSecondsShrinkLogoReturnToRecentTab), nullptr},
272 {"10s:Hide Shortcuts and show Return to Recent Tab tile",
273 kStartSurfaceTenSecondsHideShortcutsReturnToRecentTab,
274 base::size(kStartSurfaceTenSecondsHideShortcutsReturnToRecentTab),
275 nullptr},
276 {"1h:Show Return to Recent Tab tile", kStartSurfaceOneHourReturnToRecentTab,
277 base::size(kStartSurfaceOneHourReturnToRecentTab), nullptr},
278 {"1h:Shrink Logo", kStartSurfaceOneHourShrinkLogo,
279 base::size(kStartSurfaceOneHourShrinkLogo), nullptr},
280 {"1h:Hide Shortcuts", kStartSurfaceOneHourHideShortcuts,
281 base::size(kStartSurfaceOneHourHideShortcuts), nullptr},
282 {"1h:Shrink Logo and show Return to Recent Tab tile",
283 kStartSurfaceOneHourShrinkLogoReturnToRecentTab,
284 base::size(kStartSurfaceOneHourShrinkLogoReturnToRecentTab), nullptr},
285 {"1h:Hide Shortcuts and show Return to Recent Tab tile",
286 kStartSurfaceOneHourHideShortcutsReturnToRecentTab,
287 base::size(kStartSurfaceOneHourHideShortcutsReturnToRecentTab), nullptr},
Chris Lu5470417c2021-03-03 18:43:08288};
gogerald0e39e3aa2021-02-10 18:41:23289
Cooper Knaak1e026562017-07-26 05:22:28290// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21291// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28292// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
293// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21294// macro for this type supplying the command line to the macro.
295// . MULTI_VALUE: a list of choices, the first of which should correspond to a
296// deactivated state for this lab (i.e. no command line option). To specify
297// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
298// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28299// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
300// either enabled, disabled, or uses the default value of the associated
301// base::Feature instance. To specify this type of entry use the macro
302// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
303// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
304// base::Feature instance. Choices corresponding to the default state, a
305// universally enabled state, and a universally disabled state are
306// automatically included. To specify this type of entry use the macro
307// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
308// the array of choices.
309//
sdefresne14900ee2015-11-27 14:43:21310// See the documentation of FeatureEntry for details on the fields.
311//
312// When adding a new choice, add it to the end of the list.
313const flags_ui::FeatureEntry kFeatureEntries[] = {
Cooper Knaak1e026562017-07-26 05:22:28314 {"in-product-help-demo-mode-choice",
315 flag_descriptions::kInProductHelpDemoModeName,
316 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
317 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23318 feature_engagement::kIPHDemoMode,
319 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09320 "IPH_DemoMode")},
Moe Ahmadic3fd7cd2018-05-11 21:40:22321 {"enable-autofill-credit-card-upload",
322 flag_descriptions::kAutofillCreditCardUploadName,
323 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24324 FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
Tina Wang41d431c2021-06-21 21:04:13325 {"enable-discover-feed-preview",
326 flag_descriptions::kEnableDiscoverFeedPreviewName,
327 flag_descriptions::kEnableDiscoverFeedPreviewDescription, flags_ui::kOsIos,
328 FEATURE_VALUE_TYPE(kEnableDiscoverFeedPreview)},
Moe Ahmadid6d5d172018-06-20 17:20:23329 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
330 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
331 SINGLE_VALUE_TYPE_AND_VALUE(
332 switches::kSyncServiceURL,
333 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
334 {"wallet-service-use-sandbox",
335 flag_descriptions::kWalletServiceUseSandboxName,
336 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
337 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
338 autofill::switches::kWalletServiceUseSandbox,
339 "1",
340 autofill::switches::kWalletServiceUseSandbox,
341 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59342 {"show-autofill-type-predictions",
343 flag_descriptions::kShowAutofillTypePredictionsName,
344 flag_descriptions::kShowAutofillTypePredictionsDescription,
345 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46346 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22347 {"autofill-ios-delay-between-fields",
348 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
349 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
350 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Kurt Horimotodc33af32018-05-01 01:39:14351 {"fullscreen-viewport-adjustment-experiment",
Chris Lu481a9322019-09-25 22:16:53352 flag_descriptions::kFullscreenSmoothScrollingName,
353 flag_descriptions::kFullscreenSmoothScrollingDescription, flags_ui::kOsIos,
354 FEATURE_VALUE_TYPE(fullscreen::features::kSmoothScrollingDefault)},
Robbie Gibson1f37a5e2020-08-06 17:03:06355 {"webpage-default-zoom-from-dynamic-type",
356 flag_descriptions::kWebPageDefaultZoomFromDynamicTypeName,
357 flag_descriptions::kWebPageDefaultZoomFromDynamicTypeDescription,
358 flags_ui::kOsIos,
359 FEATURE_VALUE_TYPE(web::kWebPageDefaultZoomFromDynamicType)},
Yi Su392b3032018-06-05 07:26:47360 {"webpage-text-accessibility",
361 flag_descriptions::kWebPageTextAccessibilityName,
362 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
363 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Robbie Gibson88f23962020-09-28 14:35:56364 {"webpage-alternative-text-zoom",
365 flag_descriptions::kWebPageAlternativeTextZoomName,
366 flag_descriptions::kWebPageAlternativeTextZoomDescription,
367 flags_ui::kOsIos, FEATURE_VALUE_TYPE(web::kWebPageAlternativeTextZoom)},
Kurt Horimoto79d590b2018-09-12 19:09:28368 {"toolbar-container", flag_descriptions::kToolbarContainerName,
369 flag_descriptions::kToolbarContainerDescription, flags_ui::kOsIos,
370 FEATURE_VALUE_TYPE(toolbar_container::kToolbarContainerEnabled)},
Ce Chenc8d803a2020-04-27 09:31:33371 {"omnibox-on-device-head-suggestions-incognito",
372 flag_descriptions::kOmniboxOnDeviceHeadSuggestionsIncognitoName,
373 flag_descriptions::kOmniboxOnDeviceHeadSuggestionsIncognitoDescription,
Ce Chen104a5382019-12-10 01:09:05374 flags_ui::kOsIos,
Ce Chend565f71f2020-08-12 01:15:53375 FEATURE_VALUE_TYPE(omnibox::kOnDeviceHeadProviderIncognito)},
Ce Chenc8d803a2020-04-27 09:31:33376 {"omnibox-on-device-head-suggestions-non-incognito",
377 flag_descriptions::kOmniboxOnDeviceHeadSuggestionsNonIncognitoName,
378 flag_descriptions::kOmniboxOnDeviceHeadSuggestionsNonIncognitoDescription,
379 flags_ui::kOsIos,
380 FEATURE_WITH_PARAMS_VALUE_TYPE(
381 omnibox::kOnDeviceHeadProviderNonIncognito,
382 kOmniboxOnDeviceHeadSuggestNonIncognitoExperimentVariations,
Ce Chen2616ea92021-03-10 04:13:07383 "OmniboxOnDeviceHeadNonIncognitoTuningMobile")},
Stepan Khapugincc4e9842019-01-23 13:38:13384 {"omnibox-ui-max-autocomplete-matches",
385 flag_descriptions::kOmniboxUIMaxAutocompleteMatchesName,
386 flag_descriptions::kOmniboxUIMaxAutocompleteMatchesDescription,
387 flags_ui::kOsIos,
388 FEATURE_WITH_PARAMS_VALUE_TYPE(
389 omnibox::kUIExperimentMaxAutocompleteMatches,
390 kOmniboxUIMaxAutocompleteMatchesVariations,
391 "OmniboxUIMaxAutocompleteVariations")},
Robbie Gibson84f1ddc2020-12-10 21:41:28392 {"omnibox-local-history-zero-suggest",
393 flag_descriptions::kOmniboxLocalHistoryZeroSuggestName,
394 flag_descriptions::kOmniboxLocalHistoryZeroSuggestDescription,
395 flags_ui::kOsIos, FEATURE_VALUE_TYPE(omnibox::kLocalHistoryZeroSuggest)},
Justin Cohen20b6f072019-01-16 01:38:50396#if defined(DCHECK_IS_CONFIGURABLE)
397 {"dcheck-is-fatal", flag_descriptions::kDcheckIsFatalName,
398 flag_descriptions::kDcheckIsFatalDescription, flags_ui::kOsIos,
399 FEATURE_VALUE_TYPE(base::kDCheckIsFatalFeature)},
400#endif // defined(DCHECK_IS_CONFIGURABLE)
Caitlin Fischer43edd90a2019-05-01 13:24:30401 {"autofill-use-mobile-label-disambiguation",
402 flag_descriptions::kAutofillUseMobileLabelDisambiguationName,
403 flag_descriptions::kAutofillUseMobileLabelDisambiguationDescription,
404 flags_ui::kOsIos,
Caitlin Fischer37e01232019-05-24 13:05:45405 FEATURE_WITH_PARAMS_VALUE_TYPE(
406 autofill::features::kAutofillUseMobileLabelDisambiguation,
407 kAutofillUseMobileLabelDisambiguationVariations,
408 "AutofillUseMobileLabelDisambiguation")},
edchinb5d92582020-03-11 15:26:11409 {"autofill-prune-suggestions",
Caitlin Fischer6d609542019-05-01 21:59:21410 flag_descriptions::kAutofillPruneSuggestionsName,
411 flag_descriptions::kAutofillPruneSuggestionsDescription, flags_ui::kOsIos,
412 FEATURE_VALUE_TYPE(autofill::features::kAutofillPruneSuggestions)},
Olivier Robin43814bb2021-06-22 15:25:45413 {"metrickit-crash-reports", flag_descriptions::kMetrickitCrashReportName,
414 flag_descriptions::kMetrickitCrashReportDescription, flags_ui::kOsIos,
415 FEATURE_VALUE_TYPE(kMetrickitCrashReport)},
Mike Doughertyb6c770d2019-09-13 22:56:46416 {"ios-breadcrumbs", flag_descriptions::kLogBreadcrumbsName,
417 flag_descriptions::kLogBreadcrumbsDescription, flags_ui::kOsIos,
Jesse McKenna85c1a59f2021-05-05 19:08:30418 FEATURE_VALUE_TYPE(breadcrumbs::kLogBreadcrumbs)},
Eugene But2823dc7e2020-07-21 18:10:37419 {"ios-synthetic-crash-reports",
420 flag_descriptions::kSyntheticCrashReportsForUteName,
421 flag_descriptions::kSyntheticCrashReportsForUteDescription,
422 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kSyntheticCrashReportsForUte)},
Jérôme Lebelc374fdd2019-09-27 10:36:48423 {"force-startup-signin-promo",
424 flag_descriptions::kForceStartupSigninPromoName,
425 flag_descriptions::kForceStartupSigninPromoDescription, flags_ui::kOsIos,
Alice Wang345e09442021-07-05 09:03:29426 FEATURE_VALUE_TYPE(switches::kForceStartupSigninPromo)},
Yoichi Osato7ae11752021-03-16 03:27:22427 {"restore-session-from-cache",
428 flag_descriptions::kRestoreSessionFromCacheName,
429 flag_descriptions::kRestoreSessionFromCacheDescription, flags_ui::kOsIos,
Justin Cohen3ec2522c2021-04-23 18:23:49430 FEATURE_VALUE_TYPE(web::kRestoreSessionFromCache)},
sczs4622e6e2019-11-06 01:17:59431 {"autofill-save-card-dismiss-on-navigation",
432 flag_descriptions::kAutofillSaveCardDismissOnNavigationName,
433 flag_descriptions::kAutofillSaveCardDismissOnNavigationDescription,
434 flags_ui::kOsIos,
435 FEATURE_VALUE_TYPE(
436 autofill::features::kAutofillSaveCardDismissOnNavigation)},
Gauthier Ambard2fc86ca52021-09-22 09:05:50437 {"default-user-agent",
438 flag_descriptions::kUseDefaultUserAgentInWebClientName,
439 flag_descriptions::kUseDefaultUserAgentInWebClientDescription,
440 flags_ui::kOsIos,
Gauthier Ambard054175f2019-12-16 11:54:09441 FEATURE_VALUE_TYPE(web::features::kUseDefaultUserAgentInWebClient)},
Mike Dougherty768389502020-04-21 08:28:35442 {"url-blocklist-ios", flag_descriptions::kURLBlocklistIOSName,
443 flag_descriptions::kURLBlocklistIOSDescription, flags_ui::kOsIos,
444 FEATURE_VALUE_TYPE(kURLBlocklistIOS)},
sczs37d9c132020-07-18 06:06:33445 {"new-content-suggestions-feed", flag_descriptions::kDiscoverFeedInNtpName,
adamta22a4d502020-05-21 03:12:21446 flag_descriptions::kDiscoverFeedInNtpDescription, flags_ui::kOsIos,
gogeralddb0d8ae2020-11-13 03:56:58447 FEATURE_WITH_PARAMS_VALUE_TYPE(kDiscoverFeedInNtp,
448 kDiscoverFeedInNtpVariations,
449 "IOSDiscoverFeed")},
Roberto Mourab87b9722020-06-17 17:12:09450 {"expanded-tab-strip", flag_descriptions::kExpandedTabStripName,
451 flag_descriptions::kExpandedTabStripDescription, flags_ui::kOsIos,
452 FEATURE_VALUE_TYPE(kExpandedTabStrip)},
Ben Blake14592fe2020-06-16 15:34:38453 {"autofill-enable-offers-in-downstream",
454 flag_descriptions::kAutofillEnableOffersInDownstreamName,
455 flag_descriptions::kAutofillEnableOffersInDownstreamDescription,
456 flags_ui::kOsIos,
457 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableOffersInDownstream)},
Tommy Martino6b4eb7e2020-06-25 18:25:41458 {"shared-highlighting-ios", flag_descriptions::kSharedHighlightingIOSName,
459 flag_descriptions::kSharedHighlightingIOSDescription, flags_ui::kOsIos,
460 FEATURE_VALUE_TYPE(kSharedHighlightingIOS)},
Aliona DANGLAfe2e87d2021-07-23 11:40:19461 {"enable-fre-default-browser-screen",
462 flag_descriptions::kEnableFREDefaultBrowserScreenName,
463 flag_descriptions::kEnableFREDefaultBrowserScreenDescription,
464 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kEnableFREDefaultBrowserScreen)},
Tina Wanga252ca42021-04-01 17:14:23465 {"enable-fre-ui-module-ios", flag_descriptions::kEnableFREUIModuleIOSName,
466 flag_descriptions::kEnableFREUIModuleIOSDescription, flags_ui::kOsIos,
467 FEATURE_VALUE_TYPE(kEnableFREUIModuleIOS)},
Julian Mentasti-Meza4c0a4162020-07-20 18:51:41468 {"enable-fullpage-screenshot",
469 flag_descriptions::kEnableFullPageScreenshotName,
470 flag_descriptions::kEnableFullPageScreenshotDescription, flags_ui::kOsIos,
471 FEATURE_VALUE_TYPE(kEnableFullPageScreenshot)},
Tina Wang17514e2f2021-09-24 23:57:18472 {"enable-long-message-duration",
473 flag_descriptions::kEnableLongMessageDurationName,
474 flag_descriptions::kEnableLongMessageDurationDescription, flags_ui::kOsIos,
475 FEATURE_VALUE_TYPE(kEnableLongMessageDuration)},
Raj T3898f032021-08-19 23:51:27476 {"enable-optimization-guide",
477 flag_descriptions::kEnableOptimizationGuideName,
478 flag_descriptions::kEnableOptimizationGuideDescription, flags_ui::kOsIos,
479 FEATURE_VALUE_TYPE(optimization_guide::features::kOptimizationHints)},
Raj T4f742fb2021-09-28 04:50:12480 {"enable-optimization-guide-metadata-validation",
481 flag_descriptions::kEnableOptimizationGuideMetadataValidationName,
482 flag_descriptions::kEnableOptimizationGuideMetadataValidationDescription,
483 flags_ui::kOsIos,
484 FEATURE_VALUE_TYPE(
485 optimization_guide::features::kOptimizationGuideMetadataValidation)},
Chris Thompson40cbb162020-08-04 23:22:15486 {"legacy-tls-interstitial",
487 flag_descriptions::kIOSLegacyTLSInterstitialsName,
488 flag_descriptions::kIOSLegacyTLSInterstitialsDescription, flags_ui::kOsIos,
489 FEATURE_VALUE_TYPE(web::features::kIOSLegacyTLSInterstitial)},
Sylvain Defresne9c107082020-10-27 16:39:13490#if BUILDFLAG(IOS_SCREEN_TIME_ENABLED)
edchin81467b82020-09-03 19:31:45491 {"screen-time-integration-ios",
492 flag_descriptions::kScreenTimeIntegrationName,
493 flag_descriptions::kScreenTimeIntegrationDescription, flags_ui::kOsIos,
494 FEATURE_VALUE_TYPE(kScreenTimeIntegration)},
Sylvain Defresne9c107082020-10-27 16:39:13495#endif
jlebel5a31acc2021-05-26 01:23:39496 {"mice-web-signin", flag_descriptions::kMICEWebSignInName,
497 flag_descriptions::kMICEWebSignInDescription, flags_ui::kOsIos,
498 FEATURE_VALUE_TYPE(signin::kMICEWebSignIn)},
Nazerke3e993f72020-09-21 13:00:06499 {"modern-tab-strip", flag_descriptions::kModernTabStripName,
500 flag_descriptions::kModernTabStripDescription, flags_ui::kOsIos,
501 FEATURE_VALUE_TYPE(kModernTabStrip)},
Maria Kazinovad4e2ed72020-09-22 17:40:50502 {"autofill-use-renderer-ids",
503 flag_descriptions::kAutofillUseRendererIDsName,
504 flag_descriptions::kAutofillUseRendererIDsDescription, flags_ui::kOsIos,
505 FEATURE_VALUE_TYPE(
506 autofill::features::kAutofillUseUniqueRendererIDsOnIOS)},
Nohemi Fernandez7af63ca22020-12-11 13:06:40507 {"restore-gaia-cookies-on-user-action",
508 flag_descriptions::kRestoreGaiaCookiesOnUserActionName,
509 flag_descriptions::kRestoreGaiaCookiesOnUserActionDescription,
510 flags_ui::kOsIos,
511 FEATURE_VALUE_TYPE(signin::kRestoreGaiaCookiesOnUserAction)},
Nohemi Fernandez222d6d42020-09-30 20:35:57512 {"minutes-delay-to-restore-gaia-cookies-if-deleted",
513 flag_descriptions::kDelayThresholdMinutesToUpdateGaiaCookieName,
514 flag_descriptions::kDelayThresholdMinutesToUpdateGaiaCookieDescription,
515 flags_ui::kOsIos,
516 MULTI_VALUE_TYPE(kDelayThresholdMinutesToUpdateGaiaCookieChoices)},
Vidhan Jainb4de5c52021-08-30 17:08:02517 {"add-passwords-in-settings",
518 flag_descriptions::kAddPasswordsInSettingsName,
519 flag_descriptions::kAddPasswordsInSettingsDescription, flags_ui::kOsIos,
520 FEATURE_VALUE_TYPE(
521 password_manager::features::kSupportForAddPasswordsInSettings)},
Viktor Semeniukd932ff52020-10-13 13:10:17522 {"edit-passwords-in-settings",
523 flag_descriptions::kEditPasswordsInSettingsName,
524 flag_descriptions::kEditPasswordsInSettingsDescription, flags_ui::kOsIos,
525 FEATURE_VALUE_TYPE(password_manager::features::kEditPasswordsInSettings)},
Gauthier Ambardcb6a0ccc2020-10-30 13:12:00526 {"web-view-native-context-menu",
527 flag_descriptions::kWebViewNativeContextMenuName,
528 flag_descriptions::kWebViewNativeContextMenuDescription, flags_ui::kOsIos,
Gauthier Ambard14d3a262021-08-09 18:09:23529 FEATURE_VALUE_TYPE(web::features::kWebViewNativeContextMenu)},
Chris Lu4b15abc2020-11-09 20:19:19530 {"location-permissions-prompt",
531 flag_descriptions::kLocationPermissionsPromptName,
532 flag_descriptions::kLocationPermissionsPromptDescription, flags_ui::kOsIos,
533 FEATURE_VALUE_TYPE(kLocationPermissionsPrompt)},
Eugene Butf869bff2020-12-10 01:16:55534 {"record-snapshot-size", flag_descriptions::kRecordSnapshotSizeName,
535 flag_descriptions::kRecordSnapshotSizeDescription, flags_ui::kOsIos,
536 FEATURE_VALUE_TYPE(web::features::kRecordSnapshotSize)},
Chris Lub17195f2020-12-10 20:49:14537 {"default-browser-fullscreen-promo-experiment",
538 flag_descriptions::kDefaultBrowserFullscreenPromoExperimentName,
539 flag_descriptions::kDefaultBrowserFullscreenPromoExperimentDescription,
540 flags_ui::kOsIos,
Javier Ernesto Flores Robles159414232021-06-16 14:29:59541 FEATURE_WITH_PARAMS_VALUE_TYPE(
542 kDefaultBrowserFullscreenPromoExperiment,
543 kDefaultBrowserFullscreenPromoExperimentVariations,
544 "IOSDefaultBrowserFullscreenPromoExperiment")},
Cheick Cisse76ade3d2020-12-16 00:15:11545 {"ios-shared-highlighting-color-change",
546 flag_descriptions::kIOSSharedHighlightingColorChangeName,
547 flag_descriptions::kIOSSharedHighlightingColorChangeDescription,
Cheick Cissed0b5bfe2021-02-11 14:23:07548 flags_ui::kOsIos,
549 FEATURE_VALUE_TYPE(web::features::kIOSSharedHighlightingColorChange)},
Chris Lu07e32772020-12-30 01:54:44550 {"ios-persist-crash-restore-infobar",
551 flag_descriptions::kIOSPersistCrashRestoreName,
552 flag_descriptions::kIOSPersistCrashRestoreDescription, flags_ui::kOsIos,
553 FEATURE_VALUE_TYPE(kIOSPersistCrashRestore)},
Stepan Khapugin04341202021-01-07 12:22:45554 {"omnibox-new-textfield-implementation",
555 flag_descriptions::kOmniboxNewImplementationName,
556 flag_descriptions::kOmniboxNewImplementationDescription, flags_ui::kOsIos,
557 FEATURE_VALUE_TYPE(kIOSNewOmniboxImplementation)},
Tommy Martino0caf3362021-01-13 20:29:58558 {"shared-highlighting-use-blocklist",
559 flag_descriptions::kSharedHighlightingUseBlocklistIOSName,
560 flag_descriptions::kSharedHighlightingUseBlocklistIOSDescription,
561 flags_ui::kOsIos,
562 FEATURE_VALUE_TYPE(shared_highlighting::kSharedHighlightingUseBlocklist)},
gogerald0ff29e52021-02-03 18:56:19563 {"start-surface", flag_descriptions::kStartSurfaceName,
564 flag_descriptions::kStartSurfaceDescription, flags_ui::kOsIos,
gogerald0e39e3aa2021-02-10 18:41:23565 FEATURE_WITH_PARAMS_VALUE_TYPE(kStartSurface,
566 kStartSurfaceVariations,
567 "StartSurface")},
Justin Cohen13ac7a202021-02-04 18:27:28568 {"ios-crashpad", flag_descriptions::kCrashpadIOSName,
569 flag_descriptions::kCrashpadIOSDescription, flags_ui::kOsIos,
570 FEATURE_VALUE_TYPE(kCrashpadIOS)},
Maria Kazinovab69b75d2021-02-16 00:09:37571 {"detect-form-submission-on-form-clear",
572 flag_descriptions::kDetectFormSubmissionOnFormClearIOSName,
573 flag_descriptions::kDetectFormSubmissionOnFormClearIOSDescription,
574 flags_ui::kOsIos,
575 FEATURE_VALUE_TYPE(
576 password_manager::features::kDetectFormSubmissionOnFormClear)},
Maria Kazinova852e23702021-02-24 11:10:11577 {"enable-manual-password-generation",
578 flag_descriptions::kEnableManualPasswordGenerationName,
579 flag_descriptions::kEnableManualPasswordGenerationDescription,
580 flags_ui::kOsIos,
581 FEATURE_VALUE_TYPE(
582 password_manager::features::kEnableManualPasswordGeneration)},
edchind847c0962021-03-03 18:17:05583 {"interest-feed-notice-card-auto-dismiss",
584 flag_descriptions::kInterestFeedNoticeCardAutoDismissName,
585 flag_descriptions::kInterestFeedNoticeCardAutoDismissDescription,
586 flags_ui::kOsIos,
587 FEATURE_VALUE_TYPE(feed::kInterestFeedNoticeCardAutoDismiss)},
Vidhan Jain451b4752021-07-15 10:16:42588 {"autofill-address-verification-in-save-prompt",
589 flag_descriptions::kEnableAutofillAddressSavePromptAddressVerificationName,
590 flag_descriptions::
591 kEnableAutofillAddressSavePromptAddressVerificationDescription,
592 flags_ui::kOsIos,
593 FEATURE_VALUE_TYPE(
594 autofill::features::
595 kAutofillAddressProfileSavePromptAddressVerificationSupport)},
Vidhan Jaina65741552021-03-09 17:18:27596 {"autofill-address-save-prompt",
597 flag_descriptions::kEnableAutofillAddressSavePromptName,
598 flag_descriptions::kEnableAutofillAddressSavePromptDescription,
599 flags_ui::kOsIos,
600 FEATURE_VALUE_TYPE(autofill::features::kAutofillAddressProfileSavePrompt)},
Viktor Semeniuk68e794a2021-03-24 10:23:25601 {"filling-across-affiliated-websites",
602 flag_descriptions::kFillingAcrossAffiliatedWebsitesName,
603 flag_descriptions::kFillingAcrossAffiliatedWebsitesDescription,
604 flags_ui::kOsIos,
605 FEATURE_VALUE_TYPE(
606 password_manager::features::kFillingAcrossAffiliatedWebsites)},
Jared Sauld47c2b72021-03-25 22:47:31607 {"autofill-parse-merchant-promo-code-fields",
608 flag_descriptions::kAutofillParseMerchantPromoCodeFieldsName,
609 flag_descriptions::kAutofillParseMerchantPromoCodeFieldsDescription,
610 flags_ui::kOsIos,
611 FEATURE_VALUE_TYPE(
612 autofill::features::kAutofillParseMerchantPromoCodeFields)},
harrisonseana9d13042021-03-31 17:21:13613 {"search-history-link-ios", flag_descriptions::kSearchHistoryLinkIOSName,
614 flag_descriptions::kSearchHistoryLinkIOSDescription, flags_ui::kOsIos,
615 FEATURE_VALUE_TYPE(kSearchHistoryLinkIOS)},
edchin257cea2f2021-04-07 13:07:13616 {"interest-feed-v2-clicks-and-views-cond-upload",
617 flag_descriptions::kInterestFeedV2ClickAndViewActionsConditionalUploadName,
618 flag_descriptions::
619 kInterestFeedV2ClickAndViewActionsConditionalUploadDescription,
620 flags_ui::kOsIos,
621 FEATURE_VALUE_TYPE(feed::kInterestFeedV2ClicksAndViewsConditionalUpload)},
Mohammad Refaatbd8bff12021-04-09 17:00:16622 {"tabs-bulkactions-ios", flag_descriptions::kTabsBulkActionsName,
623 flag_descriptions::kTabsBulkActionsDescription, flags_ui::kOsIos,
624 FEATURE_VALUE_TYPE(kTabsBulkActions)},
Side Yilmaz0e6c15a2021-04-26 12:55:09625 {"incognito-brand-consistency-for-ios",
626 flag_descriptions::kIncognitoBrandConsistencyForIOSName,
627 flag_descriptions::kIncognitoBrandConsistencyForIOSDescription,
628 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kIncognitoBrandConsistencyForIOS)},
Side Yilmaz6c53f7102021-09-07 13:26:19629 {"incognito-ntp-revamp", flag_descriptions::kIncognitoNtpRevampName,
630 flag_descriptions::kIncognitoNtpRevampDescription, flags_ui::kOsIos,
631 FEATURE_VALUE_TYPE(kIncognitoNtpRevamp)},
Side Yilmazc0e4a4c62021-05-05 13:41:42632 {"update-history-entry-points-in-incognito",
633 flag_descriptions::kUpdateHistoryEntryPointsInIncognitoName,
634 flag_descriptions::kUpdateHistoryEntryPointsInIncognitoDescription,
635 flags_ui::kOsIos,
636 FEATURE_VALUE_TYPE(kUpdateHistoryEntryPointsInIncognito)},
Victor Hugo Vianna Silvae427a722021-05-07 12:47:36637 {"enable-autofill-account-wallet-storage",
638 flag_descriptions::kEnableAutofillAccountWalletStorageName,
639 flag_descriptions::kEnableAutofillAccountWalletStorageDescription,
640 flags_ui::kOsIos,
641 FEATURE_VALUE_TYPE(
642 autofill::features::kAutofillEnableAccountWalletStorage)},
Chris Lue45c94c62021-05-21 01:32:59643 {"reading-list-messages", flag_descriptions::kReadingListMessagesName,
644 flag_descriptions::kReadingListMessagesDescription, flags_ui::kOsIos,
645 FEATURE_VALUE_TYPE(kReadingListMessages)},
Nohemi Fernandez58baec0f2021-06-10 10:41:36646 {"force-disable-extended-sync-promos",
647 flag_descriptions::kForceDisableExtendedSyncPromosName,
648 flag_descriptions::kForceDisableExtendedSyncPromosDescription,
649 flags_ui::kOsIos,
650 FEATURE_VALUE_TYPE(switches::kForceDisableExtendedSyncPromos)},
Ewann1a9d33d2021-06-14 11:12:24651 {"download-mobileconfig-file",
652 flag_descriptions::kDownloadMobileConfigFileName,
653 flag_descriptions::kDownloadMobileConfigFileDescription, flags_ui::kOsIos,
654 FEATURE_VALUE_TYPE(kDownloadMobileConfigFile)},
jlebeld95434d652021-06-22 10:32:48655 {"sync-trusted-vault-passphrase-ios-rpc",
656 flag_descriptions::kSyncTrustedVaultPassphraseiOSRPCName,
657 flag_descriptions::kSyncTrustedVaultPassphraseiOSRPCDescription,
658 flags_ui::kOsIos,
659 FEATURE_VALUE_TYPE(::switches::kSyncTrustedVaultPassphraseiOSRPC)},
Mikel Astiz850b0fe2021-06-16 09:47:27660 {"sync-trusted-vault-passphrase-promo",
661 flag_descriptions::kSyncTrustedVaultPassphrasePromoName,
662 flag_descriptions::kSyncTrustedVaultPassphrasePromoDescription,
663 flags_ui::kOsIos,
664 FEATURE_VALUE_TYPE(::switches::kSyncTrustedVaultPassphrasePromo)},
665 {"sync-trusted-vault-passphrase-recovery",
666 flag_descriptions::kSyncTrustedVaultPassphraseRecoveryName,
667 flag_descriptions::kSyncTrustedVaultPassphraseRecoveryDescription,
668 flags_ui::kOsIos,
669 FEATURE_VALUE_TYPE(::switches::kSyncTrustedVaultPassphraseRecovery)},
Sergio Collazosdaf078b2021-06-26 01:21:52670 {"enable-ntp-memory-enhancement",
671 flag_descriptions::kEnableNTPMemoryEnhancementName,
672 flag_descriptions::kEnableNTPMemoryEnhancementDescription,
673 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kEnableNTPMemoryEnhancement)},
Victor Hugo Vianna Silvacbf44342021-07-01 15:27:59674 {"enable-autofill-save-card-info-bar-account-indication-footer",
675 flag_descriptions::
676 kEnableAutofillSaveCardInfoBarAccountIndicationFooterName,
677 flag_descriptions::
678 kEnableAutofillSaveCardInfoBarAccountIndicationFooterDescription,
679 flags_ui::kOsIos,
680 FEATURE_VALUE_TYPE(
681 autofill::features::
682 kAutofillEnableSaveCardInfoBarAccountIndicationFooter)},
Nohemi Fernandezc00842a2021-07-26 11:47:34683 {"wait-threshold-seconds-for-capabilities-api",
684 flag_descriptions::kWaitThresholdMillisecondsForCapabilitiesApiName,
685 flag_descriptions::kWaitThresholdMillisecondsForCapabilitiesApiDescription,
686 flags_ui::kOsIos,
687 MULTI_VALUE_TYPE(kWaitThresholdMillisecondsForCapabilitiesApiChoices)},
Jared Saul2188f762021-08-02 21:22:23688 {"autofill-fill-merchant-promo-code-fields",
689 flag_descriptions::kAutofillFillMerchantPromoCodeFieldsName,
690 flag_descriptions::kAutofillFillMerchantPromoCodeFieldsDescription,
691 flags_ui::kOsIos,
692 FEATURE_VALUE_TYPE(
693 autofill::features::kAutofillFillMerchantPromoCodeFields)},
Ewann8cfdfb52021-08-24 08:40:17694 {"context-menu-actions-refresh",
695 flag_descriptions::kContextMenuActionsRefreshName,
696 flag_descriptions::kContextMenuActionsRefreshDescription, flags_ui::kOsIos,
697 FEATURE_VALUE_TYPE(kContextMenuActionsRefresh)},
Gauthier Ambard14d3a262021-08-09 18:09:23698 {"context-menu-phase2",
699 flag_descriptions::kWebViewNativeContextMenuPhase2Name,
700 flag_descriptions::kWebViewNativeContextMenuPhase2Description,
701 flags_ui::kOsIos,
702 FEATURE_VALUE_TYPE(web::features::kWebViewNativeContextMenuPhase2)},
Gauthier Ambard14d3a262021-08-09 18:09:23703 {"default-wkwebview-context-menu",
704 flag_descriptions::kDefaultWebViewContextMenuName,
705 flag_descriptions::kDefaultWebViewContextMenuDescription, flags_ui::kOsIos,
706 FEATURE_VALUE_TYPE(web::features::kDefaultWebViewContextMenu)},
Victor Hugo Vianna Silva0399402f2021-09-07 21:41:25707 {"send-tab-to-self-when-signed-in",
708 flag_descriptions::kSendTabToSelfWhenSignedInName,
709 flag_descriptions::kSendTabToSelfWhenSignedInDescription, flags_ui::kOsIos,
710 FEATURE_VALUE_TYPE(send_tab_to_self::kSendTabToSelfWhenSignedIn)},
711 {"send-tab-to-self-manage-devices-link",
712 flag_descriptions::kSendTabToSelfManageDevicesLinkName,
713 flag_descriptions::kSendTabToSelfManageDevicesLinkDescription,
714 flags_ui::kOsIos,
715 FEATURE_VALUE_TYPE(send_tab_to_self::kSendTabToSelfManageDevicesLink)},
Sylvain Defresnedff67e42021-09-24 09:43:03716 {"new-overflow-menu", flag_descriptions::kNewOverflowMenuName,
717 flag_descriptions::kNewOverflowMenuDescription, flags_ui::kOsIos,
718 FEATURE_VALUE_TYPE(kNewOverflowMenu)},
719 {"enable-new-download-api", flag_descriptions::kEnableNewDownloadAPIName,
720 flag_descriptions::kEnableNewDownloadAPIDescription, flags_ui::kOsIos,
721 FEATURE_VALUE_TYPE(web::features::kEnableNewDownloadAPI)},
Evan Bernstein0a85f332021-09-29 19:07:24722 {"use-lens-to-search-for-image",
723 flag_descriptions::kUseLensToSearchForImageName,
724 flag_descriptions::kUseLensToSearchForImageDescription, flags_ui::kOsIos,
Ali Juma02a9b7b2021-10-01 13:44:44725 FEATURE_VALUE_TYPE(kUseLensToSearchForImage)},
726 {"force-major-version-to-100",
727 flag_descriptions::kForceMajorVersion100InUserAgentName,
728 flag_descriptions::kForceMajorVersion100InUserAgentDescription,
729 flags_ui::kOsIos,
730 FEATURE_VALUE_TYPE(web::kForceMajorVersion100InUserAgent)},
Ewannf7ed0752021-10-01 17:43:01731 {"download-vcard", flag_descriptions::kDownloadVcardName,
732 flag_descriptions::kDownloadVcardDescription, flags_ui::kOsIos,
733 FEATURE_VALUE_TYPE(kDownloadVcard)},
Ali Juma02a9b7b2021-10-01 13:44:44734};
sdefresne14900ee2015-11-27 14:43:21735
Rohit Raobed794c2020-04-27 15:27:45736bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
737 return false;
738}
739
740flags_ui::FlagsState& GetGlobalFlagsState() {
741 static base::NoDestructor<flags_ui::FlagsState> flags_state(kFeatureEntries,
742 nullptr);
743 return *flags_state;
744}
David Jean5ca263c2021-08-18 09:19:30745// Creates the experimental test policies map, used by AsyncPolicyLoader and
746// PolicyLoaderIOS to locally enable policies.
Vincent Boisselle19200bc2021-09-01 17:58:25747NSMutableDictionary* CreateExperimentalTestingPolicies(
748 base::CommandLine* command_line) {
sdefresne14900ee2015-11-27 14:43:21749 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
750
Guillaume Jenkins25e9bd72020-08-27 17:39:06751 // Shared variables for all enterprise experimental flags.
Guillaume Jenkins57606d72020-08-13 17:32:55752 NSMutableDictionary* testing_policies = [[NSMutableDictionary alloc] init];
Guillaume Jenkins25e9bd72020-08-27 17:39:06753 NSMutableArray* allowed_experimental_policies = [[NSMutableArray alloc] init];
Guillaume Jenkins57606d72020-08-13 17:32:55754
Guillaume Jenkins25e9bd72020-08-27 17:39:06755 // Set some sample policy values for testing if EnableSamplePolicies is set to
756 // true.
Guillaume Jenkinseeb7007c2020-06-25 22:55:40757 if ([defaults boolForKey:@"EnableSamplePolicies"]) {
Guillaume Jenkins5b4d30a2021-02-17 22:13:35758 // Define sample policies to enable. If some of the sample policies are
759 // still marked as experimental (future_on), they must be explicitly
760 // allowed, otherwise they will be ignored in Beta and Stable. Add them to
761 // the |allowed_experimental_policies| array.
Gauthier Ambard21b23702021-04-16 16:11:27762 [allowed_experimental_policies addObjectsFromArray:@[
Gauthier Ambard21b23702021-04-16 16:11:27763 ]];
764
Guillaume Jenkins57606d72020-08-13 17:32:55765 [testing_policies addEntriesFromDictionary:@{
Tina Wang59d0b7e2020-08-11 04:41:01766 base::SysUTF8ToNSString(policy::key::kAutofillAddressEnabled) : @NO,
767
Guillaume Jenkinseeb7007c2020-06-25 22:55:40768 base::SysUTF8ToNSString(policy::key::kAutofillCreditCardEnabled) : @NO,
769
770 // 2 = Disable all variations
771 base::SysUTF8ToNSString(policy::key::kChromeVariations) : @2,
772
773 // 2 = Do not allow any site to show popups
774 base::SysUTF8ToNSString(policy::key::kDefaultPopupsSetting) : @2,
775
Tina Wang5abee802020-07-29 23:09:52776 // Set default search engine.
777 base::SysUTF8ToNSString(policy::key::kDefaultSearchProviderEnabled) :
778 @YES,
779 base::SysUTF8ToNSString(policy::key::kDefaultSearchProviderSearchURL) :
780 @"http://www.google.com/search?q={searchTerms}",
781 base::SysUTF8ToNSString(policy::key::kDefaultSearchProviderName) :
Tina Wang7cd0a062020-09-15 21:31:02782 @"TestEngine",
Tina Wang5abee802020-07-29 23:09:52783
Tina Wang89068c82020-10-29 15:51:50784 base::SysUTF8ToNSString(policy::key::kEditBookmarksEnabled) : @NO,
785
Gauthier Ambard21b23702021-04-16 16:11:27786 base::SysUTF8ToNSString(policy::key::kNTPContentSuggestionsEnabled) : @NO,
787
Guillaume Jenkinseeb7007c2020-06-25 22:55:40788 base::SysUTF8ToNSString(policy::key::kPasswordManagerEnabled) : @NO,
Tina Wang59d0b7e2020-08-11 04:41:01789
790 base::SysUTF8ToNSString(policy::key::kTranslateEnabled) : @NO,
Tina Wang54dddfc22020-08-20 22:34:53791
792 // 2 = Enhanced safe browsing protection
793 base::SysUTF8ToNSString(policy::key::kSafeBrowsingProtectionLevel) : @2,
794
795 base::SysUTF8ToNSString(policy::key::kSearchSuggestEnabled) : @YES,
Guillaume Jenkins57606d72020-08-13 17:32:55796 }];
797 }
798
Ewann227a3c02021-04-19 12:04:54799 if ([defaults boolForKey:@"EnableSyncDisabledPolicy"]) {
Guillaume Jenkinsfe46d3a2021-04-26 19:51:04800 NSString* sync_policy_key =
801 base::SysUTF8ToNSString(policy::key::kSyncDisabled);
David Jean5ca263c2021-08-18 09:19:30802 [testing_policies addEntriesFromDictionary:@{sync_policy_key : @YES}];
Guillaume Jenkinsfe46d3a2021-04-26 19:51:04803 [allowed_experimental_policies addObject:sync_policy_key];
Ewann227a3c02021-04-19 12:04:54804 }
Ewann227a3c02021-04-19 12:04:54805
Ewann570a6302021-08-17 07:22:42806 // SyncTypesListDisabled policy.
807 NSString* Sync_types_list_disabled_key =
808 base::SysUTF8ToNSString(policy::key::kSyncTypesListDisabled);
809 NSMutableArray* Sync_types_list_disabled_values =
810 [[NSMutableArray alloc] init];
811 if ([defaults boolForKey:@"SyncTypesListBookmarks"]) {
812 [Sync_types_list_disabled_values addObject:@"bookmarks"];
813 }
814 if ([defaults boolForKey:@"SyncTypesListReadingList"]) {
815 [Sync_types_list_disabled_values addObject:@"readingList"];
816 }
817 if ([defaults boolForKey:@"SyncTypesListPreferences"]) {
818 [Sync_types_list_disabled_values addObject:@"preferences"];
819 }
820 if ([defaults boolForKey:@"SyncTypesListPasswords"]) {
821 [Sync_types_list_disabled_values addObject:@"passwords"];
822 }
823 if ([defaults boolForKey:@"SyncTypesListAutofill"]) {
824 [Sync_types_list_disabled_values addObject:@"autofill"];
825 }
826 if ([defaults boolForKey:@"SyncTypesListTypedUrls"]) {
827 [Sync_types_list_disabled_values addObject:@"typedUrls"];
828 }
829 if ([defaults boolForKey:@"SyncTypesListTabs"]) {
830 [Sync_types_list_disabled_values addObject:@"tabs"];
831 }
832 if ([Sync_types_list_disabled_values count]) {
833 [testing_policies addEntriesFromDictionary:@{
834 Sync_types_list_disabled_key : Sync_types_list_disabled_values
835 }];
836 [allowed_experimental_policies addObject:Sync_types_list_disabled_key];
837 }
838
Tina Wangc6bcf572021-01-27 18:15:52839 // If an incognito mode availability is set, add the policy key to the list of
840 // allowed experimental policies, and set the value.
841 NSString* incognito_policy_key =
842 base::SysUTF8ToNSString(policy::key::kIncognitoModeAvailability);
843 NSInteger incognito_mode_availability =
844 [defaults integerForKey:incognito_policy_key];
845 if (incognito_mode_availability) {
846 [allowed_experimental_policies addObject:incognito_policy_key];
847 [testing_policies addEntriesFromDictionary:@{
848 incognito_policy_key : @(incognito_mode_availability),
849 }];
850 }
851
Ewann40a8f8a2021-07-29 10:01:20852 NSString* restriction_pattern =
853 [defaults stringForKey:@"RestrictAccountsToPatterns"];
854 if ([restriction_pattern length] > 0) {
Ewannb3bee382021-08-16 09:12:29855 NSString* restrict_key =
856 base::SysUTF8ToNSString(policy::key::kRestrictAccountsToPatterns);
Ewann40a8f8a2021-07-29 10:01:20857 [testing_policies addEntriesFromDictionary:@{
Ewannb3bee382021-08-16 09:12:29858 restrict_key : @[ restriction_pattern ]
Ewann40a8f8a2021-07-29 10:01:20859 }];
Ewannb3bee382021-08-16 09:12:29860 [allowed_experimental_policies addObject:restrict_key];
Ewann40a8f8a2021-07-29 10:01:20861 }
862
Vincent Boisselle19200bc2021-09-01 17:58:25863 // If the sign-in policy is set (not "None"), add the policy key to the list
864 // of enabled experimental policies, and set the value.
865 NSString* const kSigninPolicyKey = @"BrowserSignin";
866 NSInteger signin_policy_mode = [defaults integerForKey:kSigninPolicyKey];
867 if (signin_policy_mode) {
868 // Remove the mode offset that was used to represent the unset policy.
869 --signin_policy_mode;
870 DCHECK(signin_policy_mode >= 0);
871
872 if (signin_policy_mode ==
873 static_cast<NSInteger>(BrowserSigninMode::kForced)) {
874 // Allow the forced sign-in policy feature when the corresponding policy
875 // mode is specified.
876 command_line->AppendSwitch(switches::kEnableForcedSignInPolicy);
877 }
878
879 [allowed_experimental_policies addObject:kSigninPolicyKey];
880 [testing_policies addEntriesFromDictionary:@{
881 kSigninPolicyKey : @(signin_policy_mode),
882 }];
883 }
884
Guillaume Jenkins25e9bd72020-08-27 17:39:06885 // If any experimental policy was allowed, set the EnableExperimentalPolicies
886 // policy.
887 if ([allowed_experimental_policies count] > 0) {
888 [testing_policies setValue:allowed_experimental_policies
889 forKey:base::SysUTF8ToNSString(
890 policy::key::kEnableExperimentalPolicies)];
891 }
892
David Jean6f85d44f2021-08-19 08:08:45893 // Warning: Add new flags to TestingPoliciesHash() below.
894
David Jean5ca263c2021-08-18 09:19:30895 return testing_policies;
896}
David Jean6f85d44f2021-08-19 08:08:45897
898// Generates a unique NSString based on currently monitored policies from
899// NSUserDefaults standardUserDefaults.
900NSString* TestingPoliciesHash() {
901 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
902 return [NSString
903 stringWithFormat:@"%d|%d|%d|%@|%d|%d|%d|%d|%d|%d|%d",
904 [defaults boolForKey:@"EnableSyncDisabledPolicy"],
905 [defaults boolForKey:@"EnableSamplePolicies"],
906 (int)[defaults
907 integerForKey:@"IncognitoModeAvailability"],
908 [defaults stringForKey:@"RestrictAccountsToPatterns"],
909 [defaults boolForKey:@"SyncTypesListBookmarks"],
910 [defaults boolForKey:@"SyncTypesListReadingList"],
911 [defaults boolForKey:@"SyncTypesListPreferences"],
912 [defaults boolForKey:@"SyncTypesListPasswords"],
913 [defaults boolForKey:@"SyncTypesListAutofill"],
914 [defaults boolForKey:@"SyncTypesListTypedUrls"],
915 [defaults boolForKey:@"SyncTypesListTabs"]];
916}
David Jean5ca263c2021-08-18 09:19:30917} // namespace
918
919// Add all switches from experimental flags to |command_line|.
920void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
921 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
922
923 // Set the UA flag if UseMobileSafariUA is enabled.
924 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
925 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
926 // Chrome puts its product token.
927 int32_t major = 0;
928 int32_t minor = 0;
929 int32_t bugfix = 0;
930 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
931 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
932
933 command_line->AppendSwitchASCII(switches::kUserAgent,
934 web::BuildMobileUserAgent(product));
935 }
936
937 // Shared variables for all enterprise experimental flags.
Vincent Boisselle19200bc2021-09-01 17:58:25938 NSMutableDictionary* testing_policies =
939 CreateExperimentalTestingPolicies(command_line);
David Jean5ca263c2021-08-18 09:19:30940
941 // If a CBCM enrollment token is provided, force Chrome Browser Cloud
942 // Management to enabled and add the token to the list of policies.
943 NSString* token_key =
944 base::SysUTF8ToNSString(policy::key::kCloudManagementEnrollmentToken);
945 NSString* token = [defaults stringForKey:token_key];
946
947 if ([token length] > 0) {
948 command_line->AppendSwitch(switches::kEnableChromeBrowserCloudManagement);
949 [testing_policies setValue:token forKey:token_key];
950 }
951
Guillaume Jenkins57606d72020-08-13 17:32:55952 // If some policies were set, commit them to the app's registration defaults.
953 if ([testing_policies count] > 0) {
Guillaume Jenkinseeb7007c2020-06-25 22:55:40954 NSDictionary* registration_defaults =
955 @{kPolicyLoaderIOSConfigurationKey : testing_policies};
956 [defaults registerDefaults:registration_defaults];
957 }
958
sdefresne14900ee2015-11-27 14:43:21959 // Freeform commandline flags. These are added last, so that any flags added
960 // earlier in this function take precedence.
961 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
962 base::CommandLine::StringVector flags;
963 // Append an empty "program" argument.
964 flags.push_back("");
965
966 // The number of flags corresponds to the number of text fields in
967 // Experimental.plist.
968 const int kNumFreeformFlags = 5;
969 for (int i = 1; i <= kNumFreeformFlags; ++i) {
970 NSString* key =
971 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
972 NSString* flag = [defaults stringForKey:key];
973 if ([flag length]) {
Robbie Gibsonc91ce622019-05-20 14:44:33974 // iOS keyboard replaces -- with —, so undo that.
975 flag = [flag stringByReplacingOccurrencesOfString:@"—"
976 withString:@"--"
977 options:0
978 range:NSMakeRange(0, 1)];
979 // To make things easier, allow flags with no dashes by prepending them
980 // here. This also allows for flags that just have one dash if they
981 // exist.
982 if (![flag hasPrefix:@"-"]) {
983 flag = [@"--" stringByAppendingString:flag];
984 }
sdefresne14900ee2015-11-27 14:43:21985 flags.push_back(base::SysNSStringToUTF8(flag));
986 }
987 }
988
989 base::CommandLine temp_command_line(flags);
990 command_line->AppendArguments(temp_command_line, false);
991 }
msardafc76f662017-02-24 12:46:28992
justincohendacc85d2017-06-28 23:34:10993 // Populate command line flag for 3rd party keyboard omnibox workaround.
994 NSString* enableThirdPartyKeyboardWorkaround =
995 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
996 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
997 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
998 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
999 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
1000 }
1001
Sylvain Defresne25e69d22021-07-08 13:40:491002 ios::GetChromeBrowserProvider().AppendSwitchesFromExperimentalSettings(
msardafc76f662017-02-24 12:46:281003 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:211004}
1005
David Jean5ca263c2021-08-18 09:19:301006void MonitorExperimentalSettingsChanges() {
David Jean5ca263c2021-08-18 09:19:301007 // Startup values for settings to be observed.
David Jean6f85d44f2021-08-19 08:08:451008 __block NSString* hash = TestingPoliciesHash();
David Jeane83ed652021-08-25 14:52:481009 static std::atomic_bool pending_check(false);
David Jean5ca263c2021-08-18 09:19:301010
1011 auto monitor = ^(NSNotification* notification) {
David Jeane83ed652021-08-25 14:52:481012 bool has_pending_check = pending_check.exchange(true);
1013 if (has_pending_check)
1014 return;
1015
David Jeanbc0fae32021-08-25 10:31:391016 // Can be called from any thread from where the notification was sent,
1017 // but since it may change standardUserDefaults, and that has to be on main
1018 // thread, dispatch to main thread.
1019 dispatch_async(dispatch_get_main_queue(), ^{
1020 // Check if observed settings have changed. Since source and destination
1021 // are both user defaults, this is required to avoid cycling back here.
1022 NSString* newHash = TestingPoliciesHash();
1023 if (![newHash isEqualToString:hash]) {
1024 hash = newHash;
David Jean5ca263c2021-08-18 09:19:301025
David Jeanbc0fae32021-08-25 10:31:391026 // Publish update.
1027 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1028 NSMutableDictionary* testing_policies =
Vincent Boisselle19200bc2021-09-01 17:58:251029 CreateExperimentalTestingPolicies(
1030 base::CommandLine::ForCurrentProcess());
David Jeanbc0fae32021-08-25 10:31:391031 NSDictionary* registration_defaults =
1032 @{kPolicyLoaderIOSConfigurationKey : testing_policies};
1033 [defaults registerDefaults:registration_defaults];
1034 }
David Jeane83ed652021-08-25 14:52:481035
1036 pending_check.store(false);
David Jeanbc0fae32021-08-25 10:31:391037 });
David Jean5ca263c2021-08-18 09:19:301038 };
1039
1040 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
1041 [center addObserverForName:NSUserDefaultsDidChangeNotification
1042 object:nil
David Jeanbc0fae32021-08-25 10:31:391043 queue:nil
David Jean5ca263c2021-08-18 09:19:301044 usingBlock:monitor];
1045}
1046
sdefresne14900ee2015-11-27 14:43:211047void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
1048 base::CommandLine* command_line) {
Sylvain Defresne8327a2f2019-01-17 14:19:181049 GetGlobalFlagsState().ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:111050 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:531051 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:211052}
1053
jkrcalbf073372016-07-29 07:21:311054std::vector<std::string> RegisterAllFeatureVariationParameters(
1055 flags_ui::FlagsStorage* flags_storage,
1056 base::FeatureList* feature_list) {
Justin Cohen2e2adb52019-10-25 17:00:021057 // Occasionally DCHECK crashes on canary can be very distuptive. An
1058 // experimental flag was added to aid in temporarily disabling this for
1059 // canary testers.
1060#if defined(DCHECK_IS_CONFIGURABLE)
1061 if (experimental_flags::AreDCHECKCrashesDisabled()) {
1062 std::vector<base::FeatureList::FeatureOverrideInfo> overrides;
1063 overrides.push_back(
1064 {std::cref(base::kDCheckIsFatalFeature),
1065 base::FeatureList::OverrideState::OVERRIDE_DISABLE_FEATURE});
1066 feature_list->RegisterExtraFeatureOverrides(std::move(overrides));
1067 }
1068#endif // defined(DCHECK_IS_CONFIGURABLE)
1069
Sylvain Defresne8327a2f2019-01-17 14:19:181070 return GetGlobalFlagsState().RegisterAllFeatureVariationParameters(
1071 flags_storage, feature_list);
jkrcalbf073372016-07-29 07:21:311072}
1073
sdefresne14900ee2015-11-27 14:43:211074void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
1075 flags_ui::FlagAccess access,
Morten Stenshorne7afa5802021-07-15 10:04:431076 base::Value::ListStorage& supported_entries,
1077 base::Value::ListStorage& unsupported_entries) {
Sylvain Defresne8327a2f2019-01-17 14:19:181078 GetGlobalFlagsState().GetFlagFeatureEntries(
sdefresne14900ee2015-11-27 14:43:211079 flags_storage, access, supported_entries, unsupported_entries,
Renjie Tang208c8192020-11-03 00:46:511080 base::BindRepeating(&SkipConditionalFeatureEntry));
sdefresne14900ee2015-11-27 14:43:211081}
1082
1083void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
1084 const std::string& internal_name,
1085 bool enable) {
Sylvain Defresne8327a2f2019-01-17 14:19:181086 GetGlobalFlagsState().SetFeatureEntryEnabled(flags_storage, internal_name,
1087 enable);
sdefresne14900ee2015-11-27 14:43:211088}
1089
1090void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
Sylvain Defresne8327a2f2019-01-17 14:19:181091 GetGlobalFlagsState().ResetAllFlags(flags_storage);
sdefresne14900ee2015-11-27 14:43:211092}
1093
1094namespace testing {
1095
Elly Fong-Jones323ab1092021-08-23 22:36:311096base::span<const flags_ui::FeatureEntry> GetFeatureEntries() {
1097 return base::span<const flags_ui::FeatureEntry>(kFeatureEntries,
1098 base::size(kFeatureEntries));
sdefresne14900ee2015-11-27 14:43:211099}
1100
1101} // namespace testing