Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 1 | // Copyright 2018 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 | #include "third_party/blink/public/common/features.h" |
| 6 | |
Scott Haseley | 8eefdcd | 2018-08-22 16:50:19 | [diff] [blame] | 7 | #include "build/build_config.h" |
Hiroki Nakagawa | 893ee50 | 2019-02-04 06:49:53 | [diff] [blame] | 8 | #include "services/network/public/cpp/features.h" |
Scott Haseley | 8eefdcd | 2018-08-22 16:50:19 | [diff] [blame] | 9 | |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 10 | namespace blink { |
| 11 | namespace features { |
| 12 | |
Fabio Tirelo | 9b423c7b | 2018-08-15 14:32:18 | [diff] [blame] | 13 | const base::Feature kAutofillPreviewStyleExperiment{ |
| 14 | "AutofillPreviewStyleExperiment", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 15 | |
Stephen Chenney | de6e5c8 | 2019-01-21 01:56:04 | [diff] [blame] | 16 | // Enable defer commits a bit to avoid flash. |
| 17 | const base::Feature kAvoidFlashBetweenNavigation{ |
| 18 | "AvoidFlashBetweenNavigation", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 19 | |
Matt Falkenhagen | c25fea4 | 2018-07-17 07:13:52 | [diff] [blame] | 20 | // Enable eagerly setting up a CacheStorage interface pointer and |
| 21 | // passing it to service workers on startup as an optimization. |
| 22 | const base::Feature kEagerCacheStorageSetupForServiceWorkers{ |
| 23 | "EagerCacheStorageSetupForServiceWorkers", |
| 24 | base::FEATURE_ENABLED_BY_DEFAULT}; |
| 25 | |
Eric Karl | 0623ec7 | 2018-10-30 19:43:26 | [diff] [blame] | 26 | // Controls the user-specified viewport restriction for GPU Rasterization on |
| 27 | // mobile. See https://crbug.com/899399 |
| 28 | const base::Feature kEnableGpuRasterizationViewportRestriction{ |
| 29 | "EnableGpuRasterizationViewportRestriction", |
| 30 | base::FEATURE_ENABLED_BY_DEFAULT}; |
| 31 | |
Peter Kvitek | 197eaf7 | 2018-12-04 19:14:56 | [diff] [blame] | 32 | // Controls script streaming. |
| 33 | const base::Feature kScriptStreaming{"ScriptStreaming", |
| 34 | base::FEATURE_ENABLED_BY_DEFAULT}; |
| 35 | |
Liquan(Max) Gu | 4e243fc | 2018-11-17 00:13:02 | [diff] [blame] | 36 | // Enable FCP++ by experiment. See https://crbug.com/869924 |
| 37 | const base::Feature kFirstContentfulPaintPlusPlus{ |
| 38 | "FirstContentfulPaintPlusPlus", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 39 | |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 40 | // Tracks "jank" from layout objects changing their visual location between |
| 41 | // animation frames (see crbug.com/581518). |
| 42 | const base::Feature kJankTracking{"JankTracking", |
Steve Kobes | 7995fdd | 2019-02-13 21:30:43 | [diff] [blame] | 43 | base::FEATURE_ENABLED_BY_DEFAULT}; |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 44 | |
Steve Kobes | aa9c7c2 | 2019-01-21 18:24:13 | [diff] [blame] | 45 | const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine", |
| 46 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 47 | |
Philip Rogers | 6348133 | 2018-12-01 22:16:51 | [diff] [blame] | 48 | // Enable a new compositing mode called BlinkGenPropertyTrees where Blink |
| 49 | // generates the compositor property trees. See: https://crbug.com/836884. |
| 50 | const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees", |
| 51 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 52 | |
Ian Kilpatrick | e68ef11a | 2018-07-04 03:52:10 | [diff] [blame] | 53 | // Enable LayoutNG. |
| 54 | const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 55 | |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 56 | const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent", |
| 57 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 58 | |
Marijn Kruisselbrink | cde6463 | 2018-06-22 22:45:16 | [diff] [blame] | 59 | // Enable mojo Blob URL interface and better blob URL lifetime management. |
| 60 | // Can be enabled independently of NetworkService. |
| 61 | const base::Feature kMojoBlobURLs{"MojoBlobURLs", |
| 62 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 63 | |
Tarun Bansal | 422f901 | 2019-01-23 16:55:58 | [diff] [blame] | 64 | // Used to control the collection of anchor element metrics (crbug.com/856683). |
| 65 | // If kNavigationPredictor is enabled, then metrics of anchor elements |
| 66 | // in the first viewport after the page load and the metrics of the clicked |
| 67 | // anchor element will be extracted and recorded. Additionally, navigation |
| 68 | // predictor may preconnect/prefetch to resources/origins to make the |
| 69 | // future navigations faster. |
| 70 | const base::Feature kNavigationPredictor{"NavigationPredictor", |
| 71 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 72 | |
Hiroki Nakagawa | df83a6f | 2019-01-28 06:07:46 | [diff] [blame] | 73 | // Enable off-the-main-thread dedicated worker script fetch. |
| 74 | // (https://crbug.com/835717) |
| 75 | const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{ |
| 76 | "OffMainThreadDedicatedWorkerScriptFetch", |
| 77 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 78 | |
Hiroki Nakagawa | 893ee50 | 2019-02-04 06:49:53 | [diff] [blame] | 79 | // Enable off-the-main-thread shared worker script fetch. |
| 80 | // (https://crbug.com/924041) |
| 81 | const base::Feature kOffMainThreadSharedWorkerScriptFetch{ |
| 82 | "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 83 | |
Daniel Murphy | 80ce302 | 2018-10-18 07:28:07 | [diff] [blame] | 84 | // Onion souping for all DOMStorage. https://crbug.com/781870 |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 85 | const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage", |
Daniel Murphy | dc4aa5a7 | 2019-02-07 22:08:47 | [diff] [blame] | 86 | base::FEATURE_ENABLED_BY_DEFAULT}; |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 87 | |
Hiroki Nakagawa | 61ee004 | 2019-01-22 06:30:26 | [diff] [blame] | 88 | // Enable browser-initiated dedicated worker script loading |
| 89 | // (PlzDedicatedWorker). https://crbug.com/906991 |
| 90 | const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker", |
| 91 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 92 | |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 93 | // Enable Portals. https://crbug.com/865123. |
| 94 | const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 95 | |
Tarun Bansal | 8df12b5 | 2019-02-15 05:46:30 | [diff] [blame] | 96 | // Enable limiting previews loading hints to specific resource types. |
| 97 | const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{ |
| 98 | "PreviewsResourceLoadingHintsSpecificResourceTypes", |
| 99 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 100 | |
Aditya Keerthi | acee82f | 2019-02-15 16:48:08 | [diff] [blame] | 101 | // Purge memory when freezing only if the renderer is backgrounded. |
| 102 | const base::Feature kPurgeMemoryOnlyForBackgroundedProcesses{ |
| 103 | "FreezePurgeMemoryBackgroundedOnly", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 104 | |
David Bokan | 911bded | 2018-11-27 23:23:32 | [diff] [blame] | 105 | // Enable Implicit Root Scroller. https://crbug.com/903260. |
| 106 | const base::Feature kImplicitRootScroller{"ImplicitRootScroller", |
David Bokan | 5173a50 | 2019-01-11 22:06:48 | [diff] [blame] | 107 | base::FEATURE_ENABLED_BY_DEFAULT}; |
David Bokan | 911bded | 2018-11-27 23:23:32 | [diff] [blame] | 108 | |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 109 | // Enables usage of getDisplayMedia() that allows capture of web content, see |
| 110 | // https://crbug.com/865060. |
| 111 | const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia", |
| 112 | base::FEATURE_ENABLED_BY_DEFAULT}; |
| 113 | |
| 114 | // Changes the default RTCPeerConnection constructor behavior to use Unified |
| 115 | // Plan as the SDP semantics. When the feature is enabled, Unified Plan is used |
| 116 | // unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the |
| 117 | // argument). |
| 118 | const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault", |
Henrik Boström | 07021ec8 | 2019-01-17 22:23:56 | [diff] [blame] | 119 | base::FEATURE_ENABLED_BY_DEFAULT}; |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 120 | |
Johannes Kron | ad5a453 | 2019-01-09 11:17:46 | [diff] [blame] | 121 | // Determines if the SDP attrbute extmap-allow-mixed should be offered by |
| 122 | // default or not. The default value can be overridden by passing |
| 123 | // {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection |
| 124 | // constructor. |
| 125 | const base::Feature kRTCOfferExtmapAllowMixed{ |
| 126 | "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 127 | |
Makoto Shimazu | fc82e99 | 2018-12-05 07:14:28 | [diff] [blame] | 128 | // Enables to load the response body through Mojo data pipe passed by |
| 129 | // WebURLLoaderClient::DidStartLoadingResponseBody() instead of |
| 130 | // WebURLLoaderClient::DidReceiveData(). |
| 131 | const base::Feature kResourceLoadViaDataPipe{"ResourceLoadViaDataPipe", |
Yutaka Hirano | ce92866e | 2019-02-21 07:57:36 | [diff] [blame] | 132 | base::FEATURE_ENABLED_BY_DEFAULT}; |
Makoto Shimazu | fc82e99 | 2018-12-05 07:14:28 | [diff] [blame] | 133 | |
momohatt | fc35229 | 2018-08-29 05:12:36 | [diff] [blame] | 134 | const base::Feature kServiceWorkerImportedScriptUpdateCheck{ |
| 135 | "ServiceWorkerImportedScriptUpdateCheck", |
| 136 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 137 | |
Ben Kelly | e20dc40 | 2018-09-18 01:55:42 | [diff] [blame] | 138 | // Enables reading a subresource's body data and side data in parallel. |
| 139 | const base::Feature kServiceWorkerParallelSideDataReading{ |
| 140 | "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 141 | |
Kenichi Ishibashi | 42f883d | 2019-01-11 08:26:14 | [diff] [blame] | 142 | const base::Feature kServiceWorkerAggressiveCodeCache{ |
| 143 | "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 144 | |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 145 | // Enable new service worker glue for NetworkService. Can be |
| 146 | // enabled independently of NetworkService. |
| 147 | const base::Feature kServiceWorkerServicification{ |
Matt Falkenhagen | 5d2271c | 2018-10-17 10:12:44 | [diff] [blame] | 148 | "ServiceWorkerServicification", base::FEATURE_ENABLED_BY_DEFAULT}; |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 149 | |
Scott Haseley | 8eefdcd | 2018-08-22 16:50:19 | [diff] [blame] | 150 | // Freeze scheduler task queues in background after allowed grace time. |
| 151 | // "stop" is a legacy name. |
| 152 | const base::Feature kStopInBackground { |
| 153 | "stop-in-background", |
| 154 | #if defined(OS_ANDROID) |
| 155 | base::FEATURE_ENABLED_BY_DEFAULT |
| 156 | #else |
| 157 | base::FEATURE_DISABLED_BY_DEFAULT |
| 158 | #endif |
| 159 | }; |
| 160 | |
Shubhie Panicker | 60bd4b0 | 2018-09-26 00:02:15 | [diff] [blame] | 161 | // Freeze non-timer task queues in background, after allowed grace time. |
| 162 | // "stop" is a legacy name. |
| 163 | const base::Feature kStopNonTimersInBackground { |
| 164 | "stop-non-timers-in-background", |
| 165 | #if defined(OS_ANDROID) |
| 166 | base::FEATURE_ENABLED_BY_DEFAULT |
| 167 | #else |
| 168 | base::FEATURE_DISABLED_BY_DEFAULT |
| 169 | #endif |
| 170 | }; |
Scott Haseley | 7757f6c | 2018-08-03 14:33:23 | [diff] [blame] | 171 | |
David Bokan | e9370c2 | 2019-02-14 15:19:58 | [diff] [blame] | 172 | // Enable text snippets in URL fragments. https://crbug.com/919204. |
| 173 | const base::Feature kTextFragmentAnchor{"TextFragmentAnchor", |
| 174 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 175 | |
Bill Budge | 4d028f1 | 2018-11-20 15:05:12 | [diff] [blame] | 176 | // Enables the site isolated Wasm code cache that is keyed on the resource URL |
| 177 | // and the origin lock of the renderer that is requesting the resource. When |
| 178 | // this flag is enabled, content/GeneratedCodeCache handles code cache requests. |
| 179 | const base::Feature kWasmCodeCache = {"WasmCodeCache", |
| 180 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 181 | |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 182 | // Writable files and native filesystem access. https://crbug.com/853326 |
| 183 | const base::Feature kWritableFilesAPI{"WritableFilesAPI", |
| 184 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 185 | |
kdillon | 66bf5b52 | 2019-01-02 22:08:30 | [diff] [blame] | 186 | // Allows for synchronous XHR requests during page dismissal |
| 187 | const base::Feature kForbidSyncXHRInPageDismissal{ |
| 188 | "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 189 | |
Balazs Engedy | 130ab80 | 2019-02-22 12:14:00 | [diff] [blame^] | 190 | // Emergency lever that can be used to restore DeviceOrientationEvent and |
| 191 | // DeviceMotionEvent functionality in non-secure browsing contexts. |
| 192 | // See: https://crbug.com/932078. |
| 193 | const base::Feature kRestrictDeviceSensorEventsToSecureContexts{ |
| 194 | "RestrictDeviceSensorEventsToSecureContexts", |
| 195 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 196 | |
Fabio Tirelo | 9b423c7b | 2018-08-15 14:32:18 | [diff] [blame] | 197 | const char kAutofillPreviewStyleExperimentBgColorParameterName[] = "bg_color"; |
| 198 | |
| 199 | const char kAutofillPreviewStyleExperimentColorParameterName[] = "color"; |
| 200 | |
Carlos IL | d3be52b | 2018-10-08 17:57:18 | [diff] [blame] | 201 | const char kMixedContentAutoupgradeModeParamName[] = "mode"; |
| 202 | const char kMixedContentAutoupgradeModeBlockable[] = "blockable"; |
| 203 | const char kMixedContentAutoupgradeModeOptionallyBlockable[] = |
| 204 | "optionally-blockable"; |
| 205 | |
Madeleine Barowsky | 45be21a4 | 2018-12-07 18:39:30 | [diff] [blame] | 206 | // Decodes lossy WebP images to YUV instead of RGBX and stores in this format |
| 207 | // in the image decode cache. See crbug.com/900264 for details on the feature. |
| 208 | const base::Feature kDecodeLossyWebPImagesToYUV{ |
| 209 | "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 210 | |
Aaron Krajeski | f2f827d42 | 2019-01-08 15:08:34 | [diff] [blame] | 211 | // Use accelerated canvases whenever possible see https://crbug.com/909937 |
| 212 | const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas", |
| 213 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 214 | |
Hiroki Nakagawa | 893ee50 | 2019-02-04 06:49:53 | [diff] [blame] | 215 | bool IsOffMainThreadSharedWorkerScriptFetchEnabled() { |
| 216 | // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker |
| 217 | // (NetworkService). |
| 218 | DCHECK(!base::FeatureList::IsEnabled( |
| 219 | features::kOffMainThreadSharedWorkerScriptFetch) || |
| 220 | base::FeatureList::IsEnabled(network::features::kNetworkService)) |
| 221 | << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService " |
| 222 | << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService."; |
| 223 | return base::FeatureList::IsEnabled(network::features::kNetworkService) && |
| 224 | base::FeatureList::IsEnabled( |
| 225 | features::kOffMainThreadSharedWorkerScriptFetch); |
| 226 | } |
| 227 | |
Hiroki Nakagawa | 7d8cbfa | 2019-02-07 11:01:28 | [diff] [blame] | 228 | bool IsPlzDedicatedWorkerEnabled() { |
| 229 | // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script |
| 230 | // fetch and NetworkService. |
| 231 | #if DCHECK_IS_ON() |
| 232 | if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) { |
| 233 | DCHECK(base::FeatureList::IsEnabled( |
| 234 | features::kOffMainThreadDedicatedWorkerScriptFetch)) |
| 235 | << "PlzDedicatedWorker is enabled but " |
| 236 | << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker " |
| 237 | << "requires OffMainThreadDedicatedWorkerScriptFetch."; |
| 238 | DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService)) |
| 239 | << "PlzDedicatedWorker is enabled but NetworkService isn't. " |
| 240 | << "PlzDedicatedWorker requires NetworkService."; |
| 241 | } |
| 242 | #endif // DCHECK_IS_ON() |
| 243 | return base::FeatureList::IsEnabled( |
| 244 | features::kOffMainThreadDedicatedWorkerScriptFetch) && |
| 245 | base::FeatureList::IsEnabled(network::features::kNetworkService) && |
| 246 | base::FeatureList::IsEnabled(features::kPlzDedicatedWorker); |
| 247 | } |
| 248 | |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 249 | } // namespace features |
| 250 | } // namespace blink |