blob: e82958e7270fbe4e639c2b536b8b3112a3485fd5 [file] [log] [blame]
sdefresne14900ee2015-11-27 14:43:211// Copyright 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Implementation of about_flags for iOS that sets flags based on experimental
6// settings.
7
8#include "ios/chrome/browser/about_flags.h"
9
avi571943672015-12-22 02:12:4910#include <stddef.h>
11#include <stdint.h>
sdefresne14900ee2015-11-27 14:43:2112#import <UIKit/UIKit.h>
13
Gregory Chatzinofff6523722017-11-21 01:33:5314#include "base/base_switches.h"
sdefresne14900ee2015-11-27 14:43:2115#include "base/bind.h"
16#include "base/command_line.h"
17#include "base/logging.h"
18#include "base/memory/singleton.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"
Moe Ahmadid6d5d172018-06-20 17:20:2324#include "components/autofill/core/common/autofill_switches.h"
Olivier Robin3d60411622018-02-23 10:03:2225#include "components/autofill/ios/browser/autofill_switches.h"
sdefresne14900ee2015-11-27 14:43:2126#include "components/dom_distiller/core/dom_distiller_switches.h"
Tommy Nyquistc1d6dea12017-07-26 20:37:2327#include "components/feature_engagement/public/feature_constants.h"
28#include "components/feature_engagement/public/feature_list.h"
sdefresne14900ee2015-11-27 14:43:2129#include "components/flags_ui/feature_entry.h"
30#include "components/flags_ui/feature_entry_macros.h"
31#include "components/flags_ui/flags_storage.h"
32#include "components/flags_ui/flags_ui_switches.h"
Tanja Gornakb0985dd2018-10-11 17:24:4033#include "components/invalidation/impl/invalidation_switches.h"
noyau4cfb1332016-10-25 17:05:4234#include "components/ntp_tiles/switches.h"
Justin Donnelly33d712e2017-08-23 21:32:5135#include "components/omnibox/browser/omnibox_field_trial.h"
Ioana Pandeled14ce9e2017-11-28 14:41:4636#include "components/password_manager/core/common/password_manager_features.h"
mathp9b4c11d2017-07-06 20:24:1337#include "components/payments/core/features.h"
Marc Treib5fc99e1f2017-11-08 12:19:1838#include "components/search_provider_logos/switches.h"
Emily Starkbafa9062017-12-27 15:22:4639#include "components/security_state/core/features.h"
Valeriya Sinevicha79dc612018-09-25 14:49:0940#include "components/signin/core/browser/account_reconcilor.h"
David Rogera6c88122017-10-25 13:02:4641#include "components/signin/core/browser/signin_switches.h"
sdefresne36579782016-02-05 11:08:2542#include "components/strings/grit/components_strings.h"
Moe Ahmadid6d5d172018-06-20 17:20:2343#include "components/sync/driver/sync_driver_switches.h"
Moe Ahmadie4cce1f2018-12-18 23:48:0144#include "components/translate/core/browser/translate_prefs.h"
Mihai Sardarescu160ec662018-07-18 21:13:5145#include "components/unified_consent/feature.h"
mrefaat4539b032018-08-02 22:25:4546#include "ios/chrome/browser/app_launcher/app_launcher_flags.h"
Sylvain Defresneae6987e2018-03-01 13:21:4047#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2148#include "ios/chrome/browser/chrome_switches.h"
Olivier Robin2a898dc2018-10-31 14:37:0449#include "ios/chrome/browser/crash_report/crash_report_flags.h"
Moe Ahmadi2d4c8452018-11-30 04:44:2650#include "ios/chrome/browser/download/features.h"
Jean-François Geyelin30be5912017-08-25 12:05:3851#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
Chris Lu77905ac2018-12-06 20:46:5152#include "ios/chrome/browser/find_in_page/features.h"
vabr0215a8e2017-03-28 12:47:3453#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
mrefaat390f99c0d2018-05-10 19:44:2454#include "ios/chrome/browser/itunes_urls/itunes_urls_flag.h"
Yi Sua3d55f3d2018-09-24 17:49:4155#include "ios/chrome/browser/search_engines/feature_flags.h"
Jérôme Lebelec282832018-09-18 08:34:1856#include "ios/chrome/browser/signin/feature_flags.h"
Mike Doughertya5e5ad52017-08-05 00:11:5857#include "ios/chrome/browser/ssl/captive_portal_features.h"
Kurt Horimoto9165404a2018-11-13 23:48:1258#import "ios/chrome/browser/ui/dialogs/dialog_features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3559#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
sczs80a6f462018-12-05 20:37:1860#import "ios/chrome/browser/ui/infobars/infobar_feature.h"
Eugene Butc61230ab2018-11-09 00:31:5861#include "ios/chrome/browser/ui/sad_tab/features.h"
Mark Cogan02ed6c772018-05-31 17:00:5162#import "ios/chrome/browser/ui/toolbar/public/features.h"
Kurt Horimoto79d590b2018-09-12 19:09:2863#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h"
Justin Cohen2d81c582018-01-22 14:46:4464#include "ios/chrome/browser/ui/ui_feature_flags.h"
Yi Su392b3032018-06-05 07:26:4765#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2166#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2867#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Danyao Wang34da6ff2017-10-30 15:16:5668#include "ios/web/public/features.h"
sdefresne14900ee2015-11-27 14:43:2169#include "ios/web/public/user_agent.h"
70#include "ios/web/public/web_view_creation_util.h"
71
72#if !defined(OFFICIAL_BUILD)
73#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2274#endif
stkhapuginc1be1792016-12-13 14:30:5375
76#if !defined(__has_feature) || !__has_feature(objc_arc)
77#error "This file requires ARC support."
78#endif
sdefresne14900ee2015-11-27 14:43:2179
elawrence816f6790e2017-06-16 18:19:2880using flags_ui::FeatureEntry;
81
sdefresne14900ee2015-11-27 14:43:2182namespace {
Emily Starkbafa9062017-12-27 15:22:4683
84const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
85 {security_state::features::kMarkHttpAsFeatureParameterName,
86 security_state::features::kMarkHttpAsParameterDangerous}};
87const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = {
88 {security_state::features::kMarkHttpAsFeatureParameterName,
89 security_state::features::kMarkHttpAsParameterWarning}};
90const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
91 {security_state::features::kMarkHttpAsFeatureParameterName,
92 security_state::features::
93 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
94const FeatureEntry::FeatureParam
95 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = {
96 {security_state::features::kMarkHttpAsFeatureParameterName,
97 security_state::features::
98 kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}};
99
100const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
101 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
kokihoon189a4022018-10-13 02:43:44102 base::size(kMarkHttpAsDangerous), nullptr},
Emily Starkbafa9062017-12-27 15:22:46103 {"(mark with a Not Secure warning)", kMarkHttpAsWarning,
kokihoon189a4022018-10-13 02:43:44104 base::size(kMarkHttpAsWarning), nullptr},
Emily Starkbafa9062017-12-27 15:22:46105 {"(mark with a Not Secure warning and dangerous on form edits)",
106 kMarkHttpAsWarningAndDangerousOnFormEdits,
kokihoon189a4022018-10-13 02:43:44107 base::size(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr},
Emily Starkbafa9062017-12-27 15:22:46108 {"(mark with a Not Secure warning and dangerous on passwords and credit "
109 "card fields)",
110 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards,
kokihoon189a4022018-10-13 02:43:44111 base::size(kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards),
Emily Starkbafa9062017-12-27 15:22:46112 nullptr}};
elawrence816f6790e2017-06-16 18:19:28113
Marc Treib5fc99e1f2017-11-08 12:19:18114const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
115 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
116 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
117 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
118 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
119 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
120 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
121 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
122 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
123 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
124 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
125 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
126};
Marc Treib2752e8b2017-08-04 14:12:09127
Olivier Robin3d60411622018-02-23 10:03:22128const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
129 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
130 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
131 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
132 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
133 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
134 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
135 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
136 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
137 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
138};
139
Gauthier Ambard2392f2a2018-10-24 16:33:27140const FeatureEntry::FeatureParam kIconForSearchButtonGrey[] = {
141 {kIconForSearchButtonFeatureParameterName,
142 kIconForSearchButtonParameterGrey}};
143const FeatureEntry::FeatureParam kIconForSearchButtonColorful[] = {
144 {kIconForSearchButtonFeatureParameterName,
145 kIconForSearchButtonParameterColorful}};
146const FeatureEntry::FeatureParam kIconForSearchButtonMagnifying[] = {
147 {kIconForSearchButtonFeatureParameterName,
148 kIconForSearchButtonParameterMagnifying}};
149
150const FeatureEntry::FeatureVariation kIconForSearchButtonVariations[] = {
151 {"Grey search engine logo", kIconForSearchButtonGrey,
152 base::size(kIconForSearchButtonGrey), nullptr},
153 {"Colorful search engine logo", kIconForSearchButtonColorful,
154 base::size(kIconForSearchButtonColorful), nullptr},
155 {"Magnifying glass", kIconForSearchButtonMagnifying,
156 base::size(kIconForSearchButtonMagnifying), nullptr}};
157
Olivier Robince9386ebd2018-11-29 09:07:38158const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout3s[] = {
159 {crash_report::kDetectMainThreadFreezeParameterName,
160 crash_report::kDetectMainThreadFreezeParameter3s}};
161const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout5s[] = {
162 {crash_report::kDetectMainThreadFreezeParameterName,
163 crash_report::kDetectMainThreadFreezeParameter5s}};
164const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout7s[] = {
165 {crash_report::kDetectMainThreadFreezeParameterName,
166 crash_report::kDetectMainThreadFreezeParameter7s}};
167const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout9s[] = {
168 {crash_report::kDetectMainThreadFreezeParameterName,
169 crash_report::kDetectMainThreadFreezeParameter9s}};
170
171const FeatureEntry::FeatureVariation kDetectMainThreadFreezeVariations[] = {
172 {"3s", kDetectMainThreadFreezeTimeout3s,
173 base::size(kDetectMainThreadFreezeTimeout3s), nullptr},
174 {"5s", kDetectMainThreadFreezeTimeout5s,
175 base::size(kDetectMainThreadFreezeTimeout5s), nullptr},
176 {"7s", kDetectMainThreadFreezeTimeout7s,
177 base::size(kDetectMainThreadFreezeTimeout7s), nullptr},
178 {"9s", kDetectMainThreadFreezeTimeout9s,
179 base::size(kDetectMainThreadFreezeTimeout9s), nullptr}};
180
Cooper Knaak1e026562017-07-26 05:22:28181// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21182// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28183// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
184// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21185// macro for this type supplying the command line to the macro.
186// . MULTI_VALUE: a list of choices, the first of which should correspond to a
187// deactivated state for this lab (i.e. no command line option). To specify
188// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
189// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28190// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
191// either enabled, disabled, or uses the default value of the associated
192// base::Feature instance. To specify this type of entry use the macro
193// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
194// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
195// base::Feature instance. Choices corresponding to the default state, a
196// universally enabled state, and a universally disabled state are
197// automatically included. To specify this type of entry use the macro
198// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
199// the array of choices.
200//
sdefresne14900ee2015-11-27 14:43:21201// See the documentation of FeatureEntry for details on the fields.
202//
203// When adding a new choice, add it to the end of the list.
204const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46205 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28206 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46207 FEATURE_WITH_PARAMS_VALUE_TYPE(
208 security_state::features::kMarkHttpAsFeature,
209 kMarkHttpAsFeatureVariations,
210 "MarkHttpAs")},
Mike Doughertyc20eefa2018-02-20 19:20:33211 {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName,
212 flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos,
213 FEATURE_VALUE_TYPE(kCaptivePortalMetrics)},
Cooper Knaak1e026562017-07-26 05:22:28214 {"in-product-help-demo-mode-choice",
215 flag_descriptions::kInProductHelpDemoModeName,
216 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
217 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23218 feature_engagement::kIPHDemoMode,
219 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09220 "IPH_DemoMode")},
Moe Ahmadi2d4c8452018-11-30 04:44:26221 {"preview-usdz", flag_descriptions::kUsdzPreviewName,
222 flag_descriptions::kUsdzPreviewDescription, flags_ui::kOsIos,
223 FEATURE_VALUE_TYPE(download::kUsdzPreview)},
Marc Treib2752e8b2017-08-04 14:12:09224 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
225 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18226 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Jean-François Geyelin30be5912017-08-25 12:05:38227 {"drag_and_drop", flag_descriptions::kDragAndDropName,
228 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41229 FEATURE_VALUE_TYPE(kDragAndDrop)},
Eugene But468b6d5f02018-10-18 21:17:45230 {"ignores-viewport-scale-limits",
231 flag_descriptions::kIgnoresViewportScaleLimitsName,
232 flag_descriptions::kIgnoresViewportScaleLimitsDescription,
233 flags_ui::kOsIos,
234 FEATURE_VALUE_TYPE(web::features::kIgnoresViewportScaleLimits)},
Danyao Wang34da6ff2017-10-30 15:16:56235 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
236 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
237 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
sczsdc2e8e02018-01-09 18:39:32238 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
239 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
240 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
mrefaata6501d92017-12-11 19:50:50241 {"wk-http-system-cookie-store",
242 flag_descriptions::kWKHTTPSystemCookieStoreName,
243 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59244 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22245 {"enable-autofill-credit-card-upload",
246 flag_descriptions::kAutofillCreditCardUploadName,
247 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24248 FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
Lakshmi Kumar Dabbiruee22004e2018-06-01 01:52:27249 {"enable-autofill-credit-card-downstream-google-pay-branding",
250 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSName,
251 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSDescription,
252 flags_ui::kOsIos,
253 FEATURE_VALUE_TYPE(
254 autofill::features::kAutofillDownstreamUseGooglePayBrandingOniOS)},
Moe Ahmadi3fd9f202018-05-10 17:39:24255 {"enable-autofill-credit-card-upload-google-pay-branding",
256 flag_descriptions::kAutofillUpstreamUseGooglePayBrandingOnMobileName,
257 flag_descriptions::
258 kAutofillUpstreamUseGooglePayBrandingOnMobileDescription,
259 flags_ui::kOsIos,
260 FEATURE_VALUE_TYPE(
261 autofill::features::kAutofillUpstreamUseGooglePayBrandingOnMobile)},
Jared Saul2e55e7f12018-10-26 20:44:43262 {"enable-autofill-save-credit-card-uses-strike-system",
263 flag_descriptions::kEnableAutofillSaveCreditCardUsesStrikeSystemName,
264 flag_descriptions::
265 kEnableAutofillSaveCreditCardUsesStrikeSystemDescription,
266 flags_ui::kOsIos,
267 FEATURE_VALUE_TYPE(
268 autofill::features::kAutofillSaveCreditCardUsesStrikeSystem)},
Moe Ahmadid6d5d172018-06-20 17:20:23269 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
270 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
271 SINGLE_VALUE_TYPE_AND_VALUE(
272 switches::kSyncServiceURL,
273 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
274 {"wallet-service-use-sandbox",
275 flag_descriptions::kWalletServiceUseSandboxName,
276 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
277 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
278 autofill::switches::kWalletServiceUseSandbox,
279 "1",
280 autofill::switches::kWalletServiceUseSandbox,
281 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59282 {"show-autofill-type-predictions",
283 flag_descriptions::kShowAutofillTypePredictionsName,
284 flag_descriptions::kShowAutofillTypePredictionsDescription,
285 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46286 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22287 {"autofill-ios-delay-between-fields",
288 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
289 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
290 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Sylvain Defresneae6987e2018-03-01 13:21:40291 {"new-clear-browsing-data-ui",
292 flag_descriptions::kNewClearBrowsingDataUIName,
293 flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos,
294 FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)},
mrefaat390f99c0d2018-05-10 19:44:24295 {"itunes-urls-store-kit-handling",
296 flag_descriptions::kITunesUrlsStoreKitHandlingName,
297 flag_descriptions::kITunesUrlsStoreKitHandlingDescription,
298 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kITunesUrlsStoreKitHandling)},
Jérôme Lebelfa6c5ae2018-03-29 13:46:57299 {"unified-consent", flag_descriptions::kUnifiedConsentName,
300 flag_descriptions::kUnifiedConsentDescription, flags_ui::kOsIos,
Mihai Sardarescu160ec662018-07-18 21:13:51301 FEATURE_VALUE_TYPE(unified_consent::kUnifiedConsent)},
sebsg93dc01c2018-04-05 16:42:48302 {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName,
303 flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos,
304 FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)},
Olivier Robin081912dd2018-06-11 09:14:26305 {"autofill-prefilled-fields",
306 flag_descriptions::kAutofillPrefilledFieldsName,
307 flag_descriptions::kAutofillPrefilledFieldsDescription, flags_ui::kOsIos,
308 FEATURE_VALUE_TYPE(autofill::features::kAutofillPrefilledFields)},
Olivier Robind81475b02018-06-20 21:30:11309 {"autofill-show-all-profiles-on-prefilled-forms",
310 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsName,
311 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsDescription,
312 flags_ui::kOsIos,
313 FEATURE_VALUE_TYPE(
314 autofill::features::kAutofillShowAllSuggestionsOnPrefilledForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08315 {"autofill-restrict-formless-form-extraction",
316 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
317 flag_descriptions::
318 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
319 flags_ui::kOsIos,
320 FEATURE_VALUE_TYPE(
321 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
Roger McFarlanee193ab122018-11-22 20:55:07322 {"autofill-rich-metadata-queries",
323 flag_descriptions::kAutofillRichMetadataQueriesName,
324 flag_descriptions::kAutofillRichMetadataQueriesDescription,
325 flags_ui::kOsIos,
326 FEATURE_VALUE_TYPE(autofill::features::kAutofillRichMetadataQueries)},
Kurt Horimotodc33af32018-05-01 01:39:14327 {"fullscreen-viewport-adjustment-experiment",
328 flag_descriptions::kFullscreenViewportAdjustmentExperimentName,
329 flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription,
330 flags_ui::kOsIos,
331 MULTI_VALUE_TYPE(
332 fullscreen::features::kViewportAdjustmentExperimentChoices)},
Roger McFarlane1a37d7b2018-04-20 22:45:19333 {"autofill-enforce-min-required-fields-for-heuristics",
334 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
335 flag_descriptions::
336 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
337 flags_ui::kOsIos,
338 FEATURE_VALUE_TYPE(
339 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
340 {"autofill-enforce-min-required-fields-for-query",
341 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
342 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
343 flags_ui::kOsIos,
344 FEATURE_VALUE_TYPE(
345 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
346 {"autofill-enforce-min-required-fields-for-upload",
347 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
348 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
349 flags_ui::kOsIos,
350 FEATURE_VALUE_TYPE(
351 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Gauthier Ambard4417f852018-04-26 14:24:32352 {"browser-container-fullscreen",
353 flag_descriptions::kBrowserContainerFullscreenName,
354 flag_descriptions::kBrowserContainerFullscreenDescription,
Gauthier Ambard5d7627282018-05-18 08:20:07355 flags_ui::kOsIos,
356 FEATURE_VALUE_TYPE(web::features::kBrowserContainerFullscreen)},
Roger McFarlane2eceba982018-05-18 01:37:11357 {"autofill-cache-query-responses",
358 flag_descriptions::kAutofillCacheQueryResponsesName,
359 flag_descriptions::kAutofillCacheQueryResponsesDescription,
360 flags_ui::kOsIos,
361 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Jeffrey Cohen05cdafa392018-08-15 20:49:17362 {"autofill-enable-company-name",
363 flag_descriptions::kAutofillEnableCompanyNameName,
364 flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos,
365 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)},
Javier Ernesto Flores Robles23c71a7d2018-06-01 09:51:17366 {"autofill-manual-fallback", flag_descriptions::kAutofillManualFallbackName,
367 flag_descriptions::kAutofillManualFallbackDescription, flags_ui::kOsIos,
368 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallback)},
Yi Su392b3032018-06-05 07:26:47369 {"webpage-text-accessibility",
370 flag_descriptions::kWebPageTextAccessibilityName,
371 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
372 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Mike Dougherty39d36b02018-06-19 19:21:40373 {"web-frame-messaging", flag_descriptions::kWebFrameMessagingName,
374 flag_descriptions::kWebFrameMessagingDescription, flags_ui::kOsIos,
375 FEATURE_VALUE_TYPE(web::features::kWebFrameMessaging)},
Yi Suf63219e2018-06-25 17:41:01376 {"copy-image", flag_descriptions::kCopyImageName,
377 flag_descriptions::kCopyImageDescription, flags_ui::kOsIos,
378 FEATURE_VALUE_TYPE(kCopyImage)},
Vadym Doroshenkoa9a914942018-07-19 08:23:30379 {"new-password-form-parsing",
380 flag_descriptions::kNewPasswordFormParsingName,
381 flag_descriptions::kNewPasswordFormParsingDescription, flags_ui::kOsIos,
382 FEATURE_VALUE_TYPE(password_manager::features::kNewPasswordFormParsing)},
mrefaat4539b032018-08-02 22:25:45383 {"app-launcher-refresh", flag_descriptions::kAppLauncherRefreshName,
384 flag_descriptions::kAppLauncherRefreshDescription, flags_ui::kOsIos,
385 FEATURE_VALUE_TYPE(kAppLauncherRefresh)},
Marc Treib6f0bbd22018-08-28 10:07:19386 {"sync-standalone-transport",
387 flag_descriptions::kSyncStandaloneTransportName,
388 flag_descriptions::kSyncStandaloneTransportDescription, flags_ui::kOsIos,
389 FEATURE_VALUE_TYPE(switches::kSyncStandaloneTransport)},
Marc Treib4bd95e72018-08-30 06:30:58390 {"sync-support-secondary-account",
391 flag_descriptions::kSyncSupportSecondaryAccountName,
392 flag_descriptions::kSyncSupportSecondaryAccountDescription,
393 flags_ui::kOsIos,
394 FEATURE_VALUE_TYPE(switches::kSyncSupportSecondaryAccount)},
Gauthier Ambard66de93d2018-08-30 15:58:19395 {"out-of-web-fullscreen", flag_descriptions::kOutOfWebFullscreenName,
396 flag_descriptions::kOutOfWebFullscreenDescription, flags_ui::kOsIos,
397 FEATURE_VALUE_TYPE(web::features::kOutOfWebFullscreen)},
Javier Ernesto Flores Robles8e66f732018-09-12 15:41:15398 {"autofill-manual-fallback-phase-two",
399 flag_descriptions::kAutofillManualFallbackPhaseTwoName,
400 flag_descriptions::kAutofillManualFallbackPhaseTwoDescription,
401 flags_ui::kOsIos,
402 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallbackPhaseTwo)},
Kurt Horimoto79d590b2018-09-12 19:09:28403 {"toolbar-container", flag_descriptions::kToolbarContainerName,
404 flag_descriptions::kToolbarContainerDescription, flags_ui::kOsIos,
405 FEATURE_VALUE_TYPE(toolbar_container::kToolbarContainerEnabled)},
Eugene Butc61230ab2018-11-09 00:31:58406 {"present-sad-tab-in-view-controller",
407 flag_descriptions::kPresentSadTabInViewControllerName,
408 flag_descriptions::kPresentSadTabInViewControllerDescription,
409 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kPresentSadTabInViewController)},
[email protected]5b899dc2018-10-02 09:20:01410 {"omnibox-popup-shortcuts",
411 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateName,
412 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateDescription,
413 flags_ui::kOsIos,
414 FEATURE_VALUE_TYPE(omnibox::kOmniboxPopupShortcutIconsInZeroState)},
Jérôme Lebelec282832018-09-18 08:34:18415 {"sso-with-wkwebview", flag_descriptions::kSSOWithWKWebViewName,
416 flag_descriptions::kSSOWithWKWebViewDescription, flags_ui::kOsIos,
417 FEATURE_VALUE_TYPE(kSSOWithWKWebView)},
Yi Sua3d55f3d2018-09-24 17:49:41418 {"custom-search-engines", flag_descriptions::kCustomSearchEnginesName,
419 flag_descriptions::kCustomSearchEnginesDescription, flags_ui::kOsIos,
420 FEATURE_VALUE_TYPE(kCustomSearchEngines)},
Valeriya Sinevicha79dc612018-09-25 14:49:09421 {"use-multilogin-endpoint", flag_descriptions::kUseMultiloginEndpointName,
422 flag_descriptions::kUseMultiloginEndpointDescription, flags_ui::kOsIos,
423 FEATURE_VALUE_TYPE(kUseMultiloginEndpoint)},
edchin18a3e602018-10-08 23:39:35424 {"closing-last-incognito-tab",
425 flag_descriptions::kClosingLastIncognitoTabName,
426 flag_descriptions::kClosingLastIncognitoTabDescription, flags_ui::kOsIos,
427 FEATURE_VALUE_TYPE(kClosingLastIncognitoTab)},
Gauthier Ambardce7fd582018-10-09 08:37:05428 {"omnibox-tab-switch-suggestions",
429 flag_descriptions::kOmniboxTabSwitchSuggestionsName,
430 flag_descriptions::kOmniboxTabSwitchSuggestionsDescription,
431 flags_ui::kOsIos,
432 FEATURE_VALUE_TYPE(omnibox::kOmniboxTabSwitchSuggestions)},
Tanja Gornakb0985dd2018-10-11 17:24:40433 {"fcm-invalidations", flag_descriptions::kFCMInvalidationsName,
434 flag_descriptions::kFCMInvalidationsDescription, flags_ui::kOsIos,
435 FEATURE_VALUE_TYPE(invalidation::switches::kFCMInvalidations)},
Justin Cohen9a5023212018-10-15 14:32:37436 {"browser-container-contains-ntp",
437 flag_descriptions::kBrowserContainerContainsNTPName,
438 flag_descriptions::kBrowserContainerContainsNTPDescription,
439 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerContainsNTP)},
Gauthier Ambard2392f2a2018-10-24 16:33:27440 {"search-icon-toggle", flag_descriptions::kSearchIconToggleName,
441 flag_descriptions::kSearchIconToggleDescription, flags_ui::kOsIos,
442 FEATURE_WITH_PARAMS_VALUE_TYPE(kIconForSearchButtonFeature,
443 kIconForSearchButtonVariations,
444 "ToggleSearchButtonIcon")},
Olivier Robin2a898dc2018-10-31 14:37:04445 {"enable-breakpad-upload-no-delay",
446 flag_descriptions::kBreakpadNoDelayInitialUploadName,
447 flag_descriptions::kBreakpadNoDelayInitialUploadDescription,
448 flags_ui::kOsIos,
449 FEATURE_VALUE_TYPE(crash_report::kBreakpadNoDelayInitialUpload)},
Moe Ahmadie4cce1f2018-12-18 23:48:01450 {"enable-compact-translate-infobar",
451 flag_descriptions::kCompactTranslateInfobarName,
452 flag_descriptions::kCompactTranslateInfobarDescription, flags_ui::kOsIos,
453 FEATURE_VALUE_TYPE(translate::kCompactTranslateInfobarIOS)},
Kurt Horimoto9165404a2018-11-13 23:48:12454 {"non-modal-dialogs", flag_descriptions::kNonModalDialogsName,
455 flag_descriptions::kNonModalDialogsDescription, flags_ui::kOsIos,
456 FEATURE_VALUE_TYPE(dialogs::kNonModalDialogs)},
Mikel Astizdb43c5652018-11-22 16:52:05457 {"sync-pseudo-uss-favicons", flag_descriptions::kSyncPseudoUSSFaviconsName,
458 flag_descriptions::kSyncPseudoUSSFaviconsDescription, flags_ui::kOsIos,
459 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSFavicons)},
460 {"sync-pseudo-uss-history-delete-directives",
461 flag_descriptions::kSyncPseudoUSSHistoryDeleteDirectivesName,
462 flag_descriptions::kSyncPseudoUSSHistoryDeleteDirectivesDescription,
463 flags_ui::kOsIos,
464 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSHistoryDeleteDirectives)},
465 {"sync-pseudo-uss-passwords",
466 flag_descriptions::kSyncPseudoUSSPasswordsName,
467 flag_descriptions::kSyncPseudoUSSPasswordsDescription, flags_ui::kOsIos,
468 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSPasswords)},
469 {"sync-pseudo-uss-preferences",
470 flag_descriptions::kSyncPseudoUSSPreferencesName,
471 flag_descriptions::kSyncPseudoUSSPreferencesDescription, flags_ui::kOsIos,
472 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSPreferences)},
473 {"sync-pseudo-uss-priority-preferences",
474 flag_descriptions::kSyncPseudoUSSPriorityPreferencesName,
475 flag_descriptions::kSyncPseudoUSSPriorityPreferencesDescription,
476 flags_ui::kOsIos,
477 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSPriorityPreferences)},
478 {"sync-pseudo-uss-supervised-users",
479 flag_descriptions::kSyncPseudoUSSSupervisedUsersName,
480 flag_descriptions::kSyncPseudoUSSSupervisedUsersDescription,
481 flags_ui::kOsIos,
482 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSSupervisedUsers)},
Olivier Robince9386ebd2018-11-29 09:07:38483 {"detect-main-thread-freeze",
484 flag_descriptions::kDetectMainThreadFreezeName,
485 flag_descriptions::kDetectMainThreadFreezeDescription, flags_ui::kOsIos,
486 FEATURE_WITH_PARAMS_VALUE_TYPE(crash_report::kDetectMainThreadFreeze,
487 kDetectMainThreadFreezeVariations,
488 "DetectMainThreadFreeze")},
Mohamed Amir Yosef9e8a1f02018-12-03 21:41:14489 {"enable-sync-uss-bookmarks",
490 flag_descriptions::kEnableSyncUSSBookmarksName,
491 flag_descriptions::kEnableSyncUSSBookmarksDescription, flags_ui::kOsIos,
492 FEATURE_VALUE_TYPE(switches::kSyncUSSBookmarks)},
sczs80a6f462018-12-05 20:37:18493 {"infobar-ui-reboot", flag_descriptions::kInfobarUIRebootName,
494 flag_descriptions::kInfobarUIRebootDescription, flags_ui::kOsIos,
495 FEATURE_VALUE_TYPE(kInfobarUIReboot)},
Chris Lu77905ac2018-12-06 20:46:51496 {"find-in-page-iframe", flag_descriptions::kFindInPageiFrameName,
497 flag_descriptions::kFindInPageiFrameDescription, flags_ui::kOsIos,
498 FEATURE_VALUE_TYPE(kFindInPageiFrame)},
Robbie Gibsoncd964bb2018-12-11 18:22:21499 {"search-copied-image", flag_descriptions::kSearchCopiedImageName,
500 flag_descriptions::kSearchCopiedImageDescription, flags_ui::kOsIos,
501 FEATURE_VALUE_TYPE(kSearchCopiedImage)},
Robbie Gibson640d842b2018-12-18 11:55:13502 {"copied-text-behavior", flag_descriptions::kCopiedTextBehaviorName,
503 flag_descriptions::kCopiedTextBehaviorName, flags_ui::kOsIos,
504 FEATURE_VALUE_TYPE(kCopiedTextBehavior)},
Gauthier Ambardcfd85182018-01-05 10:37:46505};
sdefresne14900ee2015-11-27 14:43:21506
507// Add all switches from experimental flags to |command_line|.
508void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
509 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
510
sdefresne14900ee2015-11-27 14:43:21511 // Set the UA flag if UseMobileSafariUA is enabled.
512 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
513 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
514 // Chrome puts its product token.
avi571943672015-12-22 02:12:49515 int32_t major = 0;
516 int32_t minor = 0;
517 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21518 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
519 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
520
521 command_line->AppendSwitchASCII(switches::kUserAgent,
522 web::BuildUserAgentFromProduct(product));
523 }
524
525 // Freeform commandline flags. These are added last, so that any flags added
526 // earlier in this function take precedence.
527 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
528 base::CommandLine::StringVector flags;
529 // Append an empty "program" argument.
530 flags.push_back("");
531
532 // The number of flags corresponds to the number of text fields in
533 // Experimental.plist.
534 const int kNumFreeformFlags = 5;
535 for (int i = 1; i <= kNumFreeformFlags; ++i) {
536 NSString* key =
537 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
538 NSString* flag = [defaults stringForKey:key];
539 if ([flag length]) {
540 flags.push_back(base::SysNSStringToUTF8(flag));
541 }
542 }
543
544 base::CommandLine temp_command_line(flags);
545 command_line->AppendArguments(temp_command_line, false);
546 }
msardafc76f662017-02-24 12:46:28547
justincohendacc85d2017-06-28 23:34:10548 // Populate command line flag for 3rd party keyboard omnibox workaround.
549 NSString* enableThirdPartyKeyboardWorkaround =
550 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
551 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
552 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
553 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
554 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
555 }
556
msardafc76f662017-02-24 12:46:28557 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
558 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21559}
560
561bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
562 return false;
563}
564
565class FlagsStateSingleton {
566 public:
567 FlagsStateSingleton()
kokihoon189a4022018-10-13 02:43:44568 : flags_state_(kFeatureEntries, base::size(kFeatureEntries)) {}
sdefresne14900ee2015-11-27 14:43:21569 ~FlagsStateSingleton() {}
570
571 static FlagsStateSingleton* GetInstance() {
572 return base::Singleton<FlagsStateSingleton>::get();
573 }
574
575 static flags_ui::FlagsState* GetFlagsState() {
576 return &GetInstance()->flags_state_;
577 }
578
579 private:
580 flags_ui::FlagsState flags_state_;
581
582 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
583};
584} // namespace
585
586void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
587 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02588 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21589 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11590 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53591 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21592}
593
jkrcalbf073372016-07-29 07:21:31594std::vector<std::string> RegisterAllFeatureVariationParameters(
595 flags_ui::FlagsStorage* flags_storage,
596 base::FeatureList* feature_list) {
597 return FlagsStateSingleton::GetFlagsState()
598 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
599}
600
sdefresne14900ee2015-11-27 14:43:21601void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
602 flags_ui::FlagAccess access,
603 base::ListValue* supported_entries,
604 base::ListValue* unsupported_entries) {
605 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
606 flags_storage, access, supported_entries, unsupported_entries,
607 base::Bind(&SkipConditionalFeatureEntry));
608}
609
610void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
611 const std::string& internal_name,
612 bool enable) {
613 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
614 flags_storage, internal_name, enable);
615}
616
617void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
618 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
619}
620
621namespace testing {
622
623const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
kokihoon189a4022018-10-13 02:43:44624 *count = base::size(kFeatureEntries);
sdefresne14900ee2015-11-27 14:43:21625 return kFeatureEntries;
626}
627
628} // namespace testing