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 | |
David Bokan | 911bded | 2018-11-27 23:23:32 | [diff] [blame] | 96 | // Enable Implicit Root Scroller. https://crbug.com/903260. |
| 97 | const base::Feature kImplicitRootScroller{"ImplicitRootScroller", |
David Bokan | 5173a50 | 2019-01-11 22:06:48 | [diff] [blame] | 98 | base::FEATURE_ENABLED_BY_DEFAULT}; |
David Bokan | 911bded | 2018-11-27 23:23:32 | [diff] [blame] | 99 | |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 100 | // Enables usage of getDisplayMedia() that allows capture of web content, see |
| 101 | // https://crbug.com/865060. |
| 102 | const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia", |
| 103 | base::FEATURE_ENABLED_BY_DEFAULT}; |
| 104 | |
| 105 | // Changes the default RTCPeerConnection constructor behavior to use Unified |
| 106 | // Plan as the SDP semantics. When the feature is enabled, Unified Plan is used |
| 107 | // unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the |
| 108 | // argument). |
| 109 | const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault", |
Henrik Boström | 07021ec8 | 2019-01-17 22:23:56 | [diff] [blame] | 110 | base::FEATURE_ENABLED_BY_DEFAULT}; |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 111 | |
Johannes Kron | ad5a453 | 2019-01-09 11:17:46 | [diff] [blame] | 112 | // Determines if the SDP attrbute extmap-allow-mixed should be offered by |
| 113 | // default or not. The default value can be overridden by passing |
| 114 | // {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection |
| 115 | // constructor. |
| 116 | const base::Feature kRTCOfferExtmapAllowMixed{ |
| 117 | "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 118 | |
Makoto Shimazu | fc82e99 | 2018-12-05 07:14:28 | [diff] [blame] | 119 | // Enables to load the response body through Mojo data pipe passed by |
| 120 | // WebURLLoaderClient::DidStartLoadingResponseBody() instead of |
| 121 | // WebURLLoaderClient::DidReceiveData(). |
| 122 | const base::Feature kResourceLoadViaDataPipe{"ResourceLoadViaDataPipe", |
Caleb Rouleau | e92139b | 2019-02-08 03:00:34 | [diff] [blame] | 123 | base::FEATURE_DISABLED_BY_DEFAULT}; |
Makoto Shimazu | fc82e99 | 2018-12-05 07:14:28 | [diff] [blame] | 124 | |
momohatt | fc35229 | 2018-08-29 05:12:36 | [diff] [blame] | 125 | const base::Feature kServiceWorkerImportedScriptUpdateCheck{ |
| 126 | "ServiceWorkerImportedScriptUpdateCheck", |
| 127 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 128 | |
Ben Kelly | e20dc40 | 2018-09-18 01:55:42 | [diff] [blame] | 129 | // Enables reading a subresource's body data and side data in parallel. |
| 130 | const base::Feature kServiceWorkerParallelSideDataReading{ |
| 131 | "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 132 | |
Kenichi Ishibashi | 42f883d | 2019-01-11 08:26:14 | [diff] [blame] | 133 | const base::Feature kServiceWorkerAggressiveCodeCache{ |
| 134 | "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 135 | |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 136 | // Enable new service worker glue for NetworkService. Can be |
| 137 | // enabled independently of NetworkService. |
| 138 | const base::Feature kServiceWorkerServicification{ |
Matt Falkenhagen | 5d2271c | 2018-10-17 10:12:44 | [diff] [blame] | 139 | "ServiceWorkerServicification", base::FEATURE_ENABLED_BY_DEFAULT}; |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 140 | |
Scott Haseley | 8eefdcd | 2018-08-22 16:50:19 | [diff] [blame] | 141 | // Freeze scheduler task queues in background after allowed grace time. |
| 142 | // "stop" is a legacy name. |
| 143 | const base::Feature kStopInBackground { |
| 144 | "stop-in-background", |
| 145 | #if defined(OS_ANDROID) |
| 146 | base::FEATURE_ENABLED_BY_DEFAULT |
| 147 | #else |
| 148 | base::FEATURE_DISABLED_BY_DEFAULT |
| 149 | #endif |
| 150 | }; |
| 151 | |
Shubhie Panicker | 60bd4b0 | 2018-09-26 00:02:15 | [diff] [blame] | 152 | // Freeze non-timer task queues in background, after allowed grace time. |
| 153 | // "stop" is a legacy name. |
| 154 | const base::Feature kStopNonTimersInBackground { |
| 155 | "stop-non-timers-in-background", |
| 156 | #if defined(OS_ANDROID) |
| 157 | base::FEATURE_ENABLED_BY_DEFAULT |
| 158 | #else |
| 159 | base::FEATURE_DISABLED_BY_DEFAULT |
| 160 | #endif |
| 161 | }; |
Scott Haseley | 7757f6c | 2018-08-03 14:33:23 | [diff] [blame] | 162 | |
David Bokan | e9370c2 | 2019-02-14 15:19:58 | [diff] [blame^] | 163 | // Enable text snippets in URL fragments. https://crbug.com/919204. |
| 164 | const base::Feature kTextFragmentAnchor{"TextFragmentAnchor", |
| 165 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 166 | |
Bill Budge | 4d028f1 | 2018-11-20 15:05:12 | [diff] [blame] | 167 | // Enables the site isolated Wasm code cache that is keyed on the resource URL |
| 168 | // and the origin lock of the renderer that is requesting the resource. When |
| 169 | // this flag is enabled, content/GeneratedCodeCache handles code cache requests. |
| 170 | const base::Feature kWasmCodeCache = {"WasmCodeCache", |
| 171 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 172 | |
Makoto Shimazu | 172eec0 | 2018-11-29 06:21:44 | [diff] [blame] | 173 | // Writable files and native filesystem access. https://crbug.com/853326 |
| 174 | const base::Feature kWritableFilesAPI{"WritableFilesAPI", |
| 175 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 176 | |
kdillon | 66bf5b52 | 2019-01-02 22:08:30 | [diff] [blame] | 177 | // Allows for synchronous XHR requests during page dismissal |
| 178 | const base::Feature kForbidSyncXHRInPageDismissal{ |
| 179 | "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 180 | |
Fabio Tirelo | 9b423c7b | 2018-08-15 14:32:18 | [diff] [blame] | 181 | const char kAutofillPreviewStyleExperimentBgColorParameterName[] = "bg_color"; |
| 182 | |
| 183 | const char kAutofillPreviewStyleExperimentColorParameterName[] = "color"; |
| 184 | |
Carlos IL | d3be52b | 2018-10-08 17:57:18 | [diff] [blame] | 185 | const char kMixedContentAutoupgradeModeParamName[] = "mode"; |
| 186 | const char kMixedContentAutoupgradeModeBlockable[] = "blockable"; |
| 187 | const char kMixedContentAutoupgradeModeOptionallyBlockable[] = |
| 188 | "optionally-blockable"; |
| 189 | |
Madeleine Barowsky | 45be21a4 | 2018-12-07 18:39:30 | [diff] [blame] | 190 | // Decodes lossy WebP images to YUV instead of RGBX and stores in this format |
| 191 | // in the image decode cache. See crbug.com/900264 for details on the feature. |
| 192 | const base::Feature kDecodeLossyWebPImagesToYUV{ |
| 193 | "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 194 | |
Aaron Krajeski | f2f827d42 | 2019-01-08 15:08:34 | [diff] [blame] | 195 | // Use accelerated canvases whenever possible see https://crbug.com/909937 |
| 196 | const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas", |
| 197 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 198 | |
Hiroki Nakagawa | 893ee50 | 2019-02-04 06:49:53 | [diff] [blame] | 199 | bool IsOffMainThreadSharedWorkerScriptFetchEnabled() { |
| 200 | // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker |
| 201 | // (NetworkService). |
| 202 | DCHECK(!base::FeatureList::IsEnabled( |
| 203 | features::kOffMainThreadSharedWorkerScriptFetch) || |
| 204 | base::FeatureList::IsEnabled(network::features::kNetworkService)) |
| 205 | << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService " |
| 206 | << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService."; |
| 207 | return base::FeatureList::IsEnabled(network::features::kNetworkService) && |
| 208 | base::FeatureList::IsEnabled( |
| 209 | features::kOffMainThreadSharedWorkerScriptFetch); |
| 210 | } |
| 211 | |
Hiroki Nakagawa | 7d8cbfa | 2019-02-07 11:01:28 | [diff] [blame] | 212 | bool IsPlzDedicatedWorkerEnabled() { |
| 213 | // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script |
| 214 | // fetch and NetworkService. |
| 215 | #if DCHECK_IS_ON() |
| 216 | if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) { |
| 217 | DCHECK(base::FeatureList::IsEnabled( |
| 218 | features::kOffMainThreadDedicatedWorkerScriptFetch)) |
| 219 | << "PlzDedicatedWorker is enabled but " |
| 220 | << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker " |
| 221 | << "requires OffMainThreadDedicatedWorkerScriptFetch."; |
| 222 | DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService)) |
| 223 | << "PlzDedicatedWorker is enabled but NetworkService isn't. " |
| 224 | << "PlzDedicatedWorker requires NetworkService."; |
| 225 | } |
| 226 | #endif // DCHECK_IS_ON() |
| 227 | return base::FeatureList::IsEnabled( |
| 228 | features::kOffMainThreadDedicatedWorkerScriptFetch) && |
| 229 | base::FeatureList::IsEnabled(network::features::kNetworkService) && |
| 230 | base::FeatureList::IsEnabled(features::kPlzDedicatedWorker); |
| 231 | } |
| 232 | |
Matt Falkenhagen | 5cc65279 | 2018-06-21 10:34:33 | [diff] [blame] | 233 | } // namespace features |
| 234 | } // namespace blink |