blob: 26fcbce891169bd5070a01f5d5cdf98352db297a [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"
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"
Jérôme Lebelfa6c5ae2018-03-29 13:46:5739#include "components/signin/core/browser/profile_management_switches.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"
Sylvain Defresneae6987e2018-03-01 13:21:4042#include "ios/chrome/browser/browsing_data/browsing_data_features.h"
sdefresne14900ee2015-11-27 14:43:2143#include "ios/chrome/browser/chrome_switches.h"
Jean-François Geyelin30be5912017-08-25 12:05:3844#include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h"
vabr0215a8e2017-03-28 12:47:3445#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
mrefaat390f99c0d2018-05-10 19:44:2446#include "ios/chrome/browser/itunes_urls/itunes_urls_flag.h"
Daniel Blakemore72387d32018-02-13 23:45:5547#include "ios/chrome/browser/mailto/features.h"
Mike Doughertya5e5ad52017-08-05 00:11:5848#include "ios/chrome/browser/ssl/captive_portal_features.h"
Louis Romerod11747a2017-10-20 20:10:3549#include "ios/chrome/browser/ui/external_search/features.h"
Kurt Horimoto4da682b022018-04-12 07:43:3550#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
Mark Cogan02ed6c772018-05-31 17:00:5151#import "ios/chrome/browser/ui/history/features.h"
Rohit Rao6a3a481d2017-09-25 19:31:4152#include "ios/chrome/browser/ui/main/main_feature_flags.h"
Mark Cogan02ed6c772018-05-31 17:00:5153#import "ios/chrome/browser/ui/toolbar/public/features.h"
Justin Cohen2d81c582018-01-22 14:46:4454#include "ios/chrome/browser/ui/ui_feature_flags.h"
Peter K. Lee88137d52018-02-20 19:59:3955#include "ios/chrome/browser/ui/user_feedback_features.h"
Yi Su392b3032018-06-05 07:26:4756#include "ios/chrome/browser/web/features.h"
sdefresne14900ee2015-11-27 14:43:2157#include "ios/chrome/grit/ios_strings.h"
msardafc76f662017-02-24 12:46:2858#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
Danyao Wang34da6ff2017-10-30 15:16:5659#include "ios/web/public/features.h"
sdefresne14900ee2015-11-27 14:43:2160#include "ios/web/public/user_agent.h"
61#include "ios/web/public/web_view_creation_util.h"
62
63#if !defined(OFFICIAL_BUILD)
64#include "components/variations/variations_switches.h"
vitaliii489217aa2017-01-30 14:50:2265#endif
stkhapuginc1be1792016-12-13 14:30:5366
67#if !defined(__has_feature) || !__has_feature(objc_arc)
68#error "This file requires ARC support."
69#endif
sdefresne14900ee2015-11-27 14:43:2170
elawrence816f6790e2017-06-16 18:19:2871using flags_ui::FeatureEntry;
72
sdefresne14900ee2015-11-27 14:43:2173namespace {
Emily Starkbafa9062017-12-27 15:22:4674
75const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = {
76 {security_state::features::kMarkHttpAsFeatureParameterName,
77 security_state::features::kMarkHttpAsParameterDangerous}};
78const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = {
79 {security_state::features::kMarkHttpAsFeatureParameterName,
80 security_state::features::kMarkHttpAsParameterWarning}};
81const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = {
82 {security_state::features::kMarkHttpAsFeatureParameterName,
83 security_state::features::
84 kMarkHttpAsParameterWarningAndDangerousOnFormEdits}};
85const FeatureEntry::FeatureParam
86 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = {
87 {security_state::features::kMarkHttpAsFeatureParameterName,
88 security_state::features::
89 kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}};
90
91const FeatureEntry::FeatureVariation kMarkHttpAsFeatureVariations[] = {
92 {"(mark as actively dangerous)", kMarkHttpAsDangerous,
93 arraysize(kMarkHttpAsDangerous), nullptr},
94 {"(mark with a Not Secure warning)", kMarkHttpAsWarning,
95 arraysize(kMarkHttpAsWarning), nullptr},
96 {"(mark with a Not Secure warning and dangerous on form edits)",
97 kMarkHttpAsWarningAndDangerousOnFormEdits,
98 arraysize(kMarkHttpAsWarningAndDangerousOnFormEdits), nullptr},
99 {"(mark with a Not Secure warning and dangerous on passwords and credit "
100 "card fields)",
101 kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards,
102 arraysize(kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards),
103 nullptr}};
elawrence816f6790e2017-06-16 18:19:28104
Marc Treib5fc99e1f2017-11-08 12:19:18105const FeatureEntry::Choice kUseDdljsonApiChoices[] = {
106 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
107 {"(force test doodle 0)", search_provider_logos::switches::kGoogleDoodleUrl,
108 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios0.json"},
109 {"(force test doodle 1)", search_provider_logos::switches::kGoogleDoodleUrl,
110 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios1.json"},
111 {"(force test doodle 2)", search_provider_logos::switches::kGoogleDoodleUrl,
112 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios2.json"},
113 {"(force test doodle 3)", search_provider_logos::switches::kGoogleDoodleUrl,
114 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios3.json"},
115 {"(force test doodle 4)", search_provider_logos::switches::kGoogleDoodleUrl,
116 "https://www.gstatic.com/chrome/ntp/doodle_test/ddljson_ios4.json"},
117};
Marc Treib2752e8b2017-08-04 14:12:09118
Olivier Robin3d60411622018-02-23 10:03:22119const FeatureEntry::Choice kAutofillIOSDelayBetweenFieldsChoices[] = {
120 {flags_ui::kGenericExperimentChoiceDefault, "", ""},
121 {"0", autofill::switches::kAutofillIOSDelayBetweenFields, "0"},
122 {"10", autofill::switches::kAutofillIOSDelayBetweenFields, "10"},
123 {"20", autofill::switches::kAutofillIOSDelayBetweenFields, "20"},
124 {"50", autofill::switches::kAutofillIOSDelayBetweenFields, "50"},
125 {"100", autofill::switches::kAutofillIOSDelayBetweenFields, "100"},
126 {"200", autofill::switches::kAutofillIOSDelayBetweenFields, "200"},
127 {"500", autofill::switches::kAutofillIOSDelayBetweenFields, "500"},
128 {"1000", autofill::switches::kAutofillIOSDelayBetweenFields, "1000"},
129};
130
Cooper Knaak1e026562017-07-26 05:22:28131// To add a new entry, add to the end of kFeatureEntries. There are four
sdefresne14900ee2015-11-27 14:43:21132// distinct types of entries:
Cooper Knaak1e026562017-07-26 05:22:28133// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
134// default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE
sdefresne14900ee2015-11-27 14:43:21135// macro for this type supplying the command line to the macro.
136// . MULTI_VALUE: a list of choices, the first of which should correspond to a
137// deactivated state for this lab (i.e. no command line option). To specify
138// this type of entry use the macro MULTI_VALUE_TYPE supplying it the
139// array of choices.
Cooper Knaak1e026562017-07-26 05:22:28140// . FEATURE_VALUE: entry is associated with a base::Feature instance. Entry is
141// either enabled, disabled, or uses the default value of the associated
142// base::Feature instance. To specify this type of entry use the macro
143// FEATURE_VALUE_TYPE supplying it the base::Feature instance.
144// . FEATURE_WITH_PARAM_VALUES: a list of choices associated with a
145// base::Feature instance. Choices corresponding to the default state, a
146// universally enabled state, and a universally disabled state are
147// automatically included. To specify this type of entry use the macro
148// FEATURE_WITH_PARAMS_VALUE_TYPE supplying it the base::Feature instance and
149// the array of choices.
150//
sdefresne14900ee2015-11-27 14:43:21151// See the documentation of FeatureEntry for details on the fields.
152//
153// When adding a new choice, add it to the end of the list.
154const flags_ui::FeatureEntry kFeatureEntries[] = {
Emily Starkbafa9062017-12-27 15:22:46155 {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName,
elawrence816f6790e2017-06-16 18:19:28156 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos,
Emily Starkbafa9062017-12-27 15:22:46157 FEATURE_WITH_PARAMS_VALUE_TYPE(
158 security_state::features::kMarkHttpAsFeature,
159 kMarkHttpAsFeatureVariations,
160 "MarkHttpAs")},
mathp9b4c11d2017-07-06 20:24:13161 {"web-payments", flag_descriptions::kWebPaymentsName,
162 flag_descriptions::kWebPaymentsDescription, flags_ui::kOsIos,
163 FEATURE_VALUE_TYPE(payments::features::kWebPayments)},
Randall Raymond59766ac2017-08-09 16:28:58164 {"web-payments-native-apps", flag_descriptions::kWebPaymentsNativeAppsName,
165 flag_descriptions::kWebPaymentsNativeAppsDescription, flags_ui::kOsIos,
166 FEATURE_VALUE_TYPE(payments::features::kWebPaymentsNativeApps)},
Mike Doughertya5e5ad52017-08-05 00:11:58167 {"ios-captive-portal", flag_descriptions::kCaptivePortalName,
168 flag_descriptions::kCaptivePortalDescription, flags_ui::kOsIos,
169 FEATURE_VALUE_TYPE(kCaptivePortalFeature)},
Mike Doughertyc20eefa2018-02-20 19:20:33170 {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName,
171 flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos,
172 FEATURE_VALUE_TYPE(kCaptivePortalMetrics)},
Cooper Knaak1e026562017-07-26 05:22:28173 {"in-product-help-demo-mode-choice",
174 flag_descriptions::kInProductHelpDemoModeName,
175 flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos,
176 FEATURE_WITH_PARAMS_VALUE_TYPE(
Tommy Nyquistc1d6dea12017-07-26 20:37:23177 feature_engagement::kIPHDemoMode,
178 feature_engagement::kIPHDemoModeChoiceVariations,
Marc Treib2752e8b2017-08-04 14:12:09179 "IPH_DemoMode")},
180 {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName,
181 flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos,
Marc Treib5fc99e1f2017-11-08 12:19:18182 MULTI_VALUE_TYPE(kUseDdljsonApiChoices)},
Justin Donnelly33d712e2017-08-23 21:32:51183 {"omnibox-ui-elide-suggestion-url-after-host",
184 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostName,
185 flag_descriptions::kOmniboxUIElideSuggestionUrlAfterHostDescription,
186 flags_ui::kOsIos,
187 FEATURE_VALUE_TYPE(omnibox::kUIExperimentElideSuggestionUrlAfterHost)},
Jean-François Geyelin30be5912017-08-25 12:05:38188#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
189 {"drag_and_drop", flag_descriptions::kDragAndDropName,
190 flag_descriptions::kDragAndDropDescription, flags_ui::kOsIos,
Rohit Rao6a3a481d2017-09-25 19:31:41191 FEATURE_VALUE_TYPE(kDragAndDrop)},
Jean-François Geyelin30be5912017-08-25 12:05:38192#endif
Rohit Rao6a3a481d2017-09-25 19:31:41193 {"tab_switcher_presents_bvc",
194 flag_descriptions::kTabSwitcherPresentsBVCName,
195 flag_descriptions::kTabSwitcherPresentsBVCDescription, flags_ui::kOsIos,
Jean-François Geyelined4cde72017-10-11 11:34:50196 FEATURE_VALUE_TYPE(kTabSwitcherPresentsBVC)},
Louis Romerod11747a2017-10-20 20:10:35197 {"external-search", flag_descriptions::kExternalSearchName,
198 flag_descriptions::kExternalSearchDescription, flags_ui::kOsIos,
199 FEATURE_VALUE_TYPE(kExternalSearch)},
sczsa0c91942017-10-26 18:39:59200 {"history-batch-updates-filter",
201 flag_descriptions::kHistoryBatchUpdatesFilterName,
202 flag_descriptions::kHistoryBatchUpdatesFilterDescription, flags_ui::kOsIos,
203 FEATURE_VALUE_TYPE(kHistoryBatchUpdatesFilter)},
Danyao Wang34da6ff2017-10-30 15:16:56204 {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName,
205 flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos,
206 FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)},
Eugene But88083f42018-01-30 17:51:37207 {"new-file-download", flag_descriptions::kNewFileDownloadName,
208 flag_descriptions::kNewFileDownloadDescription, flags_ui::kOsIos,
209 FEATURE_VALUE_TYPE(web::features::kNewFileDownload)},
Eugene Buta23c8fb2018-05-14 20:40:23210 {"web-error-pages", flag_descriptions::kWebErrorPagesName,
211 flag_descriptions::kWebErrorPagesDescription, flags_ui::kOsIos,
212 FEATURE_VALUE_TYPE(web::features::kWebErrorPages)},
sczsdc2e8e02018-01-09 18:39:32213 {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName,
214 flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos,
215 FEATURE_VALUE_TYPE(kMemexTabSwitcher)},
nikhild70e7cb52017-12-26 07:38:20216 {"PasswordExport", flag_descriptions::kPasswordExportName,
Ioana Pandeled14ce9e2017-11-28 14:41:46217 flag_descriptions::kPasswordExportDescription, flags_ui::kOsIos,
mrefaata6501d92017-12-11 19:50:50218 FEATURE_VALUE_TYPE(password_manager::features::kPasswordExport)},
219 {"wk-http-system-cookie-store",
220 flag_descriptions::kWKHTTPSystemCookieStoreName,
221 flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
Mohamad Ahmadic4df81f2017-12-20 04:41:59222 FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
Moe Ahmadic3fd7cd2018-05-11 21:40:22223 {"enable-autofill-credit-card-upload",
224 flag_descriptions::kAutofillCreditCardUploadName,
225 flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos,
226 FEATURE_VALUE_TYPE(autofill::kAutofillUpstream)},
Lakshmi Kumar Dabbiruee22004e2018-06-01 01:52:27227 {"enable-autofill-credit-card-downstream-google-pay-branding",
228 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSName,
229 flag_descriptions::kAutofillDownstreamUseGooglePayBrandingOniOSDescription,
230 flags_ui::kOsIos,
231 FEATURE_VALUE_TYPE(
232 autofill::features::kAutofillDownstreamUseGooglePayBrandingOniOS)},
Moe Ahmadi3fd9f202018-05-10 17:39:24233 {"enable-autofill-credit-card-upload-google-pay-branding",
234 flag_descriptions::kAutofillUpstreamUseGooglePayBrandingOnMobileName,
235 flag_descriptions::
236 kAutofillUpstreamUseGooglePayBrandingOnMobileDescription,
237 flags_ui::kOsIos,
238 FEATURE_VALUE_TYPE(
239 autofill::features::kAutofillUpstreamUseGooglePayBrandingOnMobile)},
Mohamad Ahmadic4df81f2017-12-20 04:41:59240 {"show-autofill-type-predictions",
241 flag_descriptions::kShowAutofillTypePredictionsName,
242 flag_descriptions::kShowAutofillTypePredictionsDescription,
243 flags_ui::kOsIos,
Gauthier Ambardcfd85182018-01-05 10:37:46244 FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)},
Olivier Robin3d60411622018-02-23 10:03:22245 {"autofill-ios-delay-between-fields",
246 flag_descriptions::kAutofillIOSDelayBetweenFieldsName,
247 flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription,
248 flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)},
Justin Cohen2d81c582018-01-22 14:46:44249 {"ui-refresh-phase-1", flag_descriptions::kUIRefreshPhase1Name,
250 flag_descriptions::kUIRefreshPhase1Description, flags_ui::kOsIos,
251 FEATURE_VALUE_TYPE(kUIRefreshPhase1)},
sczs44d54dc2018-03-12 15:56:02252 {"collections-ui-reboot", flag_descriptions::kCollectionsUIRebootName,
253 flag_descriptions::kCollectionsUIRebootDescription, flags_ui::kOsIos,
254 FEATURE_VALUE_TYPE(kCollectionsUIReboot)},
Peter K. Lee1e176752018-05-04 20:48:09255 {"infobars-ui-reboot", flag_descriptions::kInfobarsUIRebootName,
256 flag_descriptions::kInfobarsUIRebootDescription, flags_ui::kOsIos,
257 FEATURE_VALUE_TYPE(kInfobarsUIReboot)},
Mike Dougherty5f188d92018-02-02 07:10:35258 {"context-menu-element-post-message",
259 flag_descriptions::kContextMenuElementPostMessageName,
260 flag_descriptions::kContextMenuElementPostMessageDescription,
261 flags_ui::kOsIos,
262 FEATURE_VALUE_TYPE(web::features::kContextMenuElementPostMessage)},
Daniel Blakemore72387d32018-02-13 23:45:55263 {"mailto-handling-google-ui",
264 flag_descriptions::kMailtoHandlingWithGoogleUIName,
265 flag_descriptions::kMailtoHandlingWithGoogleUIDescription,
266 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)},
Peter K. Lee88137d52018-02-20 19:59:39267 {"feedback-kit-v2", flag_descriptions::kFeedbackKitV2Name,
268 flag_descriptions::kFeedbackKitV2Description, flags_ui::kOsIos,
269 FEATURE_VALUE_TYPE(kFeedbackKitV2)},
Peter K. Lee302c8b82018-03-29 23:54:51270 {"feedback-kit-v2-sso-service",
271 flag_descriptions::kFeedbackKitV2WithSSOServiceName,
272 flag_descriptions::kFeedbackKitV2WithSSOServiceDescription,
273 flags_ui::kOsIos, FEATURE_VALUE_TYPE(kFeedbackKitV2WithSSOService)},
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,
284 FEATURE_VALUE_TYPE(signin::kUnifiedConsent)},
sebsg93dc01c2018-04-05 16:42:48285 {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName,
286 flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos,
287 FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)},
Moe Ahmadid3ddfcb2018-04-20 19:51:08288 {"autofill-restrict-formless-form-extraction",
289 flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName,
290 flag_descriptions::
291 kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription,
292 flags_ui::kOsIos,
293 FEATURE_VALUE_TYPE(
294 autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)},
[email protected]dbcd4d52018-04-10 09:17:58295 {"ui-refresh-location-bar", flag_descriptions::kUIRefreshLocationBarName,
296 flag_descriptions::kUIRefreshLocationBarDescription, flags_ui::kOsIos,
297 FEATURE_VALUE_TYPE(kUIRefreshLocationBar)},
Kurt Horimotodc33af32018-05-01 01:39:14298 {"fullscreen-viewport-adjustment-experiment",
299 flag_descriptions::kFullscreenViewportAdjustmentExperimentName,
300 flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription,
301 flags_ui::kOsIos,
302 MULTI_VALUE_TYPE(
303 fullscreen::features::kViewportAdjustmentExperimentChoices)},
Roger McFarlane1a37d7b2018-04-20 22:45:19304 {"autofill-enforce-min-required-fields-for-heuristics",
305 flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName,
306 flag_descriptions::
307 kAutofillEnforceMinRequiredFieldsForHeuristicsDescription,
308 flags_ui::kOsIos,
309 FEATURE_VALUE_TYPE(
310 autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)},
311 {"autofill-enforce-min-required-fields-for-query",
312 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName,
313 flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription,
314 flags_ui::kOsIos,
315 FEATURE_VALUE_TYPE(
316 autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)},
317 {"autofill-enforce-min-required-fields-for-upload",
318 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName,
319 flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription,
320 flags_ui::kOsIos,
321 FEATURE_VALUE_TYPE(
322 autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)},
Gauthier Ambard4417f852018-04-26 14:24:32323 {"browser-container-fullscreen",
324 flag_descriptions::kBrowserContainerFullscreenName,
325 flag_descriptions::kBrowserContainerFullscreenDescription,
Gauthier Ambard5d7627282018-05-18 08:20:07326 flags_ui::kOsIos,
327 FEATURE_VALUE_TYPE(web::features::kBrowserContainerFullscreen)},
Roger McFarlane2eceba982018-05-18 01:37:11328 {"autofill-cache-query-responses",
329 flag_descriptions::kAutofillCacheQueryResponsesName,
330 flag_descriptions::kAutofillCacheQueryResponsesDescription,
331 flags_ui::kOsIos,
332 FEATURE_VALUE_TYPE(autofill::features::kAutofillCacheQueryResponses)},
Javier Ernesto Flores Robles23c71a7d2018-06-01 09:51:17333 {"autofill-manual-fallback", flag_descriptions::kAutofillManualFallbackName,
334 flag_descriptions::kAutofillManualFallbackDescription, flags_ui::kOsIos,
335 FEATURE_VALUE_TYPE(autofill::features::kAutofillManualFallback)},
Yi Su392b3032018-06-05 07:26:47336 {"webpage-text-accessibility",
337 flag_descriptions::kWebPageTextAccessibilityName,
338 flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
339 FEATURE_VALUE_TYPE(web::kWebPageTextAccessibility)},
Gauthier Ambardcfd85182018-01-05 10:37:46340};
sdefresne14900ee2015-11-27 14:43:21341
342// Add all switches from experimental flags to |command_line|.
343void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
344 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
345
sdefresne14900ee2015-11-27 14:43:21346 // Set the UA flag if UseMobileSafariUA is enabled.
347 if ([defaults boolForKey:@"UseMobileSafariUA"]) {
348 // Safari uses "Vesion/", followed by the OS version excluding bugfix, where
349 // Chrome puts its product token.
avi571943672015-12-22 02:12:49350 int32_t major = 0;
351 int32_t minor = 0;
352 int32_t bugfix = 0;
sdefresne14900ee2015-11-27 14:43:21353 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
354 std::string product = base::StringPrintf("Version/%d.%d", major, minor);
355
356 command_line->AppendSwitchASCII(switches::kUserAgent,
357 web::BuildUserAgentFromProduct(product));
358 }
359
360 // Freeform commandline flags. These are added last, so that any flags added
361 // earlier in this function take precedence.
362 if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) {
363 base::CommandLine::StringVector flags;
364 // Append an empty "program" argument.
365 flags.push_back("");
366
367 // The number of flags corresponds to the number of text fields in
368 // Experimental.plist.
369 const int kNumFreeformFlags = 5;
370 for (int i = 1; i <= kNumFreeformFlags; ++i) {
371 NSString* key =
372 [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i];
373 NSString* flag = [defaults stringForKey:key];
374 if ([flag length]) {
375 flags.push_back(base::SysNSStringToUTF8(flag));
376 }
377 }
378
379 base::CommandLine temp_command_line(flags);
380 command_line->AppendArguments(temp_command_line, false);
381 }
msardafc76f662017-02-24 12:46:28382
justincohendacc85d2017-06-28 23:34:10383 // Populate command line flag for 3rd party keyboard omnibox workaround.
384 NSString* enableThirdPartyKeyboardWorkaround =
385 [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"];
386 if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) {
387 command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround);
388 } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) {
389 command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround);
390 }
391
msardafc76f662017-02-24 12:46:28392 ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings(
393 defaults, command_line);
sdefresne14900ee2015-11-27 14:43:21394}
395
396bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
397 return false;
398}
399
400class FlagsStateSingleton {
401 public:
402 FlagsStateSingleton()
403 : flags_state_(kFeatureEntries, arraysize(kFeatureEntries)) {}
404 ~FlagsStateSingleton() {}
405
406 static FlagsStateSingleton* GetInstance() {
407 return base::Singleton<FlagsStateSingleton>::get();
408 }
409
410 static flags_ui::FlagsState* GetFlagsState() {
411 return &GetInstance()->flags_state_;
412 }
413
414 private:
415 flags_ui::FlagsState flags_state_;
416
417 DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton);
418};
419} // namespace
420
421void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
422 base::CommandLine* command_line) {
Gregory Chatzinoff31305112017-12-20 21:56:02423 AppendSwitchesFromExperimentalSettings(command_line);
sdefresne14900ee2015-11-27 14:43:21424 FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches(
sdefresnec9763902015-12-02 10:30:11425 flags_storage, command_line, flags_ui::kAddSentinels,
Gregory Chatzinofff6523722017-11-21 01:33:53426 switches::kEnableFeatures, switches::kDisableFeatures);
sdefresne14900ee2015-11-27 14:43:21427}
428
jkrcalbf073372016-07-29 07:21:31429std::vector<std::string> RegisterAllFeatureVariationParameters(
430 flags_ui::FlagsStorage* flags_storage,
431 base::FeatureList* feature_list) {
432 return FlagsStateSingleton::GetFlagsState()
433 ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);
434}
435
sdefresne14900ee2015-11-27 14:43:21436void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
437 flags_ui::FlagAccess access,
438 base::ListValue* supported_entries,
439 base::ListValue* unsupported_entries) {
440 FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries(
441 flags_storage, access, supported_entries, unsupported_entries,
442 base::Bind(&SkipConditionalFeatureEntry));
443}
444
445void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
446 const std::string& internal_name,
447 bool enable) {
448 FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled(
449 flags_storage, internal_name, enable);
450}
451
452void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) {
453 FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage);
454}
455
456namespace testing {
457
458const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) {
459 *count = arraysize(kFeatureEntries);
460 return kFeatureEntries;
461}
462
463} // namespace testing