blob: afabcaf60311ef4ccba220ab2cf70c3e8e6ede20 [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}};
Emily Starkbafa9062017-12-27 15:22:4687const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
88 {security_state::features::kMarkHttpAsFeatureParameterName,
89 security_state::features::
90 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
Emily Starkbafa9062017-12-27 15:22:4691
92const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
93 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
kokihoon189a4022018-10-13 02:43:4494 base::size(kMarkHttpAsDangerous), nullptr},
Emily Starkbafa9062017-12-27 15:22:4695 {"(mark with a Not Secure warning and dangerous on form edits)",
96 kMarkHttpAsWarningAndDangerousOnFormEdits,
Joe DeBlasio20e01fd2018-12-20 19:59:3097 base::size(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr}};
elawrence816f6790e2017-06-16 18:19:2898
Marc Treib5fc99e1f2017-11-08 12:19:1899const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
100 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
101 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
102 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
103 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
104 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
105 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
106 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
107 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
108 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
109 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
110 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
111};
Marc Treib2752e8b2017-08-04 14:12:09112
Olivier Robin3d60411622018-02-23 10:03:22113const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
114 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
115 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
116 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
117 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
118 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
119 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
120 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
121 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
122 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
123};
124
Gauthier Ambard2392f2a2018-10-24 16:33:27125const FeatureEntry::FeatureParam kIconForSearchButtonGrey[] = {
126 {kIconForSearchButtonFeatureParameterName,
127 kIconForSearchButtonParameterGrey}};
128const FeatureEntry::FeatureParam kIconForSearchButtonColorful[] = {
129 {kIconForSearchButtonFeatureParameterName,
130 kIconForSearchButtonParameterColorful}};
131const FeatureEntry::FeatureParam kIconForSearchButtonMagnifying[] = {
132 {kIconForSearchButtonFeatureParameterName,
133 kIconForSearchButtonParameterMagnifying}};
134
135const FeatureEntry::FeatureVariation kIconForSearchButtonVariations[] = {
136 {"Grey search engine logo", kIconForSearchButtonGrey,
137 base::size(kIconForSearchButtonGrey), nullptr},
138 {"Colorful search engine logo", kIconForSearchButtonColorful,
139 base::size(kIconForSearchButtonColorful), nullptr},
140 {"Magnifying glass", kIconForSearchButtonMagnifying,
141 base::size(kIconForSearchButtonMagnifying), nullptr}};
142
Olivier Robince9386ebd2018-11-29 09:07:38143const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout3s[] = {
144 {crash_report::kDetectMainThreadFreezeParameterName,
145 crash_report::kDetectMainThreadFreezeParameter3s}};
146const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout5s[] = {
147 {crash_report::kDetectMainThreadFreezeParameterName,
148 crash_report::kDetectMainThreadFreezeParameter5s}};
149const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout7s[] = {
150 {crash_report::kDetectMainThreadFreezeParameterName,
151 crash_report::kDetectMainThreadFreezeParameter7s}};
152const FeatureEntry::FeatureParam kDetectMainThreadFreezeTimeout9s[] = {
153 {crash_report::kDetectMainThreadFreezeParameterName,
154 crash_report::kDetectMainThreadFreezeParameter9s}};
155
156const FeatureEntry::FeatureVariation kDetectMainThreadFreezeVariations[] = {
157 {"3s", kDetectMainThreadFreezeTimeout3s,
158 base::size(kDetectMainThreadFreezeTimeout3s), nullptr},
159 {"5s", kDetectMainThreadFreezeTimeout5s,
160 base::size(kDetectMainThreadFreezeTimeout5s), nullptr},
161 {"7s", kDetectMainThreadFreezeTimeout7s,
162 base::size(kDetectMainThreadFreezeTimeout7s), nullptr},
163 {"9s", kDetectMainThreadFreezeTimeout9s,
164 base::size(kDetectMainThreadFreezeTimeout9s), nullptr}};
165
Cooper Knaak1e026562017-07-26 05:22:28166// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21167// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28168// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
169// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21170// macro for this type supplying the command line to the macro.
171// . MULTI_VALUE: a list of choices, the first of which should correspond to a
172// deactivated state for this lab (i.e. no command line option). To specify
173// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
174// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28175// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
176// either enabled, disabled, or uses the default value of the associated
177// base::Feature instance. To specify this type of entry use the macro
178// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
179// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
180// base::Feature instance. Choices corresponding to the default state, a
181// universally enabled state, and a universally disabled state are
182// automatically included. To specify this type of entry use the macro
183// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
184// the array of choices.
185//
sdefresne14900ee2015-11-27 14:43:21186// See the documentation of FeatureEntry for details on the fields.
187//
188// When adding a new choice, add it to the end of the list.
189const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46190 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28191 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46192 FEATURE_WITH_PARAMS_VALUE_TYPE(
193 security_state::features::kMarkHttpAsFeature,
194 kMarkHttpAsFeatureVariations,
195 "MarkHttpAs")},
Mike Doughertyc20eefa2018-02-20 19:20:33196 {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName,
197 flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos,
198 FEATURE_VALUE_TYPE(kCaptivePortalMetrics)},
Cooper Knaak1e026562017-07-26 05:22:28199 {"in-product-help-demo-mode-choice",
200 flag_descriptions::kInProductHelpDemoModeName,
201 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
202 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23203 feature_engagement::kIPHDemoMode,
204 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09205 "IPH_DemoMode")},
Moe Ahmadi2d4c8452018-11-30 04:44:26206 {"preview-usdz", flag_descriptions::kUsdzPreviewName,
207 flag_descriptions::kUsdzPreviewDescription, flags_ui::kOsIos,
208 FEATURE_VALUE_TYPE(download::kUsdzPreview)},
Marc Treib2752e8b2017-08-04 14:12:09209 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
210 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18211 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Jean-François Geyelin30be5912017-08-25 12:05:38212 {"drag_and_drop", flag_descriptions::kDragAndDropName,
213 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41214 FEATURE_VALUE_TYPE(kDragAndDrop)},
Eugene But468b6d5f02018-10-18 21:17:45215 {"ignores-viewport-scale-limits",
216 flag_descriptions::kIgnoresViewportScaleLimitsName,
217 flag_descriptions::kIgnoresViewportScaleLimitsDescription,
218 flags_ui::kOsIos,
219 FEATURE_VALUE_TYPE(web::features::kIgnoresViewportScaleLimits)},
Danyao Wang34da6ff2017-10-30 15:16:56220 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
221 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
222 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
sczsdc2e8e02018-01-09 18:39:32223 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
224 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
225 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
mrefaata6501d92017-12-11 19:50:50226 {"wk-http-system-cookie-store",
227 flag_descriptions::kWKHTTPSystemCookieStoreName,
228 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59229 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22230 {"enable-autofill-credit-card-upload",
231 flag_descriptions::kAutofillCreditCardUploadName,
232 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24233 FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
Lakshmi Kumar Dabbiruee22004e2018-06-01 01:52:27234 {"enable-autofill-credit-card-downstream-google-pay-branding",
235 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSName,
236 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSDescription,
237 flags_ui::kOsIos,
238 FEATURE_VALUE_TYPE(
239 autofill::features::kAutofillDownstreamUseGooglePayBrandingOniOS)},
Jared Saul2e55e7f12018-10-26 20:44:43240 {"enable-autofill-save-credit-card-uses-strike-system",
241 flag_descriptions::kEnableAutofillSaveCreditCardUsesStrikeSystemName,
242 flag_descriptions::
243 kEnableAutofillSaveCreditCardUsesStrikeSystemDescription,
244 flags_ui::kOsIos,
245 FEATURE_VALUE_TYPE(
246 autofill::features::kAutofillSaveCreditCardUsesStrikeSystem)},
Moe Ahmadid6d5d172018-06-20 17:20:23247 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
248 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
249 SINGLE_VALUE_TYPE_AND_VALUE(
250 switches::kSyncServiceURL,
251 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
252 {"wallet-service-use-sandbox",
253 flag_descriptions::kWalletServiceUseSandboxName,
254 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
255 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
256 autofill::switches::kWalletServiceUseSandbox,
257 "1",
258 autofill::switches::kWalletServiceUseSandbox,
259 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59260 {"show-autofill-type-predictions",
261 flag_descriptions::kShowAutofillTypePredictionsName,
262 flag_descriptions::kShowAutofillTypePredictionsDescription,
263 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46264 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22265 {"autofill-ios-delay-between-fields",
266 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
267 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
268 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Sylvain Defresneae6987e2018-03-01 13:21:40269 {"new-clear-browsing-data-ui",
270 flag_descriptions::kNewClearBrowsingDataUIName,
271 flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos,
272 FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)},
mrefaat390f99c0d2018-05-10 19:44:24273 {"itunes-urls-store-kit-handling",
274 flag_descriptions::kITunesUrlsStoreKitHandlingName,
275 flag_descriptions::kITunesUrlsStoreKitHandlingDescription,
276 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kITunesUrlsStoreKitHandling)},
Jérôme Lebelfa6c5ae2018-03-29 13:46:57277 {"unified-consent", flag_descriptions::kUnifiedConsentName,
278 flag_descriptions::kUnifiedConsentDescription, flags_ui::kOsIos,
Mihai Sardarescu160ec662018-07-18 21:13:51279 FEATURE_VALUE_TYPE(unified_consent::kUnifiedConsent)},
sebsg93dc01c2018-04-05 16:42:48280 {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName,
281 flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos,
282 FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)},
Olivier Robin081912dd2018-06-11 09:14:26283 {"autofill-prefilled-fields",
284 flag_descriptions::kAutofillPrefilledFieldsName,
285 flag_descriptions::kAutofillPrefilledFieldsDescription, flags_ui::kOsIos,
286 FEATURE_VALUE_TYPE(autofill::features::kAutofillPrefilledFields)},
Olivier Robind81475b02018-06-20 21:30:11287 {"autofill-show-all-profiles-on-prefilled-forms",
288 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsName,
289 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsDescription,
290 flags_ui::kOsIos,
291 FEATURE_VALUE_TYPE(
292 autofill::features::kAutofillShowAllSuggestionsOnPrefilledForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08293 {"autofill-restrict-formless-form-extraction",
294 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
295 flag_descriptions::
296 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
297 flags_ui::kOsIos,
298 FEATURE_VALUE_TYPE(
299 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
Roger McFarlanee193ab122018-11-22 20:55:07300 {"autofill-rich-metadata-queries",
301 flag_descriptions::kAutofillRichMetadataQueriesName,
302 flag_descriptions::kAutofillRichMetadataQueriesDescription,
303 flags_ui::kOsIos,
304 FEATURE_VALUE_TYPE(autofill::features::kAutofillRichMetadataQueries)},
Kurt Horimotodc33af32018-05-01 01:39:14305 {"fullscreen-viewport-adjustment-experiment",
306 flag_descriptions::kFullscreenViewportAdjustmentExperimentName,
307 flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription,
308 flags_ui::kOsIos,
309 MULTI_VALUE_TYPE(
310 fullscreen::features::kViewportAdjustmentExperimentChoices)},
Roger McFarlane1a37d7b2018-04-20 22:45:19311 {"autofill-enforce-min-required-fields-for-heuristics",
312 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
313 flag_descriptions::
314 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
315 flags_ui::kOsIos,
316 FEATURE_VALUE_TYPE(
317 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
318 {"autofill-enforce-min-required-fields-for-query",
319 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
320 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
321 flags_ui::kOsIos,
322 FEATURE_VALUE_TYPE(
323 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
324 {"autofill-enforce-min-required-fields-for-upload",
325 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
326 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
327 flags_ui::kOsIos,
328 FEATURE_VALUE_TYPE(
329 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Gauthier Ambard4417f852018-04-26 14:24:32330 {"browser-container-fullscreen",
331 flag_descriptions::kBrowserContainerFullscreenName,
332 flag_descriptions::kBrowserContainerFullscreenDescription,
Gauthier Ambard5d7627282018-05-18 08:20:07333 flags_ui::kOsIos,
334 FEATURE_VALUE_TYPE(web::features::kBrowserContainerFullscreen)},
Roger McFarlane2eceba982018-05-18 01:37:11335 {"autofill-cache-query-responses",
336 flag_descriptions::kAutofillCacheQueryResponsesName,
337 flag_descriptions::kAutofillCacheQueryResponsesDescription,
338 flags_ui::kOsIos,
339 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Jeffrey Cohen05cdafa392018-08-15 20:49:17340 {"autofill-enable-company-name",
341 flag_descriptions::kAutofillEnableCompanyNameName,
342 flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos,
343 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)},
Javier Ernesto Flores Robles23c71a7d2018-06-01 09:51:17344 {"autofill-manual-fallback", flag_descriptions::kAutofillManualFallbackName,
345 flag_descriptions::kAutofillManualFallbackDescription, flags_ui::kOsIos,
346 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallback)},
Yi Su392b3032018-06-05 07:26:47347 {"webpage-text-accessibility",
348 flag_descriptions::kWebPageTextAccessibilityName,
349 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
350 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Mike Dougherty39d36b02018-06-19 19:21:40351 {"web-frame-messaging", flag_descriptions::kWebFrameMessagingName,
352 flag_descriptions::kWebFrameMessagingDescription, flags_ui::kOsIos,
353 FEATURE_VALUE_TYPE(web::features::kWebFrameMessaging)},
Yi Suf63219e2018-06-25 17:41:01354 {"copy-image", flag_descriptions::kCopyImageName,
355 flag_descriptions::kCopyImageDescription, flags_ui::kOsIos,
356 FEATURE_VALUE_TYPE(kCopyImage)},
Vadym Doroshenkoa9a914942018-07-19 08:23:30357 {"new-password-form-parsing",
358 flag_descriptions::kNewPasswordFormParsingName,
359 flag_descriptions::kNewPasswordFormParsingDescription, flags_ui::kOsIos,
360 FEATURE_VALUE_TYPE(password_manager::features::kNewPasswordFormParsing)},
mrefaat4539b032018-08-02 22:25:45361 {"app-launcher-refresh", flag_descriptions::kAppLauncherRefreshName,
362 flag_descriptions::kAppLauncherRefreshDescription, flags_ui::kOsIos,
363 FEATURE_VALUE_TYPE(kAppLauncherRefresh)},
Marc Treib6f0bbd22018-08-28 10:07:19364 {"sync-standalone-transport",
365 flag_descriptions::kSyncStandaloneTransportName,
366 flag_descriptions::kSyncStandaloneTransportDescription, flags_ui::kOsIos,
367 FEATURE_VALUE_TYPE(switches::kSyncStandaloneTransport)},
Marc Treib4bd95e72018-08-30 06:30:58368 {"sync-support-secondary-account",
369 flag_descriptions::kSyncSupportSecondaryAccountName,
370 flag_descriptions::kSyncSupportSecondaryAccountDescription,
371 flags_ui::kOsIos,
372 FEATURE_VALUE_TYPE(switches::kSyncSupportSecondaryAccount)},
Gauthier Ambard66de93d2018-08-30 15:58:19373 {"out-of-web-fullscreen", flag_descriptions::kOutOfWebFullscreenName,
374 flag_descriptions::kOutOfWebFullscreenDescription, flags_ui::kOsIos,
375 FEATURE_VALUE_TYPE(web::features::kOutOfWebFullscreen)},
Javier Ernesto Flores Robles8e66f732018-09-12 15:41:15376 {"autofill-manual-fallback-phase-two",
377 flag_descriptions::kAutofillManualFallbackPhaseTwoName,
378 flag_descriptions::kAutofillManualFallbackPhaseTwoDescription,
379 flags_ui::kOsIos,
380 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallbackPhaseTwo)},
Kurt Horimoto79d590b2018-09-12 19:09:28381 {"toolbar-container", flag_descriptions::kToolbarContainerName,
382 flag_descriptions::kToolbarContainerDescription, flags_ui::kOsIos,
383 FEATURE_VALUE_TYPE(toolbar_container::kToolbarContainerEnabled)},
Eugene Butc61230ab2018-11-09 00:31:58384 {"present-sad-tab-in-view-controller",
385 flag_descriptions::kPresentSadTabInViewControllerName,
386 flag_descriptions::kPresentSadTabInViewControllerDescription,
387 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kPresentSadTabInViewController)},
[email protected]5b899dc2018-10-02 09:20:01388 {"omnibox-popup-shortcuts",
389 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateName,
390 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateDescription,
391 flags_ui::kOsIos,
392 FEATURE_VALUE_TYPE(omnibox::kOmniboxPopupShortcutIconsInZeroState)},
Jérôme Lebelec282832018-09-18 08:34:18393 {"sso-with-wkwebview", flag_descriptions::kSSOWithWKWebViewName,
394 flag_descriptions::kSSOWithWKWebViewDescription, flags_ui::kOsIos,
395 FEATURE_VALUE_TYPE(kSSOWithWKWebView)},
Yi Sua3d55f3d2018-09-24 17:49:41396 {"custom-search-engines", flag_descriptions::kCustomSearchEnginesName,
397 flag_descriptions::kCustomSearchEnginesDescription, flags_ui::kOsIos,
398 FEATURE_VALUE_TYPE(kCustomSearchEngines)},
Valeriya Sinevicha79dc612018-09-25 14:49:09399 {"use-multilogin-endpoint", flag_descriptions::kUseMultiloginEndpointName,
400 flag_descriptions::kUseMultiloginEndpointDescription, flags_ui::kOsIos,
401 FEATURE_VALUE_TYPE(kUseMultiloginEndpoint)},
edchin18a3e602018-10-08 23:39:35402 {"closing-last-incognito-tab",
403 flag_descriptions::kClosingLastIncognitoTabName,
404 flag_descriptions::kClosingLastIncognitoTabDescription, flags_ui::kOsIos,
405 FEATURE_VALUE_TYPE(kClosingLastIncognitoTab)},
Gauthier Ambardce7fd582018-10-09 08:37:05406 {"omnibox-tab-switch-suggestions",
407 flag_descriptions::kOmniboxTabSwitchSuggestionsName,
408 flag_descriptions::kOmniboxTabSwitchSuggestionsDescription,
409 flags_ui::kOsIos,
410 FEATURE_VALUE_TYPE(omnibox::kOmniboxTabSwitchSuggestions)},
Tanja Gornakb0985dd2018-10-11 17:24:40411 {"fcm-invalidations", flag_descriptions::kFCMInvalidationsName,
412 flag_descriptions::kFCMInvalidationsDescription, flags_ui::kOsIos,
413 FEATURE_VALUE_TYPE(invalidation::switches::kFCMInvalidations)},
Justin Cohen9a5023212018-10-15 14:32:37414 {"browser-container-contains-ntp",
415 flag_descriptions::kBrowserContainerContainsNTPName,
416 flag_descriptions::kBrowserContainerContainsNTPDescription,
417 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerContainsNTP)},
Gauthier Ambard2392f2a2018-10-24 16:33:27418 {"search-icon-toggle", flag_descriptions::kSearchIconToggleName,
419 flag_descriptions::kSearchIconToggleDescription, flags_ui::kOsIos,
420 FEATURE_WITH_PARAMS_VALUE_TYPE(kIconForSearchButtonFeature,
421 kIconForSearchButtonVariations,
422 "ToggleSearchButtonIcon")},
Olivier Robin2a898dc2018-10-31 14:37:04423 {"enable-breakpad-upload-no-delay",
424 flag_descriptions::kBreakpadNoDelayInitialUploadName,
425 flag_descriptions::kBreakpadNoDelayInitialUploadDescription,
426 flags_ui::kOsIos,
427 FEATURE_VALUE_TYPE(crash_report::kBreakpadNoDelayInitialUpload)},
Moe Ahmadie4cce1f2018-12-18 23:48:01428 {"enable-compact-translate-infobar",
429 flag_descriptions::kCompactTranslateInfobarName,
430 flag_descriptions::kCompactTranslateInfobarDescription, flags_ui::kOsIos,
431 FEATURE_VALUE_TYPE(translate::kCompactTranslateInfobarIOS)},
Kurt Horimoto9165404a2018-11-13 23:48:12432 {"non-modal-dialogs", flag_descriptions::kNonModalDialogsName,
433 flag_descriptions::kNonModalDialogsDescription, flags_ui::kOsIos,
434 FEATURE_VALUE_TYPE(dialogs::kNonModalDialogs)},
Mikel Astizdb43c5652018-11-22 16:52:05435 {"sync-pseudo-uss-favicons", flag_descriptions::kSyncPseudoUSSFaviconsName,
436 flag_descriptions::kSyncPseudoUSSFaviconsDescription, flags_ui::kOsIos,
437 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSFavicons)},
438 {"sync-pseudo-uss-history-delete-directives",
439 flag_descriptions::kSyncPseudoUSSHistoryDeleteDirectivesName,
440 flag_descriptions::kSyncPseudoUSSHistoryDeleteDirectivesDescription,
441 flags_ui::kOsIos,
442 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSHistoryDeleteDirectives)},
443 {"sync-pseudo-uss-passwords",
444 flag_descriptions::kSyncPseudoUSSPasswordsName,
445 flag_descriptions::kSyncPseudoUSSPasswordsDescription, flags_ui::kOsIos,
446 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSPasswords)},
447 {"sync-pseudo-uss-preferences",
448 flag_descriptions::kSyncPseudoUSSPreferencesName,
449 flag_descriptions::kSyncPseudoUSSPreferencesDescription, flags_ui::kOsIos,
450 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSPreferences)},
451 {"sync-pseudo-uss-priority-preferences",
452 flag_descriptions::kSyncPseudoUSSPriorityPreferencesName,
453 flag_descriptions::kSyncPseudoUSSPriorityPreferencesDescription,
454 flags_ui::kOsIos,
455 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSPriorityPreferences)},
Jérôme Lebel5717fa852018-12-19 12:11:13456 {"use-nsurlsession-for-signin",
457 flag_descriptions::kUseNSURLSessionForGaiaSigninRequestsName,
458 flag_descriptions::kUseNSURLSessionForGaiaSigninRequestsDescription,
459 flags_ui::kOsIos,
460 FEATURE_VALUE_TYPE(kUseNSURLSessionForGaiaSigninRequests)},
Mikel Astizdb43c5652018-11-22 16:52:05461 {"sync-pseudo-uss-supervised-users",
462 flag_descriptions::kSyncPseudoUSSSupervisedUsersName,
463 flag_descriptions::kSyncPseudoUSSSupervisedUsersDescription,
464 flags_ui::kOsIos,
465 FEATURE_VALUE_TYPE(switches::kSyncPseudoUSSSupervisedUsers)},
Olivier Robince9386ebd2018-11-29 09:07:38466 {"detect-main-thread-freeze",
467 flag_descriptions::kDetectMainThreadFreezeName,
468 flag_descriptions::kDetectMainThreadFreezeDescription, flags_ui::kOsIos,
469 FEATURE_WITH_PARAMS_VALUE_TYPE(crash_report::kDetectMainThreadFreeze,
470 kDetectMainThreadFreezeVariations,
471 "DetectMainThreadFreeze")},
Mohamed Amir Yosef9e8a1f02018-12-03 21:41:14472 {"enable-sync-uss-bookmarks",
473 flag_descriptions::kEnableSyncUSSBookmarksName,
474 flag_descriptions::kEnableSyncUSSBookmarksDescription, flags_ui::kOsIos,
475 FEATURE_VALUE_TYPE(switches::kSyncUSSBookmarks)},
sczs80a6f462018-12-05 20:37:18476 {"infobar-ui-reboot", flag_descriptions::kInfobarUIRebootName,
477 flag_descriptions::kInfobarUIRebootDescription, flags_ui::kOsIos,
478 FEATURE_VALUE_TYPE(kInfobarUIReboot)},
Chris Lu77905ac2018-12-06 20:46:51479 {"find-in-page-iframe", flag_descriptions::kFindInPageiFrameName,
480 flag_descriptions::kFindInPageiFrameDescription, flags_ui::kOsIos,
481 FEATURE_VALUE_TYPE(kFindInPageiFrame)},
Robbie Gibsoncd964bb2018-12-11 18:22:21482 {"search-copied-image", flag_descriptions::kSearchCopiedImageName,
483 flag_descriptions::kSearchCopiedImageDescription, flags_ui::kOsIos,
484 FEATURE_VALUE_TYPE(kSearchCopiedImage)},
Robbie Gibson640d842b2018-12-18 11:55:13485 {"copied-text-behavior", flag_descriptions::kCopiedTextBehaviorName,
486 flag_descriptions::kCopiedTextBehaviorName, flags_ui::kOsIos,
Robbie Gibsone6915ce12018-12-26 12:08:10487 FEATURE_VALUE_TYPE(omnibox::kCopiedTextBehavior)},
Vadym Doroshenkod178ff3f2019-01-02 14:59:23488 {"new-password-form-parsing-for-saving",
489 flag_descriptions::kNewPasswordFormParsingForSavingName,
490 flag_descriptions::kNewPasswordFormParsingForSavingDescription,
491 flags_ui::kOsIos,
492 FEATURE_VALUE_TYPE(
493 password_manager::features::kNewPasswordFormParsingForSaving)},
494 {"only-new-password-form-parsing",
495 flag_descriptions::kOnlyNewPasswordFormParsingName,
496 flag_descriptions::kOnlyNewPasswordFormParsingDescription,
497 flags_ui::kOsIos,
498 FEATURE_VALUE_TYPE(password_manager::features::kOnlyNewParser)},
edchin5ae0b4c2019-01-06 06:52:28499 {"snapshot-draw-view", flag_descriptions::kSnapshotDrawViewName,
500 flag_descriptions::kSnapshotDrawViewDescription, flags_ui::kOsIos,
501 FEATURE_VALUE_TYPE(kSnapshotDrawView)},
Gauthier Ambardcfd85182018-01-05 10:37:46502};
sdefresne14900ee2015-11-27 14:43:21503
504// Add all switches from experimental flags to |command_line|.
505void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
506 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
507
sdefresne14900ee2015-11-27 14:43:21508 // Set the UA flag if UseMobileSafariUA is enabled.
509 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
510 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
511 // Chrome puts its product token.
avi571943672015-12-22 02:12:49512 int32_t major = 0;
513 int32_t minor = 0;
514 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21515 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
516 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
517
518 command_line->AppendSwitchASCII(switches::kUserAgent,
519 web::BuildUserAgentFromProduct(product));
520 }
521
522 // Freeform commandline flags. These are added last, so that any flags added
523 // earlier in this function take precedence.
524 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
525 base::CommandLine::StringVector flags;
526 // Append an empty "program" argument.
527 flags.push_back("");
528
529 // The number of flags corresponds to the number of text fields in
530 // Experimental.plist.
531 const int kNumFreeformFlags = 5;
532 for (int i = 1; i <= kNumFreeformFlags; ++i) {
533 NSString* key =
534 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
535 NSString* flag = [defaults stringForKey:key];
536 if ([flag length]) {
537 flags.push_back(base::SysNSStringToUTF8(flag));
538 }
539 }
540
541 base::CommandLine temp_command_line(flags);
542 command_line->AppendArguments(temp_command_line, false);
543 }
msardafc76f662017-02-24 12:46:28544
justincohendacc85d2017-06-28 23:34:10545 // Populate command line flag for 3rd party keyboard omnibox workaround.
546 NSString* enableThirdPartyKeyboardWorkaround =
547 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
548 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
549 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
550 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
551 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
552 }
553
msardafc76f662017-02-24 12:46:28554 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
555 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21556}
557
558bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
559 return false;
560}
561
562class FlagsStateSingleton {
563 public:
564 FlagsStateSingleton()
kokihoon189a4022018-10-13 02:43:44565 : flags_state_(kFeatureEntries, base::size(kFeatureEntries)) {}
sdefresne14900ee2015-11-27 14:43:21566 ~FlagsStateSingleton() {}
567
568 static FlagsStateSingleton* GetInstance() {
569 return base::Singleton<FlagsStateSingleton>::get();
570 }
571
572 static flags_ui::FlagsState* GetFlagsState() {
573 return &GetInstance()->flags_state_;
574 }
575
576 private:
577 flags_ui::FlagsState flags_state_;
578
579 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
580};
581} // namespace
582
583void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
584 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02585 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21586 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11587 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53588 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21589}
590
jkrcalbf073372016-07-29 07:21:31591std::vector<std::string> RegisterAllFeatureVariationParameters(
592 flags_ui::FlagsStorage* flags_storage,
593 base::FeatureList* feature_list) {
594 return FlagsStateSingleton::GetFlagsState()
595 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
596}
597
sdefresne14900ee2015-11-27 14:43:21598void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
599 flags_ui::FlagAccess access,
600 base::ListValue* supported_entries,
601 base::ListValue* unsupported_entries) {
602 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
603 flags_storage, access, supported_entries, unsupported_entries,
604 base::Bind(&SkipConditionalFeatureEntry));
605}
606
607void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
608 const std::string& internal_name,
609 bool enable) {
610 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
611 flags_storage, internal_name, enable);
612}
613
614void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
615 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
616}
617
618namespace testing {
619
620const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
kokihoon189a4022018-10-13 02:43:44621 *count = base::size(kFeatureEntries);
sdefresne14900ee2015-11-27 14:43:21622 return kFeatureEntries;
623}
624
625} // namespace testing