blob: 8ccbe65408fa46783acf928577d34328caeef1a5 [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"
avi571943672015-12-22 02:12:4918#include "base/macros.h"
sdefresne14900ee2015-11-27 14:43:2119#include "base/memory/singleton.h"
20#include "base/strings/stringprintf.h"
21#include "base/strings/sys_string_conversions.h"
22#include "base/sys_info.h"
Moe Ahmadic3fd7cd2018-05-11 21:40:2223#include "components/autofill/core/browser/autofill_experiments.h"
Mohamad Ahmadic4df81f2017-12-20 04:41:5924#include "components/autofill/core/common/autofill_features.h"
Moe Ahmadid6d5d172018-06-20 17:20:2325#include "components/autofill/core/common/autofill_switches.h"
Olivier Robin3d60411622018-02-23 10:03:2226#include "components/autofill/ios/browser/autofill_switches.h"
sdefresne14900ee2015-11-27 14:43:2127#include "components/dom_distiller/core/dom_distiller_switches.h"
Tommy Nyquistc1d6dea12017-07-26 20:37:2328#include "components/feature_engagement/public/feature_constants.h"
29#include "components/feature_engagement/public/feature_list.h"
sdefresne14900ee2015-11-27 14:43:2130#include "components/flags_ui/feature_entry.h"
31#include "components/flags_ui/feature_entry_macros.h"
32#include "components/flags_ui/flags_storage.h"
33#include "components/flags_ui/flags_ui_switches.h"
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"
David Rogera6c88122017-10-25 13:02:4640#include "components/signin/core/browser/signin_switches.h"
sdefresne36579782016-02-05 11:08:2541#include "components/strings/grit/components_strings.h"
Moe Ahmadid6d5d172018-06-20 17:20:2342#include "components/sync/driver/sync_driver_switches.h"
Mihai Sardarescu160ec662018-07-18 21:13:5143#include "components/unified_consent/feature.h"
mrefaat4539b032018-08-02 22:25:4544#include "ios/chrome/browser/app_launcher/app_launcher_flags.h"
Sylvain Defresneae6987e2018-03-01 13:21:4045#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2146#include "ios/chrome/browser/chrome_switches.h"
Jean-François Geyelin30be5912017-08-25 12:05:3847#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
vabr0215a8e2017-03-28 12:47:3448#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
mrefaat390f99c0d2018-05-10 19:44:2449#include "ios/chrome/browser/itunes_urls/itunes_urls_flag.h"
Daniel Blakemore72387d32018-02-13 23:45:5550#include "ios/chrome/browser/mailto/features.h"
Mike Doughertya5e5ad52017-08-05 00:11:5851#include "ios/chrome/browser/ssl/captive_portal_features.h"
Louis Romerod11747a2017-10-20 20:10:3552#include "ios/chrome/browser/ui/external_search/features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3553#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
Mark Cogan02ed6c772018-05-31 17:00:5154#import "ios/chrome/browser/ui/history/features.h"
Rohit Rao6a3a481d2017-09-25 19:31:4155#include "ios/chrome/browser/ui/main/main_feature_flags.h"
Mark Cogan02ed6c772018-05-31 17:00:5156#import "ios/chrome/browser/ui/toolbar/public/features.h"
Justin Cohen2d81c582018-01-22 14:46:4457#include "ios/chrome/browser/ui/ui_feature_flags.h"
Yi Su392b3032018-06-05 07:26:4758#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2159#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2860#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Danyao Wang34da6ff2017-10-30 15:16:5661#include "ios/web/public/features.h"
sdefresne14900ee2015-11-27 14:43:2162#include "ios/web/public/user_agent.h"
63#include "ios/web/public/web_view_creation_util.h"
64
65#if !defined(OFFICIAL_BUILD)
66#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2267#endif
stkhapuginc1be1792016-12-13 14:30:5368
69#if !defined(__has_feature) || !__has_feature(objc_arc)
70#error "This file requires ARC support."
71#endif
sdefresne14900ee2015-11-27 14:43:2172
elawrence816f6790e2017-06-16 18:19:2873using flags_ui::FeatureEntry;
74
sdefresne14900ee2015-11-27 14:43:2175namespace {
Emily Starkbafa9062017-12-27 15:22:4676
77const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
78 {security_state::features::kMarkHttpAsFeatureParameterName,
79 security_state::features::kMarkHttpAsParameterDangerous}};
80const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = {
81 {security_state::features::kMarkHttpAsFeatureParameterName,
82 security_state::features::kMarkHttpAsParameterWarning}};
83const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
84 {security_state::features::kMarkHttpAsFeatureParameterName,
85 security_state::features::
86 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
87const FeatureEntry::FeatureParam
88 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = {
89 {security_state::features::kMarkHttpAsFeatureParameterName,
90 security_state::features::
91 kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}};
92
93const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
94 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
95 arraysize(kMarkHttpAsDangerous), nullptr},
96 {"(mark with a Not Secure warning)", kMarkHttpAsWarning,
97 arraysize(kMarkHttpAsWarning), nullptr},
98 {"(mark with a Not Secure warning and dangerous on form edits)",
99 kMarkHttpAsWarningAndDangerousOnFormEdits,
100 arraysize(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr},
101 {"(mark with a Not Secure warning and dangerous on passwords and credit "
102 "card fields)",
103 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards,
104 arraysize(kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards),
105 nullptr}};
elawrence816f6790e2017-06-16 18:19:28106
Marc Treib5fc99e1f2017-11-08 12:19:18107const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
108 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
109 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
110 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
111 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
112 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
113 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
114 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
115 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
116 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
117 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
118 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
119};
Marc Treib2752e8b2017-08-04 14:12:09120
Olivier Robin3d60411622018-02-23 10:03:22121const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
122 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
123 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
124 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
125 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
126 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
127 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
128 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
129 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
130 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
131};
132
Cooper Knaak1e026562017-07-26 05:22:28133// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21134// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28135// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
136// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21137// macro for this type supplying the command line to the macro.
138// . MULTI_VALUE: a list of choices, the first of which should correspond to a
139// deactivated state for this lab (i.e. no command line option). To specify
140// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
141// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28142// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
143// either enabled, disabled, or uses the default value of the associated
144// base::Feature instance. To specify this type of entry use the macro
145// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
146// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
147// base::Feature instance. Choices corresponding to the default state, a
148// universally enabled state, and a universally disabled state are
149// automatically included. To specify this type of entry use the macro
150// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
151// the array of choices.
152//
sdefresne14900ee2015-11-27 14:43:21153// See the documentation of FeatureEntry for details on the fields.
154//
155// When adding a new choice, add it to the end of the list.
156const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46157 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28158 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46159 FEATURE_WITH_PARAMS_VALUE_TYPE(
160 security_state::features::kMarkHttpAsFeature,
161 kMarkHttpAsFeatureVariations,
162 "MarkHttpAs")},
mathp9b4c11d2017-07-06 20:24:13163 {"web-payments", flag_descriptions::kWebPaymentsName,
164 flag_descriptions::kWebPaymentsDescription, flags_ui::kOsIos,
165 FEATURE_VALUE_TYPE(payments::features::kWebPayments)},
Randall Raymond59766ac2017-08-09 16:28:58166 {"web-payments-native-apps", flag_descriptions::kWebPaymentsNativeAppsName,
167 flag_descriptions::kWebPaymentsNativeAppsDescription, flags_ui::kOsIos,
168 FEATURE_VALUE_TYPE(payments::features::kWebPaymentsNativeApps)},
Mike Doughertya5e5ad52017-08-05 00:11:58169 {"ios-captive-portal", flag_descriptions::kCaptivePortalName,
170 flag_descriptions::kCaptivePortalDescription, flags_ui::kOsIos,
171 FEATURE_VALUE_TYPE(kCaptivePortalFeature)},
Mike Doughertyc20eefa2018-02-20 19:20:33172 {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName,
173 flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos,
174 FEATURE_VALUE_TYPE(kCaptivePortalMetrics)},
Cooper Knaak1e026562017-07-26 05:22:28175 {"in-product-help-demo-mode-choice",
176 flag_descriptions::kInProductHelpDemoModeName,
177 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
178 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23179 feature_engagement::kIPHDemoMode,
180 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09181 "IPH_DemoMode")},
182 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
183 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18184 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Justin Donnelly33d712e2017-08-23 21:32:51185 {"omnibox-ui-elide-suggestion-url-after-host",
186 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostName,
187 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostDescription,
188 flags_ui::kOsIos,
189 FEATURE_VALUE_TYPE(omnibox::kUIExperimentElideSuggestionUrlAfterHost)},
Jean-François Geyelin30be5912017-08-25 12:05:38190#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
191 {"drag_and_drop", flag_descriptions::kDragAndDropName,
192 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41193 FEATURE_VALUE_TYPE(kDragAndDrop)},
Jean-François Geyelin30be5912017-08-25 12:05:38194#endif
Rohit Rao6a3a481d2017-09-25 19:31:41195 {"tab_switcher_presents_bvc",
196 flag_descriptions::kTabSwitcherPresentsBVCName,
197 flag_descriptions::kTabSwitcherPresentsBVCDescription, flags_ui::kOsIos,
Jean-François Geyelined4cde72017-10-11 11:34:50198 FEATURE_VALUE_TYPE(kTabSwitcherPresentsBVC)},
Louis Romerod11747a2017-10-20 20:10:35199 {"external-search", flag_descriptions::kExternalSearchName,
200 flag_descriptions::kExternalSearchDescription, flags_ui::kOsIos,
201 FEATURE_VALUE_TYPE(kExternalSearch)},
sczsa0c91942017-10-26 18:39:59202 {"history-batch-updates-filter",
203 flag_descriptions::kHistoryBatchUpdatesFilterName,
204 flag_descriptions::kHistoryBatchUpdatesFilterDescription, flags_ui::kOsIos,
205 FEATURE_VALUE_TYPE(kHistoryBatchUpdatesFilter)},
Danyao Wang34da6ff2017-10-30 15:16:56206 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
207 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
208 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
Eugene Buta23c8fb2018-05-14 20:40:23209 {"web-error-pages", flag_descriptions::kWebErrorPagesName,
210 flag_descriptions::kWebErrorPagesDescription, flags_ui::kOsIos,
211 FEATURE_VALUE_TYPE(web::features::kWebErrorPages)},
sczsdc2e8e02018-01-09 18:39:32212 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
213 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
214 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
nikhild70e7cb52017-12-26 07:38:20215 {"PasswordExport", flag_descriptions::kPasswordExportName,
Ioana Pandeled14ce9e2017-11-28 14:41:46216 flag_descriptions::kPasswordExportDescription, flags_ui::kOsIos,
mrefaata6501d92017-12-11 19:50:50217 FEATURE_VALUE_TYPE(password_manager::features::kPasswordExport)},
218 {"wk-http-system-cookie-store",
219 flag_descriptions::kWKHTTPSystemCookieStoreName,
220 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59221 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22222 {"enable-autofill-credit-card-upload",
223 flag_descriptions::kAutofillCreditCardUploadName,
224 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
225 FEATURE_VALUE_TYPE(autofill::kAutofillUpstream)},
Lakshmi Kumar Dabbiruee22004e2018-06-01 01:52:27226 {"enable-autofill-credit-card-downstream-google-pay-branding",
227 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSName,
228 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSDescription,
229 flags_ui::kOsIos,
230 FEATURE_VALUE_TYPE(
231 autofill::features::kAutofillDownstreamUseGooglePayBrandingOniOS)},
Moe Ahmadi3fd9f202018-05-10 17:39:24232 {"enable-autofill-credit-card-upload-google-pay-branding",
233 flag_descriptions::kAutofillUpstreamUseGooglePayBrandingOnMobileName,
234 flag_descriptions::
235 kAutofillUpstreamUseGooglePayBrandingOnMobileDescription,
236 flags_ui::kOsIos,
237 FEATURE_VALUE_TYPE(
238 autofill::features::kAutofillUpstreamUseGooglePayBrandingOnMobile)},
Moe Ahmadif5e2fe62018-06-13 16:04:56239 {"enable-autofill-credit-card-upload-update-prompt-explanation",
240 flag_descriptions::
241 kEnableAutofillCreditCardUploadUpdatePromptExplanationName,
242 flag_descriptions::
243 kEnableAutofillCreditCardUploadUpdatePromptExplanationDescription,
244 flags_ui::kOsIos,
245 FEATURE_VALUE_TYPE(autofill::kAutofillUpstreamUpdatePromptExplanation)},
Moe Ahmadid6d5d172018-06-20 17:20:23246 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
247 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
248 SINGLE_VALUE_TYPE_AND_VALUE(
249 switches::kSyncServiceURL,
250 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
251 {"wallet-service-use-sandbox",
252 flag_descriptions::kWalletServiceUseSandboxName,
253 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
254 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
255 autofill::switches::kWalletServiceUseSandbox,
256 "1",
257 autofill::switches::kWalletServiceUseSandbox,
258 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59259 {"show-autofill-type-predictions",
260 flag_descriptions::kShowAutofillTypePredictionsName,
261 flag_descriptions::kShowAutofillTypePredictionsDescription,
262 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46263 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22264 {"autofill-ios-delay-between-fields",
265 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
266 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
267 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Justin Cohen2d81c582018-01-22 14:46:44268 {"ui-refresh-phase-1", flag_descriptions::kUIRefreshPhase1Name,
269 flag_descriptions::kUIRefreshPhase1Description, flags_ui::kOsIos,
270 FEATURE_VALUE_TYPE(kUIRefreshPhase1)},
sczs44d54dc2018-03-12 15:56:02271 {"collections-ui-reboot", flag_descriptions::kCollectionsUIRebootName,
272 flag_descriptions::kCollectionsUIRebootDescription, flags_ui::kOsIos,
273 FEATURE_VALUE_TYPE(kCollectionsUIReboot)},
Peter K. Lee1e176752018-05-04 20:48:09274 {"infobars-ui-reboot", flag_descriptions::kInfobarsUIRebootName,
275 flag_descriptions::kInfobarsUIRebootDescription, flags_ui::kOsIos,
276 FEATURE_VALUE_TYPE(kInfobarsUIReboot)},
Daniel Blakemore72387d32018-02-13 23:45:55277 {"mailto-handling-google-ui",
278 flag_descriptions::kMailtoHandlingWithGoogleUIName,
279 flag_descriptions::kMailtoHandlingWithGoogleUIDescription,
280 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)},
Sylvain Defresneae6987e2018-03-01 13:21:40281 {"new-clear-browsing-data-ui",
282 flag_descriptions::kNewClearBrowsingDataUIName,
283 flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos,
284 FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)},
mrefaat390f99c0d2018-05-10 19:44:24285 {"itunes-urls-store-kit-handling",
286 flag_descriptions::kITunesUrlsStoreKitHandlingName,
287 flag_descriptions::kITunesUrlsStoreKitHandlingDescription,
288 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kITunesUrlsStoreKitHandling)},
Jérôme Lebelfa6c5ae2018-03-29 13:46:57289 {"unified-consent", flag_descriptions::kUnifiedConsentName,
290 flag_descriptions::kUnifiedConsentDescription, flags_ui::kOsIos,
Mihai Sardarescu160ec662018-07-18 21:13:51291 FEATURE_VALUE_TYPE(unified_consent::kUnifiedConsent)},
Jérôme Lebelfe1b2e02018-08-03 12:26:20292 {"force-unified-consent-bump",
293 flag_descriptions::kForceUnifiedConsentBumpName,
294 flag_descriptions::kForceUnifiedConsentBumpDescription, flags_ui::kOsIos,
295 FEATURE_VALUE_TYPE(unified_consent::kForceUnifiedConsentBump)},
sebsg93dc01c2018-04-05 16:42:48296 {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName,
297 flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos,
298 FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)},
Olivier Robin081912dd2018-06-11 09:14:26299 {"autofill-prefilled-fields",
300 flag_descriptions::kAutofillPrefilledFieldsName,
301 flag_descriptions::kAutofillPrefilledFieldsDescription, flags_ui::kOsIos,
302 FEATURE_VALUE_TYPE(autofill::features::kAutofillPrefilledFields)},
Olivier Robind81475b02018-06-20 21:30:11303 {"autofill-show-all-profiles-on-prefilled-forms",
304 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsName,
305 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsDescription,
306 flags_ui::kOsIos,
307 FEATURE_VALUE_TYPE(
308 autofill::features::kAutofillShowAllSuggestionsOnPrefilledForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08309 {"autofill-restrict-formless-form-extraction",
310 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
311 flag_descriptions::
312 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
313 flags_ui::kOsIos,
314 FEATURE_VALUE_TYPE(
315 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
[email protected]dbcd4d52018-04-10 09:17:58316 {"ui-refresh-location-bar", flag_descriptions::kUIRefreshLocationBarName,
317 flag_descriptions::kUIRefreshLocationBarDescription, flags_ui::kOsIos,
318 FEATURE_VALUE_TYPE(kUIRefreshLocationBar)},
Kurt Horimotodc33af32018-05-01 01:39:14319 {"fullscreen-viewport-adjustment-experiment",
320 flag_descriptions::kFullscreenViewportAdjustmentExperimentName,
321 flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription,
322 flags_ui::kOsIos,
323 MULTI_VALUE_TYPE(
324 fullscreen::features::kViewportAdjustmentExperimentChoices)},
Roger McFarlane1a37d7b2018-04-20 22:45:19325 {"autofill-enforce-min-required-fields-for-heuristics",
326 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
327 flag_descriptions::
328 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
329 flags_ui::kOsIos,
330 FEATURE_VALUE_TYPE(
331 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
332 {"autofill-enforce-min-required-fields-for-query",
333 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
334 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
335 flags_ui::kOsIos,
336 FEATURE_VALUE_TYPE(
337 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
338 {"autofill-enforce-min-required-fields-for-upload",
339 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
340 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
341 flags_ui::kOsIos,
342 FEATURE_VALUE_TYPE(
343 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Gauthier Ambard4417f852018-04-26 14:24:32344 {"browser-container-fullscreen",
345 flag_descriptions::kBrowserContainerFullscreenName,
346 flag_descriptions::kBrowserContainerFullscreenDescription,
Gauthier Ambard5d7627282018-05-18 08:20:07347 flags_ui::kOsIos,
348 FEATURE_VALUE_TYPE(web::features::kBrowserContainerFullscreen)},
Roger McFarlane2eceba982018-05-18 01:37:11349 {"autofill-cache-query-responses",
350 flag_descriptions::kAutofillCacheQueryResponsesName,
351 flag_descriptions::kAutofillCacheQueryResponsesDescription,
352 flags_ui::kOsIos,
353 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Javier Ernesto Flores Robles23c71a7d2018-06-01 09:51:17354 {"autofill-manual-fallback", flag_descriptions::kAutofillManualFallbackName,
355 flag_descriptions::kAutofillManualFallbackDescription, flags_ui::kOsIos,
356 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallback)},
Yi Su392b3032018-06-05 07:26:47357 {"webpage-text-accessibility",
358 flag_descriptions::kWebPageTextAccessibilityName,
359 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
360 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Mike Dougherty39d36b02018-06-19 19:21:40361 {"web-frame-messaging", flag_descriptions::kWebFrameMessagingName,
362 flag_descriptions::kWebFrameMessagingDescription, flags_ui::kOsIos,
363 FEATURE_VALUE_TYPE(web::features::kWebFrameMessaging)},
Yi Suf63219e2018-06-25 17:41:01364 {"copy-image", flag_descriptions::kCopyImageName,
365 flag_descriptions::kCopyImageDescription, flags_ui::kOsIos,
366 FEATURE_VALUE_TYPE(kCopyImage)},
Vadym Doroshenkoa9a914942018-07-19 08:23:30367 {"new-password-form-parsing",
368 flag_descriptions::kNewPasswordFormParsingName,
369 flag_descriptions::kNewPasswordFormParsingDescription, flags_ui::kOsIos,
370 FEATURE_VALUE_TYPE(password_manager::features::kNewPasswordFormParsing)},
mrefaat4539b032018-08-02 22:25:45371 {"app-launcher-refresh", flag_descriptions::kAppLauncherRefreshName,
372 flag_descriptions::kAppLauncherRefreshDescription, flags_ui::kOsIos,
373 FEATURE_VALUE_TYPE(kAppLauncherRefresh)},
Gauthier Ambardcfd85182018-01-05 10:37:46374};
sdefresne14900ee2015-11-27 14:43:21375
376// Add all switches from experimental flags to |command_line|.
377void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
378 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
379
sdefresne14900ee2015-11-27 14:43:21380 // Set the UA flag if UseMobileSafariUA is enabled.
381 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
382 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
383 // Chrome puts its product token.
avi571943672015-12-22 02:12:49384 int32_t major = 0;
385 int32_t minor = 0;
386 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21387 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
388 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
389
390 command_line->AppendSwitchASCII(switches::kUserAgent,
391 web::BuildUserAgentFromProduct(product));
392 }
393
394 // Freeform commandline flags. These are added last, so that any flags added
395 // earlier in this function take precedence.
396 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
397 base::CommandLine::StringVector flags;
398 // Append an empty "program" argument.
399 flags.push_back("");
400
401 // The number of flags corresponds to the number of text fields in
402 // Experimental.plist.
403 const int kNumFreeformFlags = 5;
404 for (int i = 1; i <= kNumFreeformFlags; ++i) {
405 NSString* key =
406 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
407 NSString* flag = [defaults stringForKey:key];
408 if ([flag length]) {
409 flags.push_back(base::SysNSStringToUTF8(flag));
410 }
411 }
412
413 base::CommandLine temp_command_line(flags);
414 command_line->AppendArguments(temp_command_line, false);
415 }
msardafc76f662017-02-24 12:46:28416
justincohendacc85d2017-06-28 23:34:10417 // Populate command line flag for 3rd party keyboard omnibox workaround.
418 NSString* enableThirdPartyKeyboardWorkaround =
419 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
420 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
421 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
422 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
423 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
424 }
425
msardafc76f662017-02-24 12:46:28426 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
427 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21428}
429
430bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
431 return false;
432}
433
434class FlagsStateSingleton {
435 public:
436 FlagsStateSingleton()
437 : flags_state_(kFeatureEntries, arraysize(kFeatureEntries)) {}
438 ~FlagsStateSingleton() {}
439
440 static FlagsStateSingleton* GetInstance() {
441 return base::Singleton<FlagsStateSingleton>::get();
442 }
443
444 static flags_ui::FlagsState* GetFlagsState() {
445 return &GetInstance()->flags_state_;
446 }
447
448 private:
449 flags_ui::FlagsState flags_state_;
450
451 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
452};
453} // namespace
454
455void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
456 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02457 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21458 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11459 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53460 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21461}
462
jkrcalbf073372016-07-29 07:21:31463std::vector<std::string> RegisterAllFeatureVariationParameters(
464 flags_ui::FlagsStorage* flags_storage,
465 base::FeatureList* feature_list) {
466 return FlagsStateSingleton::GetFlagsState()
467 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
468}
469
sdefresne14900ee2015-11-27 14:43:21470void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
471 flags_ui::FlagAccess access,
472 base::ListValue* supported_entries,
473 base::ListValue* unsupported_entries) {
474 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
475 flags_storage, access, supported_entries, unsupported_entries,
476 base::Bind(&SkipConditionalFeatureEntry));
477}
478
479void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
480 const std::string& internal_name,
481 bool enable) {
482 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
483 flags_storage, internal_name, enable);
484}
485
486void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
487 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
488}
489
490namespace testing {
491
492const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
493 *count = arraysize(kFeatureEntries);
494 return kFeatureEntries;
495}
496
497} // namespace testing