blob: b8241082f8d9ccd27c2fdacb22a66dfad1193c4c [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"
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"
noyau4cfb1332016-10-25 17:05:4233#include "components/ntp_tiles/switches.h"
Justin Donnelly33d712e2017-08-23 21:32:5134#include "components/omnibox/browser/omnibox_field_trial.h"
Ioana Pandeled14ce9e2017-11-28 14:41:4635#include "components/password_manager/core/common/password_manager_features.h"
mathp9b4c11d2017-07-06 20:24:1336#include "components/payments/core/features.h"
Marc Treib5fc99e1f2017-11-08 12:19:1837#include "components/search_provider_logos/switches.h"
Emily Starkbafa9062017-12-27 15:22:4638#include "components/security_state/core/features.h"
David Rogera6c88122017-10-25 13:02:4639#include "components/signin/core/browser/signin_switches.h"
sdefresne36579782016-02-05 11:08:2540#include "components/strings/grit/components_strings.h"
Moe Ahmadid6d5d172018-06-20 17:20:2341#include "components/sync/driver/sync_driver_switches.h"
Mihai Sardarescu160ec662018-07-18 21:13:5142#include "components/unified_consent/feature.h"
mrefaat4539b032018-08-02 22:25:4543#include "ios/chrome/browser/app_launcher/app_launcher_flags.h"
Sylvain Defresneae6987e2018-03-01 13:21:4044#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2145#include "ios/chrome/browser/chrome_switches.h"
Jean-François Geyelin30be5912017-08-25 12:05:3846#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
vabr0215a8e2017-03-28 12:47:3447#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
mrefaat390f99c0d2018-05-10 19:44:2448#include "ios/chrome/browser/itunes_urls/itunes_urls_flag.h"
Daniel Blakemore72387d32018-02-13 23:45:5549#include "ios/chrome/browser/mailto/features.h"
Yi Sua3d55f3d2018-09-24 17:49:4150#include "ios/chrome/browser/search_engines/feature_flags.h"
Jérôme Lebelec282832018-09-18 08:34:1851#include "ios/chrome/browser/signin/feature_flags.h"
Mike Doughertya5e5ad52017-08-05 00:11:5852#include "ios/chrome/browser/ssl/captive_portal_features.h"
Louis Romerod11747a2017-10-20 20:10:3553#include "ios/chrome/browser/ui/external_search/features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3554#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
Mark Cogan02ed6c772018-05-31 17:00:5155#import "ios/chrome/browser/ui/history/features.h"
Rohit Rao6a3a481d2017-09-25 19:31:4156#include "ios/chrome/browser/ui/main/main_feature_flags.h"
Mark Cogan02ed6c772018-05-31 17:00:5157#import "ios/chrome/browser/ui/toolbar/public/features.h"
Kurt Horimoto79d590b2018-09-12 19:09:2858#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h"
Justin Cohen2d81c582018-01-22 14:46:4459#include "ios/chrome/browser/ui/ui_feature_flags.h"
Yi Su392b3032018-06-05 07:26:4760#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2161#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2862#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Danyao Wang34da6ff2017-10-30 15:16:5663#include "ios/web/public/features.h"
sdefresne14900ee2015-11-27 14:43:2164#include "ios/web/public/user_agent.h"
65#include "ios/web/public/web_view_creation_util.h"
66
67#if !defined(OFFICIAL_BUILD)
68#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2269#endif
stkhapuginc1be1792016-12-13 14:30:5370
71#if !defined(__has_feature) || !__has_feature(objc_arc)
72#error "This file requires ARC support."
73#endif
sdefresne14900ee2015-11-27 14:43:2174
elawrence816f6790e2017-06-16 18:19:2875using flags_ui::FeatureEntry;
76
sdefresne14900ee2015-11-27 14:43:2177namespace {
Emily Starkbafa9062017-12-27 15:22:4678
79const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
80 {security_state::features::kMarkHttpAsFeatureParameterName,
81 security_state::features::kMarkHttpAsParameterDangerous}};
82const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = {
83 {security_state::features::kMarkHttpAsFeatureParameterName,
84 security_state::features::kMarkHttpAsParameterWarning}};
85const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
86 {security_state::features::kMarkHttpAsFeatureParameterName,
87 security_state::features::
88 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
89const FeatureEntry::FeatureParam
90 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = {
91 {security_state::features::kMarkHttpAsFeatureParameterName,
92 security_state::features::
93 kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}};
94
95const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
96 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
97 arraysize(kMarkHttpAsDangerous), nullptr},
98 {"(mark with a Not Secure warning)", kMarkHttpAsWarning,
99 arraysize(kMarkHttpAsWarning), nullptr},
100 {"(mark with a Not Secure warning and dangerous on form edits)",
101 kMarkHttpAsWarningAndDangerousOnFormEdits,
102 arraysize(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr},
103 {"(mark with a Not Secure warning and dangerous on passwords and credit "
104 "card fields)",
105 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards,
106 arraysize(kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards),
107 nullptr}};
elawrence816f6790e2017-06-16 18:19:28108
Marc Treib5fc99e1f2017-11-08 12:19:18109const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
110 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
111 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
112 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
113 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
114 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
115 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
116 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
117 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
118 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
119 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
120 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
121};
Marc Treib2752e8b2017-08-04 14:12:09122
Olivier Robin3d60411622018-02-23 10:03:22123const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
124 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
125 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
126 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
127 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
128 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
129 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
130 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
131 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
132 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
133};
134
Cooper Knaak1e026562017-07-26 05:22:28135// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21136// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28137// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
138// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21139// macro for this type supplying the command line to the macro.
140// . MULTI_VALUE: a list of choices, the first of which should correspond to a
141// deactivated state for this lab (i.e. no command line option). To specify
142// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
143// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28144// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
145// either enabled, disabled, or uses the default value of the associated
146// base::Feature instance. To specify this type of entry use the macro
147// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
148// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
149// base::Feature instance. Choices corresponding to the default state, a
150// universally enabled state, and a universally disabled state are
151// automatically included. To specify this type of entry use the macro
152// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
153// the array of choices.
154//
sdefresne14900ee2015-11-27 14:43:21155// See the documentation of FeatureEntry for details on the fields.
156//
157// When adding a new choice, add it to the end of the list.
158const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46159 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28160 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46161 FEATURE_WITH_PARAMS_VALUE_TYPE(
162 security_state::features::kMarkHttpAsFeature,
163 kMarkHttpAsFeatureVariations,
164 "MarkHttpAs")},
mathp9b4c11d2017-07-06 20:24:13165 {"web-payments", flag_descriptions::kWebPaymentsName,
166 flag_descriptions::kWebPaymentsDescription, flags_ui::kOsIos,
167 FEATURE_VALUE_TYPE(payments::features::kWebPayments)},
Randall Raymond59766ac2017-08-09 16:28:58168 {"web-payments-native-apps", flag_descriptions::kWebPaymentsNativeAppsName,
169 flag_descriptions::kWebPaymentsNativeAppsDescription, flags_ui::kOsIos,
170 FEATURE_VALUE_TYPE(payments::features::kWebPaymentsNativeApps)},
Mike Doughertyc20eefa2018-02-20 19:20:33171 {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName,
172 flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos,
173 FEATURE_VALUE_TYPE(kCaptivePortalMetrics)},
Cooper Knaak1e026562017-07-26 05:22:28174 {"in-product-help-demo-mode-choice",
175 flag_descriptions::kInProductHelpDemoModeName,
176 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
177 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23178 feature_engagement::kIPHDemoMode,
179 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09180 "IPH_DemoMode")},
181 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
182 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18183 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Justin Donnelly33d712e2017-08-23 21:32:51184 {"omnibox-ui-elide-suggestion-url-after-host",
185 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostName,
186 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostDescription,
187 flags_ui::kOsIos,
188 FEATURE_VALUE_TYPE(omnibox::kUIExperimentElideSuggestionUrlAfterHost)},
Jean-François Geyelin30be5912017-08-25 12:05:38189 {"drag_and_drop", flag_descriptions::kDragAndDropName,
190 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41191 FEATURE_VALUE_TYPE(kDragAndDrop)},
Rohit Rao6a3a481d2017-09-25 19:31:41192 {"tab_switcher_presents_bvc",
193 flag_descriptions::kTabSwitcherPresentsBVCName,
194 flag_descriptions::kTabSwitcherPresentsBVCDescription, flags_ui::kOsIos,
Jean-François Geyelined4cde72017-10-11 11:34:50195 FEATURE_VALUE_TYPE(kTabSwitcherPresentsBVC)},
Louis Romerod11747a2017-10-20 20:10:35196 {"external-search", flag_descriptions::kExternalSearchName,
197 flag_descriptions::kExternalSearchDescription, flags_ui::kOsIos,
198 FEATURE_VALUE_TYPE(kExternalSearch)},
sczsa0c91942017-10-26 18:39:59199 {"history-batch-updates-filter",
200 flag_descriptions::kHistoryBatchUpdatesFilterName,
201 flag_descriptions::kHistoryBatchUpdatesFilterDescription, flags_ui::kOsIos,
202 FEATURE_VALUE_TYPE(kHistoryBatchUpdatesFilter)},
Danyao Wang34da6ff2017-10-30 15:16:56203 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
204 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
205 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
Eugene Buta23c8fb2018-05-14 20:40:23206 {"web-error-pages", flag_descriptions::kWebErrorPagesName,
207 flag_descriptions::kWebErrorPagesDescription, flags_ui::kOsIos,
208 FEATURE_VALUE_TYPE(web::features::kWebErrorPages)},
sczsdc2e8e02018-01-09 18:39:32209 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
210 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
211 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
mrefaata6501d92017-12-11 19:50:50212 {"wk-http-system-cookie-store",
213 flag_descriptions::kWKHTTPSystemCookieStoreName,
214 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59215 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22216 {"enable-autofill-credit-card-upload",
217 flag_descriptions::kAutofillCreditCardUploadName,
218 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24219 FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
Lakshmi Kumar Dabbiruee22004e2018-06-01 01:52:27220 {"enable-autofill-credit-card-downstream-google-pay-branding",
221 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSName,
222 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSDescription,
223 flags_ui::kOsIos,
224 FEATURE_VALUE_TYPE(
225 autofill::features::kAutofillDownstreamUseGooglePayBrandingOniOS)},
Moe Ahmadi3fd9f202018-05-10 17:39:24226 {"enable-autofill-credit-card-upload-google-pay-branding",
227 flag_descriptions::kAutofillUpstreamUseGooglePayBrandingOnMobileName,
228 flag_descriptions::
229 kAutofillUpstreamUseGooglePayBrandingOnMobileDescription,
230 flags_ui::kOsIos,
231 FEATURE_VALUE_TYPE(
232 autofill::features::kAutofillUpstreamUseGooglePayBrandingOnMobile)},
Moe Ahmadif5e2fe62018-06-13 16:04:56233 {"enable-autofill-credit-card-upload-update-prompt-explanation",
234 flag_descriptions::
235 kEnableAutofillCreditCardUploadUpdatePromptExplanationName,
236 flag_descriptions::
237 kEnableAutofillCreditCardUploadUpdatePromptExplanationDescription,
238 flags_ui::kOsIos,
Anne Lim579b5732018-08-30 18:24:24239 FEATURE_VALUE_TYPE(
240 autofill::features::kAutofillUpstreamUpdatePromptExplanation)},
Moe Ahmadid6d5d172018-06-20 17:20:23241 {"use-sync-sandbox", flag_descriptions::kSyncSandboxName,
242 flag_descriptions::kSyncSandboxDescription, flags_ui::kOsIos,
243 SINGLE_VALUE_TYPE_AND_VALUE(
244 switches::kSyncServiceURL,
245 "https://chrome-sync.sandbox.google.com/chrome-sync/alpha")},
246 {"wallet-service-use-sandbox",
247 flag_descriptions::kWalletServiceUseSandboxName,
248 flag_descriptions::kWalletServiceUseSandboxDescription, flags_ui::kOsIos,
249 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(
250 autofill::switches::kWalletServiceUseSandbox,
251 "1",
252 autofill::switches::kWalletServiceUseSandbox,
253 "0")},
Mohamad Ahmadic4df81f2017-12-20 04:41:59254 {"show-autofill-type-predictions",
255 flag_descriptions::kShowAutofillTypePredictionsName,
256 flag_descriptions::kShowAutofillTypePredictionsDescription,
257 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46258 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22259 {"autofill-ios-delay-between-fields",
260 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
261 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
262 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Olivier Robincba46aa2018-09-12 07:48:39263 {"autofill-ios-iframe-support",
264 flag_descriptions::kAutofillEnableIFrameSupportOniOSName,
265 flag_descriptions::kAutofillEnableIFrameSupportOniOSDescription,
266 flags_ui::kOsIos,
267 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableIFrameSupportOniOS)},
Daniel Blakemore72387d32018-02-13 23:45:55268 {"mailto-handling-google-ui",
269 flag_descriptions::kMailtoHandlingWithGoogleUIName,
270 flag_descriptions::kMailtoHandlingWithGoogleUIDescription,
271 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)},
Sylvain Defresneae6987e2018-03-01 13:21:40272 {"new-clear-browsing-data-ui",
273 flag_descriptions::kNewClearBrowsingDataUIName,
274 flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos,
275 FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)},
mrefaat390f99c0d2018-05-10 19:44:24276 {"itunes-urls-store-kit-handling",
277 flag_descriptions::kITunesUrlsStoreKitHandlingName,
278 flag_descriptions::kITunesUrlsStoreKitHandlingDescription,
279 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kITunesUrlsStoreKitHandling)},
Jérôme Lebelfa6c5ae2018-03-29 13:46:57280 {"unified-consent", flag_descriptions::kUnifiedConsentName,
281 flag_descriptions::kUnifiedConsentDescription, flags_ui::kOsIos,
Mihai Sardarescu160ec662018-07-18 21:13:51282 FEATURE_VALUE_TYPE(unified_consent::kUnifiedConsent)},
Jérôme Lebelfe1b2e02018-08-03 12:26:20283 {"force-unified-consent-bump",
284 flag_descriptions::kForceUnifiedConsentBumpName,
285 flag_descriptions::kForceUnifiedConsentBumpDescription, flags_ui::kOsIos,
286 FEATURE_VALUE_TYPE(unified_consent::kForceUnifiedConsentBump)},
sebsg93dc01c2018-04-05 16:42:48287 {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName,
288 flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos,
289 FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)},
Olivier Robin081912dd2018-06-11 09:14:26290 {"autofill-prefilled-fields",
291 flag_descriptions::kAutofillPrefilledFieldsName,
292 flag_descriptions::kAutofillPrefilledFieldsDescription, flags_ui::kOsIos,
293 FEATURE_VALUE_TYPE(autofill::features::kAutofillPrefilledFields)},
Olivier Robind81475b02018-06-20 21:30:11294 {"autofill-show-all-profiles-on-prefilled-forms",
295 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsName,
296 flag_descriptions::kAutofillShowAllSuggestionsOnPrefilledFormsDescription,
297 flags_ui::kOsIos,
298 FEATURE_VALUE_TYPE(
299 autofill::features::kAutofillShowAllSuggestionsOnPrefilledForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08300 {"autofill-restrict-formless-form-extraction",
301 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
302 flag_descriptions::
303 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
304 flags_ui::kOsIos,
305 FEATURE_VALUE_TYPE(
306 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
Kurt Horimotodc33af32018-05-01 01:39:14307 {"fullscreen-viewport-adjustment-experiment",
308 flag_descriptions::kFullscreenViewportAdjustmentExperimentName,
309 flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription,
310 flags_ui::kOsIos,
311 MULTI_VALUE_TYPE(
312 fullscreen::features::kViewportAdjustmentExperimentChoices)},
Roger McFarlane1a37d7b2018-04-20 22:45:19313 {"autofill-enforce-min-required-fields-for-heuristics",
314 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
315 flag_descriptions::
316 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
317 flags_ui::kOsIos,
318 FEATURE_VALUE_TYPE(
319 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
320 {"autofill-enforce-min-required-fields-for-query",
321 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
322 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
323 flags_ui::kOsIos,
324 FEATURE_VALUE_TYPE(
325 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
326 {"autofill-enforce-min-required-fields-for-upload",
327 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
328 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
329 flags_ui::kOsIos,
330 FEATURE_VALUE_TYPE(
331 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Gauthier Ambard4417f852018-04-26 14:24:32332 {"browser-container-fullscreen",
333 flag_descriptions::kBrowserContainerFullscreenName,
334 flag_descriptions::kBrowserContainerFullscreenDescription,
Gauthier Ambard5d7627282018-05-18 08:20:07335 flags_ui::kOsIos,
336 FEATURE_VALUE_TYPE(web::features::kBrowserContainerFullscreen)},
Roger McFarlane2eceba982018-05-18 01:37:11337 {"autofill-cache-query-responses",
338 flag_descriptions::kAutofillCacheQueryResponsesName,
339 flag_descriptions::kAutofillCacheQueryResponsesDescription,
340 flags_ui::kOsIos,
341 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Jeffrey Cohen05cdafa392018-08-15 20:49:17342 {"autofill-enable-company-name",
343 flag_descriptions::kAutofillEnableCompanyNameName,
344 flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos,
345 FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)},
Javier Ernesto Flores Robles23c71a7d2018-06-01 09:51:17346 {"autofill-manual-fallback", flag_descriptions::kAutofillManualFallbackName,
347 flag_descriptions::kAutofillManualFallbackDescription, flags_ui::kOsIos,
348 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallback)},
Yi Su392b3032018-06-05 07:26:47349 {"webpage-text-accessibility",
350 flag_descriptions::kWebPageTextAccessibilityName,
351 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
352 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Mike Dougherty39d36b02018-06-19 19:21:40353 {"web-frame-messaging", flag_descriptions::kWebFrameMessagingName,
354 flag_descriptions::kWebFrameMessagingDescription, flags_ui::kOsIos,
355 FEATURE_VALUE_TYPE(web::features::kWebFrameMessaging)},
Yi Suf63219e2018-06-25 17:41:01356 {"copy-image", flag_descriptions::kCopyImageName,
357 flag_descriptions::kCopyImageDescription, flags_ui::kOsIos,
358 FEATURE_VALUE_TYPE(kCopyImage)},
Vadym Doroshenkoa9a914942018-07-19 08:23:30359 {"new-password-form-parsing",
360 flag_descriptions::kNewPasswordFormParsingName,
361 flag_descriptions::kNewPasswordFormParsingDescription, flags_ui::kOsIos,
362 FEATURE_VALUE_TYPE(password_manager::features::kNewPasswordFormParsing)},
mrefaat4539b032018-08-02 22:25:45363 {"app-launcher-refresh", flag_descriptions::kAppLauncherRefreshName,
364 flag_descriptions::kAppLauncherRefreshDescription, flags_ui::kOsIos,
365 FEATURE_VALUE_TYPE(kAppLauncherRefresh)},
Marc Treib6f0bbd22018-08-28 10:07:19366 {"sync-standalone-transport",
367 flag_descriptions::kSyncStandaloneTransportName,
368 flag_descriptions::kSyncStandaloneTransportDescription, flags_ui::kOsIos,
369 FEATURE_VALUE_TYPE(switches::kSyncStandaloneTransport)},
Marc Treib4bd95e72018-08-30 06:30:58370 {"sync-support-secondary-account",
371 flag_descriptions::kSyncSupportSecondaryAccountName,
372 flag_descriptions::kSyncSupportSecondaryAccountDescription,
373 flags_ui::kOsIos,
374 FEATURE_VALUE_TYPE(switches::kSyncSupportSecondaryAccount)},
Gauthier Ambard66de93d2018-08-30 15:58:19375 {"out-of-web-fullscreen", flag_descriptions::kOutOfWebFullscreenName,
376 flag_descriptions::kOutOfWebFullscreenDescription, flags_ui::kOsIos,
377 FEATURE_VALUE_TYPE(web::features::kOutOfWebFullscreen)},
Javier Ernesto Flores Robles8e66f732018-09-12 15:41:15378 {"autofill-manual-fallback-phase-two",
379 flag_descriptions::kAutofillManualFallbackPhaseTwoName,
380 flag_descriptions::kAutofillManualFallbackPhaseTwoDescription,
381 flags_ui::kOsIos,
382 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallbackPhaseTwo)},
Kurt Horimoto79d590b2018-09-12 19:09:28383 {"toolbar-container", flag_descriptions::kToolbarContainerName,
384 flag_descriptions::kToolbarContainerDescription, flags_ui::kOsIos,
385 FEATURE_VALUE_TYPE(toolbar_container::kToolbarContainerEnabled)},
[email protected]9edb7c1a2018-09-19 12:56:39386 {"omnibox-popup-shortcuts", flag_descriptions::kOmniboxPopupShortcutsName,
387 flag_descriptions::kOmniboxPopupShortcutsDescription, flags_ui::kOsIos,
388 FEATURE_VALUE_TYPE(kOmniboxPopupShortcuts)},
Jérôme Lebelec282832018-09-18 08:34:18389 {"sso-with-wkwebview", flag_descriptions::kSSOWithWKWebViewName,
390 flag_descriptions::kSSOWithWKWebViewDescription, flags_ui::kOsIos,
391 FEATURE_VALUE_TYPE(kSSOWithWKWebView)},
edchin98e594cc2018-09-18 18:02:40392 {"wk-web-view-snapshots", flag_descriptions::kWKWebViewSnapshotsName,
393 flag_descriptions::kWKWebViewSnapshotsDescription, flags_ui::kOsIos,
394 FEATURE_VALUE_TYPE(kWKWebViewSnapshots)},
Yi Sua3d55f3d2018-09-24 17:49:41395 {"custom-search-engines", flag_descriptions::kCustomSearchEnginesName,
396 flag_descriptions::kCustomSearchEnginesDescription, flags_ui::kOsIos,
397 FEATURE_VALUE_TYPE(kCustomSearchEngines)},
Gauthier Ambardcfd85182018-01-05 10:37:46398};
sdefresne14900ee2015-11-27 14:43:21399
400// Add all switches from experimental flags to |command_line|.
401void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
402 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
403
sdefresne14900ee2015-11-27 14:43:21404 // Set the UA flag if UseMobileSafariUA is enabled.
405 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
406 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
407 // Chrome puts its product token.
avi571943672015-12-22 02:12:49408 int32_t major = 0;
409 int32_t minor = 0;
410 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21411 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
412 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
413
414 command_line->AppendSwitchASCII(switches::kUserAgent,
415 web::BuildUserAgentFromProduct(product));
416 }
417
418 // Freeform commandline flags. These are added last, so that any flags added
419 // earlier in this function take precedence.
420 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
421 base::CommandLine::StringVector flags;
422 // Append an empty "program" argument.
423 flags.push_back("");
424
425 // The number of flags corresponds to the number of text fields in
426 // Experimental.plist.
427 const int kNumFreeformFlags = 5;
428 for (int i = 1; i <= kNumFreeformFlags; ++i) {
429 NSString* key =
430 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
431 NSString* flag = [defaults stringForKey:key];
432 if ([flag length]) {
433 flags.push_back(base::SysNSStringToUTF8(flag));
434 }
435 }
436
437 base::CommandLine temp_command_line(flags);
438 command_line->AppendArguments(temp_command_line, false);
439 }
msardafc76f662017-02-24 12:46:28440
justincohendacc85d2017-06-28 23:34:10441 // Populate command line flag for 3rd party keyboard omnibox workaround.
442 NSString* enableThirdPartyKeyboardWorkaround =
443 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
444 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
445 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
446 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
447 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
448 }
449
msardafc76f662017-02-24 12:46:28450 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
451 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21452}
453
454bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
455 return false;
456}
457
458class FlagsStateSingleton {
459 public:
460 FlagsStateSingleton()
461 : flags_state_(kFeatureEntries, arraysize(kFeatureEntries)) {}
462 ~FlagsStateSingleton() {}
463
464 static FlagsStateSingleton* GetInstance() {
465 return base::Singleton<FlagsStateSingleton>::get();
466 }
467
468 static flags_ui::FlagsState* GetFlagsState() {
469 return &GetInstance()->flags_state_;
470 }
471
472 private:
473 flags_ui::FlagsState flags_state_;
474
475 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
476};
477} // namespace
478
479void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
480 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02481 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21482 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11483 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53484 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21485}
486
jkrcalbf073372016-07-29 07:21:31487std::vector<std::string> RegisterAllFeatureVariationParameters(
488 flags_ui::FlagsStorage* flags_storage,
489 base::FeatureList* feature_list) {
490 return FlagsStateSingleton::GetFlagsState()
491 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
492}
493
sdefresne14900ee2015-11-27 14:43:21494void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
495 flags_ui::FlagAccess access,
496 base::ListValue* supported_entries,
497 base::ListValue* unsupported_entries) {
498 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
499 flags_storage, access, supported_entries, unsupported_entries,
500 base::Bind(&SkipConditionalFeatureEntry));
501}
502
503void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
504 const std::string& internal_name,
505 bool enable) {
506 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
507 flags_storage, internal_name, enable);
508}
509
510void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
511 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
512}
513
514namespace testing {
515
516const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
517 *count = arraysize(kFeatureEntries);
518 return kFeatureEntries;
519}
520
521} // namespace testing