sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 1 | // 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 | |
avi | 57194367 | 2015-12-22 02:12:49 | [diff] [blame] | 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 12 | #import <UIKit/UIKit.h> |
| 13 | |
Gregory Chatzinoff | f652372 | 2017-11-21 01:33:53 | [diff] [blame] | 14 | #include "base/base_switches.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 15 | #include "base/bind.h" |
| 16 | #include "base/command_line.h" |
| 17 | #include "base/logging.h" |
avi | 57194367 | 2015-12-22 02:12:49 | [diff] [blame] | 18 | #include "base/macros.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 19 | #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 Ahmadi | c3fd7cd | 2018-05-11 21:40:22 | [diff] [blame^] | 23 | #include "components/autofill/core/browser/autofill_experiments.h" |
Mohamad Ahmadi | c4df81f | 2017-12-20 04:41:59 | [diff] [blame] | 24 | #include "components/autofill/core/common/autofill_features.h" |
Olivier Robin | 3d6041162 | 2018-02-23 10:03:22 | [diff] [blame] | 25 | #include "components/autofill/ios/browser/autofill_switches.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 26 | #include "components/dom_distiller/core/dom_distiller_switches.h" |
Tommy Nyquist | c1d6dea1 | 2017-07-26 20:37:23 | [diff] [blame] | 27 | #include "components/feature_engagement/public/feature_constants.h" |
| 28 | #include "components/feature_engagement/public/feature_list.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 29 | #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" |
noyau | 4cfb133 | 2016-10-25 17:05:42 | [diff] [blame] | 33 | #include "components/ntp_tiles/switches.h" |
Justin Donnelly | 33d712e | 2017-08-23 21:32:51 | [diff] [blame] | 34 | #include "components/omnibox/browser/omnibox_field_trial.h" |
Ioana Pandele | d14ce9e | 2017-11-28 14:41:46 | [diff] [blame] | 35 | #include "components/password_manager/core/common/password_manager_features.h" |
mathp | 9b4c11d | 2017-07-06 20:24:13 | [diff] [blame] | 36 | #include "components/payments/core/features.h" |
Marc Treib | 5fc99e1f | 2017-11-08 12:19:18 | [diff] [blame] | 37 | #include "components/search_provider_logos/switches.h" |
Emily Stark | bafa906 | 2017-12-27 15:22:46 | [diff] [blame] | 38 | #include "components/security_state/core/features.h" |
Jérôme Lebel | fa6c5ae | 2018-03-29 13:46:57 | [diff] [blame] | 39 | #include "components/signin/core/browser/profile_management_switches.h" |
David Roger | a6c8812 | 2017-10-25 13:02:46 | [diff] [blame] | 40 | #include "components/signin/core/browser/signin_switches.h" |
sdefresne | 3657978 | 2016-02-05 11:08:25 | [diff] [blame] | 41 | #include "components/strings/grit/components_strings.h" |
Sylvain Defresne | ae6987e | 2018-03-01 13:21:40 | [diff] [blame] | 42 | #include "ios/chrome/browser/browsing_data/browsing_data_features.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 43 | #include "ios/chrome/browser/chrome_switches.h" |
Jean-François Geyelin | 30be591 | 2017-08-25 12:05:38 | [diff] [blame] | 44 | #include "ios/chrome/browser/drag_and_drop/drag_and_drop_flag.h" |
vabr | 0215a8e | 2017-03-28 12:47:34 | [diff] [blame] | 45 | #include "ios/chrome/browser/ios_chrome_flag_descriptions.h" |
mrefaat | 390f99c0d | 2018-05-10 19:44:24 | [diff] [blame] | 46 | #include "ios/chrome/browser/itunes_urls/itunes_urls_flag.h" |
Daniel Blakemore | 72387d3 | 2018-02-13 23:45:55 | [diff] [blame] | 47 | #include "ios/chrome/browser/mailto/features.h" |
Mike Dougherty | a5e5ad5 | 2017-08-05 00:11:58 | [diff] [blame] | 48 | #include "ios/chrome/browser/ssl/captive_portal_features.h" |
Louis Romero | d11747a | 2017-10-20 20:10:35 | [diff] [blame] | 49 | #include "ios/chrome/browser/ui/external_search/features.h" |
Kurt Horimoto | 4da682b02 | 2018-04-12 07:43:35 | [diff] [blame] | 50 | #import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h" |
sczs | a0c9194 | 2017-10-26 18:39:59 | [diff] [blame] | 51 | #import "ios/chrome/browser/ui/history/history_base_feature.h" |
Rohit Rao | 6a3a481d | 2017-09-25 19:31:41 | [diff] [blame] | 52 | #include "ios/chrome/browser/ui/main/main_feature_flags.h" |
Gauthier Ambard | 2746a4b | 2018-03-20 12:52:16 | [diff] [blame] | 53 | #import "ios/chrome/browser/ui/popup_menu/popup_menu_flags.h" |
sczs | 6ca1d26 | 2017-10-30 20:27:13 | [diff] [blame] | 54 | #import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_base_feature.h" |
Justin Cohen | 2d81c58 | 2018-01-22 14:46:44 | [diff] [blame] | 55 | #include "ios/chrome/browser/ui/ui_feature_flags.h" |
Peter K. Lee | 88137d5 | 2018-02-20 19:59:39 | [diff] [blame] | 56 | #include "ios/chrome/browser/ui/user_feedback_features.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 57 | #include "ios/chrome/grit/ios_strings.h" |
msarda | fc76f66 | 2017-02-24 12:46:28 | [diff] [blame] | 58 | #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
Danyao Wang | 34da6ff | 2017-10-30 15:16:56 | [diff] [blame] | 59 | #include "ios/web/public/features.h" |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 60 | #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" |
vitaliii | 489217aa | 2017-01-30 14:50:22 | [diff] [blame] | 65 | #endif |
stkhapugin | c1be179 | 2016-12-13 14:30:53 | [diff] [blame] | 66 | |
| 67 | #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 68 | #error "This file requires ARC support." |
| 69 | #endif |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 70 | |
elawrence | 816f6790e | 2017-06-16 18:19:28 | [diff] [blame] | 71 | using flags_ui::FeatureEntry; |
| 72 | |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 73 | namespace { |
Emily Stark | bafa906 | 2017-12-27 15:22:46 | [diff] [blame] | 74 | |
| 75 | const FeatureEntry::FeatureParam kMarkHttpAsDangerous[] = { |
| 76 | {security_state::features::kMarkHttpAsFeatureParameterName, |
| 77 | security_state::features::kMarkHttpAsParameterDangerous}}; |
| 78 | const FeatureEntry::FeatureParam kMarkHttpAsWarning[] = { |
| 79 | {security_state::features::kMarkHttpAsFeatureParameterName, |
| 80 | security_state::features::kMarkHttpAsParameterWarning}}; |
| 81 | const FeatureEntry::FeatureParam kMarkHttpAsWarningAndDangerousOnFormEdits[] = { |
| 82 | {security_state::features::kMarkHttpAsFeatureParameterName, |
| 83 | security_state::features:: |
| 84 | kMarkHttpAsParameterWarningAndDangerousOnFormEdits}}; |
| 85 | const FeatureEntry::FeatureParam |
| 86 | kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[] = { |
| 87 | {security_state::features::kMarkHttpAsFeatureParameterName, |
| 88 | security_state::features:: |
| 89 | kMarkHttpAsParameterWarningAndDangerousOnPasswordsAndCreditCards}}; |
| 90 | |
| 91 | const 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}}; |
elawrence | 816f6790e | 2017-06-16 18:19:28 | [diff] [blame] | 104 | |
Marc Treib | 5fc99e1f | 2017-11-08 12:19:18 | [diff] [blame] | 105 | const 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 Treib | 2752e8b | 2017-08-04 14:12:09 | [diff] [blame] | 118 | |
Olivier Robin | 3d6041162 | 2018-02-23 10:03:22 | [diff] [blame] | 119 | const 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 Knaak | 1e02656 | 2017-07-26 05:22:28 | [diff] [blame] | 131 | // To add a new entry, add to the end of kFeatureEntries. There are four |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 132 | // distinct types of entries: |
Cooper Knaak | 1e02656 | 2017-07-26 05:22:28 | [diff] [blame] | 133 | // . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the |
| 134 | // default value for this feature. Use the ENABLE_DISABLE_VALUE_TYPE |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 135 | // 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 Knaak | 1e02656 | 2017-07-26 05:22:28 | [diff] [blame] | 140 | // . 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 | // |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 151 | // 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. |
| 154 | const flags_ui::FeatureEntry kFeatureEntries[] = { |
Emily Stark | bafa906 | 2017-12-27 15:22:46 | [diff] [blame] | 155 | {"enable-mark-http-as", flag_descriptions::kMarkHttpAsName, |
elawrence | 816f6790e | 2017-06-16 18:19:28 | [diff] [blame] | 156 | flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos, |
Emily Stark | bafa906 | 2017-12-27 15:22:46 | [diff] [blame] | 157 | FEATURE_WITH_PARAMS_VALUE_TYPE( |
| 158 | security_state::features::kMarkHttpAsFeature, |
| 159 | kMarkHttpAsFeatureVariations, |
| 160 | "MarkHttpAs")}, |
mathp | 9b4c11d | 2017-07-06 20:24:13 | [diff] [blame] | 161 | {"web-payments", flag_descriptions::kWebPaymentsName, |
| 162 | flag_descriptions::kWebPaymentsDescription, flags_ui::kOsIos, |
| 163 | FEATURE_VALUE_TYPE(payments::features::kWebPayments)}, |
Randall Raymond | 59766ac | 2017-08-09 16:28:58 | [diff] [blame] | 164 | {"web-payments-native-apps", flag_descriptions::kWebPaymentsNativeAppsName, |
| 165 | flag_descriptions::kWebPaymentsNativeAppsDescription, flags_ui::kOsIos, |
| 166 | FEATURE_VALUE_TYPE(payments::features::kWebPaymentsNativeApps)}, |
Mike Dougherty | a5e5ad5 | 2017-08-05 00:11:58 | [diff] [blame] | 167 | {"ios-captive-portal", flag_descriptions::kCaptivePortalName, |
| 168 | flag_descriptions::kCaptivePortalDescription, flags_ui::kOsIos, |
| 169 | FEATURE_VALUE_TYPE(kCaptivePortalFeature)}, |
Mike Dougherty | c20eefa | 2018-02-20 19:20:33 | [diff] [blame] | 170 | {"ios-captive-portal-metrics", flag_descriptions::kCaptivePortalMetricsName, |
| 171 | flag_descriptions::kCaptivePortalMetricsDescription, flags_ui::kOsIos, |
| 172 | FEATURE_VALUE_TYPE(kCaptivePortalMetrics)}, |
Cooper Knaak | 1e02656 | 2017-07-26 05:22:28 | [diff] [blame] | 173 | {"in-product-help-demo-mode-choice", |
| 174 | flag_descriptions::kInProductHelpDemoModeName, |
| 175 | flag_descriptions::kInProductHelpDemoModeDescription, flags_ui::kOsIos, |
| 176 | FEATURE_WITH_PARAMS_VALUE_TYPE( |
Tommy Nyquist | c1d6dea1 | 2017-07-26 20:37:23 | [diff] [blame] | 177 | feature_engagement::kIPHDemoMode, |
| 178 | feature_engagement::kIPHDemoModeChoiceVariations, |
Marc Treib | 2752e8b | 2017-08-04 14:12:09 | [diff] [blame] | 179 | "IPH_DemoMode")}, |
| 180 | {"use-ddljson-api", flag_descriptions::kUseDdljsonApiName, |
| 181 | flag_descriptions::kUseDdljsonApiDescription, flags_ui::kOsIos, |
Marc Treib | 5fc99e1f | 2017-11-08 12:19:18 | [diff] [blame] | 182 | MULTI_VALUE_TYPE(kUseDdljsonApiChoices)}, |
Justin Donnelly | 33d712e | 2017-08-23 21:32:51 | [diff] [blame] | 183 | {"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 Geyelin | 30be591 | 2017-08-25 12:05:38 | [diff] [blame] | 188 | #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 Rao | 6a3a481d | 2017-09-25 19:31:41 | [diff] [blame] | 191 | FEATURE_VALUE_TYPE(kDragAndDrop)}, |
Jean-François Geyelin | 30be591 | 2017-08-25 12:05:38 | [diff] [blame] | 192 | #endif |
Rohit Rao | 6a3a481d | 2017-09-25 19:31:41 | [diff] [blame] | 193 | {"tab_switcher_presents_bvc", |
| 194 | flag_descriptions::kTabSwitcherPresentsBVCName, |
| 195 | flag_descriptions::kTabSwitcherPresentsBVCDescription, flags_ui::kOsIos, |
Jean-François Geyelin | ed4cde7 | 2017-10-11 11:34:50 | [diff] [blame] | 196 | FEATURE_VALUE_TYPE(kTabSwitcherPresentsBVC)}, |
Louis Romero | d11747a | 2017-10-20 20:10:35 | [diff] [blame] | 197 | {"external-search", flag_descriptions::kExternalSearchName, |
| 198 | flag_descriptions::kExternalSearchDescription, flags_ui::kOsIos, |
| 199 | FEATURE_VALUE_TYPE(kExternalSearch)}, |
sczs | a0c9194 | 2017-10-26 18:39:59 | [diff] [blame] | 200 | {"history-batch-updates-filter", |
| 201 | flag_descriptions::kHistoryBatchUpdatesFilterName, |
| 202 | flag_descriptions::kHistoryBatchUpdatesFilterDescription, flags_ui::kOsIos, |
| 203 | FEATURE_VALUE_TYPE(kHistoryBatchUpdatesFilter)}, |
Danyao Wang | 34da6ff | 2017-10-30 15:16:56 | [diff] [blame] | 204 | {"slim-navigation-manager", flag_descriptions::kSlimNavigationManagerName, |
| 205 | flag_descriptions::kSlimNavigationManagerDescription, flags_ui::kOsIos, |
| 206 | FEATURE_VALUE_TYPE(web::features::kSlimNavigationManager)}, |
Eugene But | 88083f4 | 2018-01-30 17:51:37 | [diff] [blame] | 207 | {"new-file-download", flag_descriptions::kNewFileDownloadName, |
| 208 | flag_descriptions::kNewFileDownloadDescription, flags_ui::kOsIos, |
| 209 | FEATURE_VALUE_TYPE(web::features::kNewFileDownload)}, |
sczs | dc2e8e0 | 2018-01-09 18:39:32 | [diff] [blame] | 210 | {"memex-tab-switcher", flag_descriptions::kMemexTabSwitcherName, |
| 211 | flag_descriptions::kMemexTabSwitcherDescription, flags_ui::kOsIos, |
| 212 | FEATURE_VALUE_TYPE(kMemexTabSwitcher)}, |
nikhil | d70e7cb5 | 2017-12-26 07:38:20 | [diff] [blame] | 213 | {"PasswordExport", flag_descriptions::kPasswordExportName, |
Ioana Pandele | d14ce9e | 2017-11-28 14:41:46 | [diff] [blame] | 214 | flag_descriptions::kPasswordExportDescription, flags_ui::kOsIos, |
mrefaat | a6501d9 | 2017-12-11 19:50:50 | [diff] [blame] | 215 | FEATURE_VALUE_TYPE(password_manager::features::kPasswordExport)}, |
| 216 | {"wk-http-system-cookie-store", |
| 217 | flag_descriptions::kWKHTTPSystemCookieStoreName, |
| 218 | flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos, |
Mohamad Ahmadi | c4df81f | 2017-12-20 04:41:59 | [diff] [blame] | 219 | FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)}, |
Moe Ahmadi | c3fd7cd | 2018-05-11 21:40:22 | [diff] [blame^] | 220 | {"enable-autofill-credit-card-upload", |
| 221 | flag_descriptions::kAutofillCreditCardUploadName, |
| 222 | flag_descriptions::kAutofillCreditCardUploadDescription, flags_ui::kOsIos, |
| 223 | FEATURE_VALUE_TYPE(autofill::kAutofillUpstream)}, |
Moe Ahmadi | 3fd9f20 | 2018-05-10 17:39:24 | [diff] [blame] | 224 | {"enable-autofill-credit-card-upload-google-pay-branding", |
| 225 | flag_descriptions::kAutofillUpstreamUseGooglePayBrandingOnMobileName, |
| 226 | flag_descriptions:: |
| 227 | kAutofillUpstreamUseGooglePayBrandingOnMobileDescription, |
| 228 | flags_ui::kOsIos, |
| 229 | FEATURE_VALUE_TYPE( |
| 230 | autofill::features::kAutofillUpstreamUseGooglePayBrandingOnMobile)}, |
Mohamad Ahmadi | c4df81f | 2017-12-20 04:41:59 | [diff] [blame] | 231 | {"show-autofill-type-predictions", |
| 232 | flag_descriptions::kShowAutofillTypePredictionsName, |
| 233 | flag_descriptions::kShowAutofillTypePredictionsDescription, |
| 234 | flags_ui::kOsIos, |
Gauthier Ambard | cfd8518 | 2018-01-05 10:37:46 | [diff] [blame] | 235 | FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)}, |
Olivier Robin | 3d6041162 | 2018-02-23 10:03:22 | [diff] [blame] | 236 | {"autofill-ios-delay-between-fields", |
| 237 | flag_descriptions::kAutofillIOSDelayBetweenFieldsName, |
| 238 | flag_descriptions::kAutofillIOSDelayBetweenFieldsDescription, |
| 239 | flags_ui::kOsIos, MULTI_VALUE_TYPE(kAutofillIOSDelayBetweenFieldsChoices)}, |
Justin Cohen | 2d81c58 | 2018-01-22 14:46:44 | [diff] [blame] | 240 | {"ui-refresh-phase-1", flag_descriptions::kUIRefreshPhase1Name, |
| 241 | flag_descriptions::kUIRefreshPhase1Description, flags_ui::kOsIos, |
| 242 | FEATURE_VALUE_TYPE(kUIRefreshPhase1)}, |
sczs | 44d54dc | 2018-03-12 15:56:02 | [diff] [blame] | 243 | {"collections-ui-reboot", flag_descriptions::kCollectionsUIRebootName, |
| 244 | flag_descriptions::kCollectionsUIRebootDescription, flags_ui::kOsIos, |
| 245 | FEATURE_VALUE_TYPE(kCollectionsUIReboot)}, |
Peter K. Lee | 1e17675 | 2018-05-04 20:48:09 | [diff] [blame] | 246 | {"infobars-ui-reboot", flag_descriptions::kInfobarsUIRebootName, |
| 247 | flag_descriptions::kInfobarsUIRebootDescription, flags_ui::kOsIos, |
| 248 | FEATURE_VALUE_TYPE(kInfobarsUIReboot)}, |
Mike Dougherty | 5f188d9 | 2018-02-02 07:10:35 | [diff] [blame] | 249 | {"context-menu-element-post-message", |
| 250 | flag_descriptions::kContextMenuElementPostMessageName, |
| 251 | flag_descriptions::kContextMenuElementPostMessageDescription, |
| 252 | flags_ui::kOsIos, |
| 253 | FEATURE_VALUE_TYPE(web::features::kContextMenuElementPostMessage)}, |
Daniel Blakemore | 72387d3 | 2018-02-13 23:45:55 | [diff] [blame] | 254 | {"mailto-handling-google-ui", |
| 255 | flag_descriptions::kMailtoHandlingWithGoogleUIName, |
| 256 | flag_descriptions::kMailtoHandlingWithGoogleUIDescription, |
| 257 | flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)}, |
Peter K. Lee | 88137d5 | 2018-02-20 19:59:39 | [diff] [blame] | 258 | {"feedback-kit-v2", flag_descriptions::kFeedbackKitV2Name, |
| 259 | flag_descriptions::kFeedbackKitV2Description, flags_ui::kOsIos, |
| 260 | FEATURE_VALUE_TYPE(kFeedbackKitV2)}, |
Peter K. Lee | 302c8b8 | 2018-03-29 23:54:51 | [diff] [blame] | 261 | {"feedback-kit-v2-sso-service", |
| 262 | flag_descriptions::kFeedbackKitV2WithSSOServiceName, |
| 263 | flag_descriptions::kFeedbackKitV2WithSSOServiceDescription, |
| 264 | flags_ui::kOsIos, FEATURE_VALUE_TYPE(kFeedbackKitV2WithSSOService)}, |
Sylvain Defresne | ae6987e | 2018-03-01 13:21:40 | [diff] [blame] | 265 | {"new-clear-browsing-data-ui", |
| 266 | flag_descriptions::kNewClearBrowsingDataUIName, |
| 267 | flag_descriptions::kNewClearBrowsingDataUIDescription, flags_ui::kOsIos, |
| 268 | FEATURE_VALUE_TYPE(kNewClearBrowsingDataUI)}, |
Gauthier Ambard | 2746a4b | 2018-03-20 12:52:16 | [diff] [blame] | 269 | {"new-tools_menu", flag_descriptions::kNewToolsMenuName, |
| 270 | flag_descriptions::kNewToolsMenuDescription, flags_ui::kOsIos, |
| 271 | FEATURE_VALUE_TYPE(kNewToolsMenu)}, |
mrefaat | 390f99c0d | 2018-05-10 19:44:24 | [diff] [blame] | 272 | {"itunes-urls-store-kit-handling", |
| 273 | flag_descriptions::kITunesUrlsStoreKitHandlingName, |
| 274 | flag_descriptions::kITunesUrlsStoreKitHandlingDescription, |
| 275 | flags_ui::kOsIos, FEATURE_VALUE_TYPE(kITunesUrlsStoreKitHandling)}, |
Jérôme Lebel | fa6c5ae | 2018-03-29 13:46:57 | [diff] [blame] | 276 | {"unified-consent", flag_descriptions::kUnifiedConsentName, |
| 277 | flag_descriptions::kUnifiedConsentDescription, flags_ui::kOsIos, |
| 278 | FEATURE_VALUE_TYPE(signin::kUnifiedConsent)}, |
sebsg | 93dc01c | 2018-04-05 16:42:48 | [diff] [blame] | 279 | {"autofill-dynamic-forms", flag_descriptions::kAutofillDynamicFormsName, |
| 280 | flag_descriptions::kAutofillDynamicFormsDescription, flags_ui::kOsIos, |
| 281 | FEATURE_VALUE_TYPE(autofill::features::kAutofillDynamicForms)}, |
Moe Ahmadi | d3ddfcb | 2018-04-20 19:51:08 | [diff] [blame] | 282 | {"autofill-restrict-formless-form-extraction", |
| 283 | flag_descriptions::kAutofillRestrictUnownedFieldsToFormlessCheckoutName, |
| 284 | flag_descriptions:: |
| 285 | kAutofillRestrictUnownedFieldsToFormlessCheckoutDescription, |
| 286 | flags_ui::kOsIos, |
| 287 | FEATURE_VALUE_TYPE( |
| 288 | autofill::features::kAutofillRestrictUnownedFieldsToFormlessCheckout)}, |
[email protected] | dbcd4d5 | 2018-04-10 09:17:58 | [diff] [blame] | 289 | {"ui-refresh-location-bar", flag_descriptions::kUIRefreshLocationBarName, |
| 290 | flag_descriptions::kUIRefreshLocationBarDescription, flags_ui::kOsIos, |
| 291 | FEATURE_VALUE_TYPE(kUIRefreshLocationBar)}, |
Kurt Horimoto | dc33af3 | 2018-05-01 01:39:14 | [diff] [blame] | 292 | {"fullscreen-viewport-adjustment-experiment", |
| 293 | flag_descriptions::kFullscreenViewportAdjustmentExperimentName, |
| 294 | flag_descriptions::kFullscreenViewportAdjustmentExperimentDescription, |
| 295 | flags_ui::kOsIos, |
| 296 | MULTI_VALUE_TYPE( |
| 297 | fullscreen::features::kViewportAdjustmentExperimentChoices)}, |
Roger McFarlane | 1a37d7b | 2018-04-20 22:45:19 | [diff] [blame] | 298 | {"autofill-enforce-min-required-fields-for-heuristics", |
| 299 | flag_descriptions::kAutofillEnforceMinRequiredFieldsForHeuristicsName, |
| 300 | flag_descriptions:: |
| 301 | kAutofillEnforceMinRequiredFieldsForHeuristicsDescription, |
| 302 | flags_ui::kOsIos, |
| 303 | FEATURE_VALUE_TYPE( |
| 304 | autofill::features::kAutofillEnforceMinRequiredFieldsForHeuristics)}, |
| 305 | {"autofill-enforce-min-required-fields-for-query", |
| 306 | flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryName, |
| 307 | flag_descriptions::kAutofillEnforceMinRequiredFieldsForQueryDescription, |
| 308 | flags_ui::kOsIos, |
| 309 | FEATURE_VALUE_TYPE( |
| 310 | autofill::features::kAutofillEnforceMinRequiredFieldsForQuery)}, |
| 311 | {"autofill-enforce-min-required-fields-for-upload", |
| 312 | flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadName, |
| 313 | flag_descriptions::kAutofillEnforceMinRequiredFieldsForUploadDescription, |
| 314 | flags_ui::kOsIos, |
| 315 | FEATURE_VALUE_TYPE( |
| 316 | autofill::features::kAutofillEnforceMinRequiredFieldsForUpload)}, |
Gauthier Ambard | 4417f85 | 2018-04-26 14:24:32 | [diff] [blame] | 317 | {"browser-container-fullscreen", |
| 318 | flag_descriptions::kBrowserContainerFullscreenName, |
| 319 | flag_descriptions::kBrowserContainerFullscreenDescription, |
| 320 | flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerFullscreen)}, |
Gauthier Ambard | cfd8518 | 2018-01-05 10:37:46 | [diff] [blame] | 321 | }; |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 322 | |
| 323 | // Add all switches from experimental flags to |command_line|. |
| 324 | void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) { |
| 325 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| 326 | |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 327 | // Set the UA flag if UseMobileSafariUA is enabled. |
| 328 | if ([defaults boolForKey:@"UseMobileSafariUA"]) { |
| 329 | // Safari uses "Vesion/", followed by the OS version excluding bugfix, where |
| 330 | // Chrome puts its product token. |
avi | 57194367 | 2015-12-22 02:12:49 | [diff] [blame] | 331 | int32_t major = 0; |
| 332 | int32_t minor = 0; |
| 333 | int32_t bugfix = 0; |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 334 | base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); |
| 335 | std::string product = base::StringPrintf("Version/%d.%d", major, minor); |
| 336 | |
| 337 | command_line->AppendSwitchASCII(switches::kUserAgent, |
| 338 | web::BuildUserAgentFromProduct(product)); |
| 339 | } |
| 340 | |
| 341 | // Freeform commandline flags. These are added last, so that any flags added |
| 342 | // earlier in this function take precedence. |
| 343 | if ([defaults boolForKey:@"EnableFreeformCommandLineFlags"]) { |
| 344 | base::CommandLine::StringVector flags; |
| 345 | // Append an empty "program" argument. |
| 346 | flags.push_back(""); |
| 347 | |
| 348 | // The number of flags corresponds to the number of text fields in |
| 349 | // Experimental.plist. |
| 350 | const int kNumFreeformFlags = 5; |
| 351 | for (int i = 1; i <= kNumFreeformFlags; ++i) { |
| 352 | NSString* key = |
| 353 | [NSString stringWithFormat:@"FreeformCommandLineFlag%d", i]; |
| 354 | NSString* flag = [defaults stringForKey:key]; |
| 355 | if ([flag length]) { |
| 356 | flags.push_back(base::SysNSStringToUTF8(flag)); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | base::CommandLine temp_command_line(flags); |
| 361 | command_line->AppendArguments(temp_command_line, false); |
| 362 | } |
msarda | fc76f66 | 2017-02-24 12:46:28 | [diff] [blame] | 363 | |
justincohen | dacc85d | 2017-06-28 23:34:10 | [diff] [blame] | 364 | // Populate command line flag for 3rd party keyboard omnibox workaround. |
| 365 | NSString* enableThirdPartyKeyboardWorkaround = |
| 366 | [defaults stringForKey:@"EnableThirdPartyKeyboardWorkaround"]; |
| 367 | if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Enabled"]) { |
| 368 | command_line->AppendSwitch(switches::kEnableThirdPartyKeyboardWorkaround); |
| 369 | } else if ([enableThirdPartyKeyboardWorkaround isEqualToString:@"Disabled"]) { |
| 370 | command_line->AppendSwitch(switches::kDisableThirdPartyKeyboardWorkaround); |
| 371 | } |
| 372 | |
msarda | fc76f66 | 2017-02-24 12:46:28 | [diff] [blame] | 373 | ios::GetChromeBrowserProvider()->AppendSwitchesFromExperimentalSettings( |
| 374 | defaults, command_line); |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) { |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | class FlagsStateSingleton { |
| 382 | public: |
| 383 | FlagsStateSingleton() |
| 384 | : flags_state_(kFeatureEntries, arraysize(kFeatureEntries)) {} |
| 385 | ~FlagsStateSingleton() {} |
| 386 | |
| 387 | static FlagsStateSingleton* GetInstance() { |
| 388 | return base::Singleton<FlagsStateSingleton>::get(); |
| 389 | } |
| 390 | |
| 391 | static flags_ui::FlagsState* GetFlagsState() { |
| 392 | return &GetInstance()->flags_state_; |
| 393 | } |
| 394 | |
| 395 | private: |
| 396 | flags_ui::FlagsState flags_state_; |
| 397 | |
| 398 | DISALLOW_COPY_AND_ASSIGN(FlagsStateSingleton); |
| 399 | }; |
| 400 | } // namespace |
| 401 | |
| 402 | void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage, |
| 403 | base::CommandLine* command_line) { |
Gregory Chatzinoff | 3130511 | 2017-12-20 21:56:02 | [diff] [blame] | 404 | AppendSwitchesFromExperimentalSettings(command_line); |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 405 | FlagsStateSingleton::GetFlagsState()->ConvertFlagsToSwitches( |
sdefresne | c976390 | 2015-12-02 10:30:11 | [diff] [blame] | 406 | flags_storage, command_line, flags_ui::kAddSentinels, |
Gregory Chatzinoff | f652372 | 2017-11-21 01:33:53 | [diff] [blame] | 407 | switches::kEnableFeatures, switches::kDisableFeatures); |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 408 | } |
| 409 | |
jkrcal | bf07337 | 2016-07-29 07:21:31 | [diff] [blame] | 410 | std::vector<std::string> RegisterAllFeatureVariationParameters( |
| 411 | flags_ui::FlagsStorage* flags_storage, |
| 412 | base::FeatureList* feature_list) { |
| 413 | return FlagsStateSingleton::GetFlagsState() |
| 414 | ->RegisterAllFeatureVariationParameters(flags_storage, feature_list); |
| 415 | } |
| 416 | |
sdefresne | 14900ee | 2015-11-27 14:43:21 | [diff] [blame] | 417 | void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage, |
| 418 | flags_ui::FlagAccess access, |
| 419 | base::ListValue* supported_entries, |
| 420 | base::ListValue* unsupported_entries) { |
| 421 | FlagsStateSingleton::GetFlagsState()->GetFlagFeatureEntries( |
| 422 | flags_storage, access, supported_entries, unsupported_entries, |
| 423 | base::Bind(&SkipConditionalFeatureEntry)); |
| 424 | } |
| 425 | |
| 426 | void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage, |
| 427 | const std::string& internal_name, |
| 428 | bool enable) { |
| 429 | FlagsStateSingleton::GetFlagsState()->SetFeatureEntryEnabled( |
| 430 | flags_storage, internal_name, enable); |
| 431 | } |
| 432 | |
| 433 | void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) { |
| 434 | FlagsStateSingleton::GetFlagsState()->ResetAllFlags(flags_storage); |
| 435 | } |
| 436 | |
| 437 | namespace testing { |
| 438 | |
| 439 | const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) { |
| 440 | *count = arraysize(kFeatureEntries); |
| 441 | return kFeatureEntries; |
| 442 | } |
| 443 | |
| 444 | } // namespace testing |