blob: c1d0d00b9ee6a283dc48c29bf101887b16be5bbc [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"
22#include "base/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"
Mihai Sardarescu160ec662018-07-18 21:13:5144#include "components/unified_consent/feature.h"
mrefaat4539b032018-08-02 22:25:4545#include "ios/chrome/browser/app_launcher/app_launcher_flags.h"
Sylvain Defresneae6987e2018-03-01 13:21:4046#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2147#include "ios/chrome/browser/chrome_switches.h"
Olivier Robin2a898dc2018-10-31 14:37:0448#include "ios/chrome/browser/crash_report/crash_report_flags.h"
Jean-François Geyelin30be5912017-08-25 12:05:3849#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
vabr0215a8e2017-03-28 12:47:3450#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
mrefaat390f99c0d2018-05-10 19:44:2451#include "ios/chrome/browser/itunes_urls/itunes_urls_flag.h"
Daniel Blakemore72387d32018-02-13 23:45:5552#include "ios/chrome/browser/mailto/features.h"
Yi Sua3d55f3d2018-09-24 17:49:4153#include "ios/chrome/browser/search_engines/feature_flags.h"
Jérôme Lebelec282832018-09-18 08:34:1854#include "ios/chrome/browser/signin/feature_flags.h"
Mike Doughertya5e5ad52017-08-05 00:11:5855#include "ios/chrome/browser/ssl/captive_portal_features.h"
Louis Romerod11747a2017-10-20 20:10:3556#include "ios/chrome/browser/ui/external_search/features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3557#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
Eugene Butc61230ab2018-11-09 00:31:5858#include "ios/chrome/browser/ui/sad_tab/features.h"
Mark Cogan02ed6c772018-05-31 17:00:5159#import "ios/chrome/browser/ui/toolbar/public/features.h"
Kurt Horimoto79d590b2018-09-12 19:09:2860#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h"
Justin Cohen2d81c582018-01-22 14:46:4461#include "ios/chrome/browser/ui/ui_feature_flags.h"
Yi Su392b3032018-06-05 07:26:4762#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2163#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2864#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Danyao Wang34da6ff2017-10-30 15:16:5665#include "ios/web/public/features.h"
sdefresne14900ee2015-11-27 14:43:2166#include "ios/web/public/user_agent.h"
67#include "ios/web/public/web_view_creation_util.h"
68
69#if !defined(OFFICIAL_BUILD)
70#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2271#endif
stkhapuginc1be1792016-12-13 14:30:5372
73#if !defined(__has_feature) || !__has_feature(objc_arc)
74#error "This file requires ARC support."
75#endif
sdefresne14900ee2015-11-27 14:43:2176
elawrence816f6790e2017-06-16 18:19:2877using flags_ui::FeatureEntry;
78
sdefresne14900ee2015-11-27 14:43:2179namespace {
Emily Starkbafa9062017-12-27 15:22:4680
81const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
82 {security_state::features::kMarkHttpAsFeatureParameterName,
83 security_state::features::kMarkHttpAsParameterDangerous}};
84const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = {
85 {security_state::features::kMarkHttpAsFeatureParameterName,
86 security_state::features::kMarkHttpAsParameterWarning}};
87const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
88 {security_state::features::kMarkHttpAsFeatureParameterName,
89 security_state::features::
90 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
91const FeatureEntry::FeatureParam
92 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = {
93 {security_state::features::kMarkHttpAsFeatureParameterName,
94 security_state::features::
95 kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}};
96
97const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
98 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
kokihoon189a4022018-10-13 02:43:4499 base::size(kMarkHttpAsDangerous), nullptr},
Emily Starkbafa9062017-12-27 15:22:46100 {"(mark with a Not Secure warning)", kMarkHttpAsWarning,
kokihoon189a4022018-10-13 02:43:44101 base::size(kMarkHttpAsWarning), nullptr},
Emily Starkbafa9062017-12-27 15:22:46102 {"(mark with a Not Secure warning and dangerous on form edits)",
103 kMarkHttpAsWarningAndDangerousOnFormEdits,
kokihoon189a4022018-10-13 02:43:44104 base::size(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr},
Emily Starkbafa9062017-12-27 15:22:46105 {"(mark with a Not Secure warning and dangerous on passwords and credit "
106 "card fields)",
107 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards,
kokihoon189a4022018-10-13 02:43:44108 base::size(kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards),
Emily Starkbafa9062017-12-27 15:22:46109 nullptr}};
elawrence816f6790e2017-06-16 18:19:28110
Marc Treib5fc99e1f2017-11-08 12:19:18111const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
112 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
113 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
114 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
115 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
116 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
117 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
118 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
119 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
120 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
121 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
122 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
123};
Marc Treib2752e8b2017-08-04 14:12:09124
Olivier Robin3d60411622018-02-23 10:03:22125const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
126 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
127 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
128 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
129 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
130 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
131 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
132 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
133 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
134 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
135};
136
Gauthier Ambard2392f2a2018-10-24 16:33:27137const FeatureEntry::FeatureParam kIconForSearchButtonGrey[] = {
138 {kIconForSearchButtonFeatureParameterName,
139 kIconForSearchButtonParameterGrey}};
140const FeatureEntry::FeatureParam kIconForSearchButtonColorful[] = {
141 {kIconForSearchButtonFeatureParameterName,
142 kIconForSearchButtonParameterColorful}};
143const FeatureEntry::FeatureParam kIconForSearchButtonMagnifying[] = {
144 {kIconForSearchButtonFeatureParameterName,
145 kIconForSearchButtonParameterMagnifying}};
146
147const FeatureEntry::FeatureVariation kIconForSearchButtonVariations[] = {
148 {"Grey search engine logo", kIconForSearchButtonGrey,
149 base::size(kIconForSearchButtonGrey), nullptr},
150 {"Colorful search engine logo", kIconForSearchButtonColorful,
151 base::size(kIconForSearchButtonColorful), nullptr},
152 {"Magnifying glass", kIconForSearchButtonMagnifying,
153 base::size(kIconForSearchButtonMagnifying), nullptr}};
154
Cooper Knaak1e026562017-07-26 05:22:28155// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21156// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28157// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
158// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21159// macro for this type supplying the command line to the macro.
160// . MULTI_VALUE: a list of choices, the first of which should correspond to a
161// deactivated state for this lab (i.e. no command line option). To specify
162// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
163// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28164// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
165// either enabled, disabled, or uses the default value of the associated
166// base::Feature instance. To specify this type of entry use the macro
167// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
168// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
169// base::Feature instance. Choices corresponding to the default state, a
170// universally enabled state, and a universally disabled state are
171// automatically included. To specify this type of entry use the macro
172// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
173// the array of choices.
174//
sdefresne14900ee2015-11-27 14:43:21175// See the documentation of FeatureEntry for details on the fields.
176//
177// When adding a new choice, add it to the end of the list.
178const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46179 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28180 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46181 FEATURE_WITH_PARAMS_VALUE_TYPE(
182 security_state::features::kMarkHttpAsFeature,
183 kMarkHttpAsFeatureVariations,
184 "MarkHttpAs")},
Mike Doughertyc20eefa2018-02-20 19:20:33185 {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName,
186 flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos,
187 FEATURE_VALUE_TYPE(kCaptivePortalMetrics)},
Cooper Knaak1e026562017-07-26 05:22:28188 {"in-product-help-demo-mode-choice",
189 flag_descriptions::kInProductHelpDemoModeName,
190 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
191 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23192 feature_engagement::kIPHDemoMode,
193 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09194 "IPH_DemoMode")},
195 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
196 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18197 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Justin Donnelly33d712e2017-08-23 21:32:51198 {"omnibox-ui-elide-suggestion-url-after-host",
199 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostName,
200 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostDescription,
201 flags_ui::kOsIos,
202 FEATURE_VALUE_TYPE(omnibox::kUIExperimentElideSuggestionUrlAfterHost)},
Jean-François Geyelin30be5912017-08-25 12:05:38203 {"drag_and_drop", flag_descriptions::kDragAndDropName,
204 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41205 FEATURE_VALUE_TYPE(kDragAndDrop)},
Louis Romerod11747a2017-10-20 20:10:35206 {"external-search", flag_descriptions::kExternalSearchName,
207 flag_descriptions::kExternalSearchDescription, flags_ui::kOsIos,
208 FEATURE_VALUE_TYPE(kExternalSearch)},
Eugene But468b6d5f02018-10-18 21:17:45209 {"ignores-viewport-scale-limits",
210 flag_descriptions::kIgnoresViewportScaleLimitsName,
211 flag_descriptions::kIgnoresViewportScaleLimitsDescription,
212 flags_ui::kOsIos,
213 FEATURE_VALUE_TYPE(web::features::kIgnoresViewportScaleLimits)},
Danyao Wang34da6ff2017-10-30 15:16:56214 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
215 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
216 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
sczsdc2e8e02018-01-09 18:39:32217 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
218 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
219 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
mrefaata6501d92017-12-11 19:50:50220 {"wk-http-system-cookie-store",
221 flag_descriptions::kWKHTTPSystemCookieStoreName,
222 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59223 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22224 {"enable-autofill-credit-card-upload",
225 flag_descriptions::kAutofillCreditCardUploadName,
226 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24227 FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
Lakshmi Kumar Dabbiruee22004e2018-06-01 01:52:27228 {"enable-autofill-credit-card-downstream-google-pay-branding",
229 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSName,
230 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSDescription,
231 flags_ui::kOsIos,
232 FEATURE_VALUE_TYPE(
233 autofill::features::kAutofillDownstreamUseGooglePayBrandingOniOS)},
Moe Ahmadi3fd9f202018-05-10 17:39:24234 {"enable-autofill-credit-card-upload-google-pay-branding",
235 flag_descriptions::kAutofillUpstreamUseGooglePayBrandingOnMobileName,
236 flag_descriptions::
237 kAutofillUpstreamUseGooglePayBrandingOnMobileDescription,
238 flags_ui::kOsIos,
239 FEATURE_VALUE_TYPE(
240 autofill::features::kAutofillUpstreamUseGooglePayBrandingOnMobile)},
Jared Saul2e55e7f12018-10-26 20:44:43241 {"enable-autofill-save-credit-card-uses-strike-system",
242 flag_descriptions::kEnableAutofillSaveCreditCardUsesStrikeSystemName,
243 flag_descriptions::
244 kEnableAutofillSaveCreditCardUsesStrikeSystemDescription,
245 flags_ui::kOsIos,
246 FEATURE_VALUE_TYPE(
247 autofill::features::kAutofillSaveCreditCardUsesStrikeSystem)},
Moe Ahmadid6d5d172018-06-20 17:20:23248 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
249 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
250 SINGLE_VALUE_TYPE_AND_VALUE(
251 switches::kSyncServiceURL,
252 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
253 {"wallet-service-use-sandbox",
254 flag_descriptions::kWalletServiceUseSandboxName,
255 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
256 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
257 autofill::switches::kWalletServiceUseSandbox,
258 "1",
259 autofill::switches::kWalletServiceUseSandbox,
260 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59261 {"show-autofill-type-predictions",
262 flag_descriptions::kShowAutofillTypePredictionsName,
263 flag_descriptions::kShowAutofillTypePredictionsDescription,
264 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46265 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22266 {"autofill-ios-delay-between-fields",
267 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
268 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
269 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Daniel Blakemore72387d32018-02-13 23:45:55270 {"mailto-handling-google-ui",
271 flag_descriptions::kMailtoHandlingWithGoogleUIName,
272 flag_descriptions::kMailtoHandlingWithGoogleUIDescription,
273 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)},
Sylvain Defresneae6987e2018-03-01 13:21:40274 {"new-clear-browsing-data-ui",
275 flag_descriptions::kNewClearBrowsingDataUIName,
276 flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos,
277 FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)},
mrefaat390f99c0d2018-05-10 19:44:24278 {"itunes-urls-store-kit-handling",
279 flag_descriptions::kITunesUrlsStoreKitHandlingName,
280 flag_descriptions::kITunesUrlsStoreKitHandlingDescription,
281 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kITunesUrlsStoreKitHandling)},
Jérôme Lebelfa6c5ae2018-03-29 13:46:57282 {"unified-consent", flag_descriptions::kUnifiedConsentName,
283 flag_descriptions::kUnifiedConsentDescription, flags_ui::kOsIos,
Mihai Sardarescu160ec662018-07-18 21:13:51284 FEATURE_VALUE_TYPE(unified_consent::kUnifiedConsent)},
Jérôme Lebelfe1b2e02018-08-03 12:26:20285 {"force-unified-consent-bump",
286 flag_descriptions::kForceUnifiedConsentBumpName,
287 flag_descriptions::kForceUnifiedConsentBumpDescription, flags_ui::kOsIos,
288 FEATURE_VALUE_TYPE(unified_consent::kForceUnifiedConsentBump)},
sebsg93dc01c2018-04-05 16:42:48289 {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName,
290 flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos,
291 FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)},
Olivier Robin081912dd2018-06-11 09:14:26292 {"autofill-prefilled-fields",
293 flag_descriptions::kAutofillPrefilledFieldsName,
294 flag_descriptions::kAutofillPrefilledFieldsDescription, flags_ui::kOsIos,
295 FEATURE_VALUE_TYPE(autofill::features::kAutofillPrefilledFields)},
Olivier Robind81475b02018-06-20 21:30:11296 {"autofill-show-all-profiles-on-prefilled-forms",
297 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsName,
298 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsDescription,
299 flags_ui::kOsIos,
300 FEATURE_VALUE_TYPE(
301 autofill::features::kAutofillShowAllSuggestionsOnPrefilledForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08302 {"autofill-restrict-formless-form-extraction",
303 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
304 flag_descriptions::
305 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
306 flags_ui::kOsIos,
307 FEATURE_VALUE_TYPE(
308 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
Kurt Horimotodc33af32018-05-01 01:39:14309 {"fullscreen-viewport-adjustment-experiment",
310 flag_descriptions::kFullscreenViewportAdjustmentExperimentName,
311 flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription,
312 flags_ui::kOsIos,
313 MULTI_VALUE_TYPE(
314 fullscreen::features::kViewportAdjustmentExperimentChoices)},
Roger McFarlane1a37d7b2018-04-20 22:45:19315 {"autofill-enforce-min-required-fields-for-heuristics",
316 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
317 flag_descriptions::
318 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
319 flags_ui::kOsIos,
320 FEATURE_VALUE_TYPE(
321 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
322 {"autofill-enforce-min-required-fields-for-query",
323 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
324 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
325 flags_ui::kOsIos,
326 FEATURE_VALUE_TYPE(
327 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
328 {"autofill-enforce-min-required-fields-for-upload",
329 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
330 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
331 flags_ui::kOsIos,
332 FEATURE_VALUE_TYPE(
333 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Gauthier Ambard4417f852018-04-26 14:24:32334 {"browser-container-fullscreen",
335 flag_descriptions::kBrowserContainerFullscreenName,
336 flag_descriptions::kBrowserContainerFullscreenDescription,
Gauthier Ambard5d7627282018-05-18 08:20:07337 flags_ui::kOsIos,
338 FEATURE_VALUE_TYPE(web::features::kBrowserContainerFullscreen)},
Roger McFarlane2eceba982018-05-18 01:37:11339 {"autofill-cache-query-responses",
340 flag_descriptions::kAutofillCacheQueryResponsesName,
341 flag_descriptions::kAutofillCacheQueryResponsesDescription,
342 flags_ui::kOsIos,
343 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Jeffrey Cohen05cdafa392018-08-15 20:49:17344 {"autofill-enable-company-name",
345 flag_descriptions::kAutofillEnableCompanyNameName,
346 flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos,
347 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)},
Javier Ernesto Flores Robles23c71a7d2018-06-01 09:51:17348 {"autofill-manual-fallback", flag_descriptions::kAutofillManualFallbackName,
349 flag_descriptions::kAutofillManualFallbackDescription, flags_ui::kOsIos,
350 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallback)},
Yi Su392b3032018-06-05 07:26:47351 {"webpage-text-accessibility",
352 flag_descriptions::kWebPageTextAccessibilityName,
353 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
354 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Mike Dougherty39d36b02018-06-19 19:21:40355 {"web-frame-messaging", flag_descriptions::kWebFrameMessagingName,
356 flag_descriptions::kWebFrameMessagingDescription, flags_ui::kOsIos,
357 FEATURE_VALUE_TYPE(web::features::kWebFrameMessaging)},
Yi Suf63219e2018-06-25 17:41:01358 {"copy-image", flag_descriptions::kCopyImageName,
359 flag_descriptions::kCopyImageDescription, flags_ui::kOsIos,
360 FEATURE_VALUE_TYPE(kCopyImage)},
Vadym Doroshenkoa9a914942018-07-19 08:23:30361 {"new-password-form-parsing",
362 flag_descriptions::kNewPasswordFormParsingName,
363 flag_descriptions::kNewPasswordFormParsingDescription, flags_ui::kOsIos,
364 FEATURE_VALUE_TYPE(password_manager::features::kNewPasswordFormParsing)},
mrefaat4539b032018-08-02 22:25:45365 {"app-launcher-refresh", flag_descriptions::kAppLauncherRefreshName,
366 flag_descriptions::kAppLauncherRefreshDescription, flags_ui::kOsIos,
367 FEATURE_VALUE_TYPE(kAppLauncherRefresh)},
Marc Treib6f0bbd22018-08-28 10:07:19368 {"sync-standalone-transport",
369 flag_descriptions::kSyncStandaloneTransportName,
370 flag_descriptions::kSyncStandaloneTransportDescription, flags_ui::kOsIos,
371 FEATURE_VALUE_TYPE(switches::kSyncStandaloneTransport)},
Marc Treib4bd95e72018-08-30 06:30:58372 {"sync-support-secondary-account",
373 flag_descriptions::kSyncSupportSecondaryAccountName,
374 flag_descriptions::kSyncSupportSecondaryAccountDescription,
375 flags_ui::kOsIos,
376 FEATURE_VALUE_TYPE(switches::kSyncSupportSecondaryAccount)},
Gauthier Ambard66de93d2018-08-30 15:58:19377 {"out-of-web-fullscreen", flag_descriptions::kOutOfWebFullscreenName,
378 flag_descriptions::kOutOfWebFullscreenDescription, flags_ui::kOsIos,
379 FEATURE_VALUE_TYPE(web::features::kOutOfWebFullscreen)},
Javier Ernesto Flores Robles8e66f732018-09-12 15:41:15380 {"autofill-manual-fallback-phase-two",
381 flag_descriptions::kAutofillManualFallbackPhaseTwoName,
382 flag_descriptions::kAutofillManualFallbackPhaseTwoDescription,
383 flags_ui::kOsIos,
384 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallbackPhaseTwo)},
Kurt Horimoto79d590b2018-09-12 19:09:28385 {"toolbar-container", flag_descriptions::kToolbarContainerName,
386 flag_descriptions::kToolbarContainerDescription, flags_ui::kOsIos,
387 FEATURE_VALUE_TYPE(toolbar_container::kToolbarContainerEnabled)},
Eugene Butc61230ab2018-11-09 00:31:58388 {"present-sad-tab-in-view-controller",
389 flag_descriptions::kPresentSadTabInViewControllerName,
390 flag_descriptions::kPresentSadTabInViewControllerDescription,
391 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kPresentSadTabInViewController)},
[email protected]5b899dc2018-10-02 09:20:01392 {"omnibox-popup-shortcuts",
393 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateName,
394 flag_descriptions::kOmniboxPopupShortcutIconsInZeroStateDescription,
395 flags_ui::kOsIos,
396 FEATURE_VALUE_TYPE(omnibox::kOmniboxPopupShortcutIconsInZeroState)},
Jérôme Lebelec282832018-09-18 08:34:18397 {"sso-with-wkwebview", flag_descriptions::kSSOWithWKWebViewName,
398 flag_descriptions::kSSOWithWKWebViewDescription, flags_ui::kOsIos,
399 FEATURE_VALUE_TYPE(kSSOWithWKWebView)},
edchin98e594cc2018-09-18 18:02:40400 {"wk-web-view-snapshots", flag_descriptions::kWKWebViewSnapshotsName,
401 flag_descriptions::kWKWebViewSnapshotsDescription, flags_ui::kOsIos,
402 FEATURE_VALUE_TYPE(kWKWebViewSnapshots)},
Yi Sua3d55f3d2018-09-24 17:49:41403 {"custom-search-engines", flag_descriptions::kCustomSearchEnginesName,
404 flag_descriptions::kCustomSearchEnginesDescription, flags_ui::kOsIos,
405 FEATURE_VALUE_TYPE(kCustomSearchEngines)},
Valeriya Sinevicha79dc612018-09-25 14:49:09406 {"use-multilogin-endpoint", flag_descriptions::kUseMultiloginEndpointName,
407 flag_descriptions::kUseMultiloginEndpointDescription, flags_ui::kOsIos,
408 FEATURE_VALUE_TYPE(kUseMultiloginEndpoint)},
edchin18a3e602018-10-08 23:39:35409 {"closing-last-incognito-tab",
410 flag_descriptions::kClosingLastIncognitoTabName,
411 flag_descriptions::kClosingLastIncognitoTabDescription, flags_ui::kOsIos,
412 FEATURE_VALUE_TYPE(kClosingLastIncognitoTab)},
Gauthier Ambardce7fd582018-10-09 08:37:05413 {"omnibox-tab-switch-suggestions",
414 flag_descriptions::kOmniboxTabSwitchSuggestionsName,
415 flag_descriptions::kOmniboxTabSwitchSuggestionsDescription,
416 flags_ui::kOsIos,
417 FEATURE_VALUE_TYPE(omnibox::kOmniboxTabSwitchSuggestions)},
Tanja Gornakb0985dd2018-10-11 17:24:40418 {"fcm-invalidations", flag_descriptions::kFCMInvalidationsName,
419 flag_descriptions::kFCMInvalidationsDescription, flags_ui::kOsIos,
420 FEATURE_VALUE_TYPE(invalidation::switches::kFCMInvalidations)},
Justin Cohen9a5023212018-10-15 14:32:37421 {"browser-container-contains-ntp",
422 flag_descriptions::kBrowserContainerContainsNTPName,
423 flag_descriptions::kBrowserContainerContainsNTPDescription,
424 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerContainsNTP)},
Gauthier Ambard2392f2a2018-10-24 16:33:27425 {"search-icon-toggle", flag_descriptions::kSearchIconToggleName,
426 flag_descriptions::kSearchIconToggleDescription, flags_ui::kOsIos,
427 FEATURE_WITH_PARAMS_VALUE_TYPE(kIconForSearchButtonFeature,
428 kIconForSearchButtonVariations,
429 "ToggleSearchButtonIcon")},
Olivier Robin2a898dc2018-10-31 14:37:04430 {"enable-breakpad-upload-no-delay",
431 flag_descriptions::kBreakpadNoDelayInitialUploadName,
432 flag_descriptions::kBreakpadNoDelayInitialUploadDescription,
433 flags_ui::kOsIos,
434 FEATURE_VALUE_TYPE(crash_report::kBreakpadNoDelayInitialUpload)},
Gauthier Ambardcfd85182018-01-05 10:37:46435};
sdefresne14900ee2015-11-27 14:43:21436
437// Add all switches from experimental flags to |command_line|.
438void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
439 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
440
sdefresne14900ee2015-11-27 14:43:21441 // Set the UA flag if UseMobileSafariUA is enabled.
442 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
443 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
444 // Chrome puts its product token.
avi571943672015-12-22 02:12:49445 int32_t major = 0;
446 int32_t minor = 0;
447 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21448 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
449 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
450
451 command_line->AppendSwitchASCII(switches::kUserAgent,
452 web::BuildUserAgentFromProduct(product));
453 }
454
455 // Freeform commandline flags. These are added last, so that any flags added
456 // earlier in this function take precedence.
457 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
458 base::CommandLine::StringVector flags;
459 // Append an empty "program" argument.
460 flags.push_back("");
461
462 // The number of flags corresponds to the number of text fields in
463 // Experimental.plist.
464 const int kNumFreeformFlags = 5;
465 for (int i = 1; i <= kNumFreeformFlags; ++i) {
466 NSString* key =
467 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
468 NSString* flag = [defaults stringForKey:key];
469 if ([flag length]) {
470 flags.push_back(base::SysNSStringToUTF8(flag));
471 }
472 }
473
474 base::CommandLine temp_command_line(flags);
475 command_line->AppendArguments(temp_command_line, false);
476 }
msardafc76f662017-02-24 12:46:28477
justincohendacc85d2017-06-28 23:34:10478 // Populate command line flag for 3rd party keyboard omnibox workaround.
479 NSString* enableThirdPartyKeyboardWorkaround =
480 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
481 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
482 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
483 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
484 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
485 }
486
msardafc76f662017-02-24 12:46:28487 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
488 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21489}
490
491bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
492 return false;
493}
494
495class FlagsStateSingleton {
496 public:
497 FlagsStateSingleton()
kokihoon189a4022018-10-13 02:43:44498 : flags_state_(kFeatureEntries, base::size(kFeatureEntries)) {}
sdefresne14900ee2015-11-27 14:43:21499 ~FlagsStateSingleton() {}
500
501 static FlagsStateSingleton* GetInstance() {
502 return base::Singleton<FlagsStateSingleton>::get();
503 }
504
505 static flags_ui::FlagsState* GetFlagsState() {
506 return &GetInstance()->flags_state_;
507 }
508
509 private:
510 flags_ui::FlagsState flags_state_;
511
512 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
513};
514} // namespace
515
516void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
517 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02518 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21519 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11520 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53521 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21522}
523
jkrcalbf073372016-07-29 07:21:31524std::vector<std::string> RegisterAllFeatureVariationParameters(
525 flags_ui::FlagsStorage* flags_storage,
526 base::FeatureList* feature_list) {
527 return FlagsStateSingleton::GetFlagsState()
528 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
529}
530
sdefresne14900ee2015-11-27 14:43:21531void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
532 flags_ui::FlagAccess access,
533 base::ListValue* supported_entries,
534 base::ListValue* unsupported_entries) {
535 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
536 flags_storage, access, supported_entries, unsupported_entries,
537 base::Bind(&SkipConditionalFeatureEntry));
538}
539
540void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
541 const std::string& internal_name,
542 bool enable) {
543 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
544 flags_storage, internal_name, enable);
545}
546
547void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
548 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
549}
550
551namespace testing {
552
553const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
kokihoon189a4022018-10-13 02:43:44554 *count = base::size(kFeatureEntries);
sdefresne14900ee2015-11-27 14:43:21555 return kFeatureEntries;
556}
557
558} // namespace testing