blob: f20b664cdc90d9728354108e06dc515bdc701f91 [file] [log] [blame]
Matt Falkenhagen5cc652792018-06-21 10:34:331// 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 Haseley8eefdcd2018-08-22 16:50:197#include "build/build_config.h"
Hiroki Nakagawa893ee502019-02-04 06:49:538#include "services/network/public/cpp/features.h"
Scott Haseley8eefdcd2018-08-22 16:50:199
Matt Falkenhagen5cc652792018-06-21 10:34:3310namespace blink {
11namespace features {
12
Stephen Chenneyde6e5c82019-01-21 01:56:0413// Enable defer commits a bit to avoid flash.
14const base::Feature kAvoidFlashBetweenNavigation{
15 "AvoidFlashBetweenNavigation", base::FEATURE_DISABLED_BY_DEFAULT};
16
Matt Falkenhagenc25fea42018-07-17 07:13:5217// Enable eagerly setting up a CacheStorage interface pointer and
18// passing it to service workers on startup as an optimization.
19const base::Feature kEagerCacheStorageSetupForServiceWorkers{
20 "EagerCacheStorageSetupForServiceWorkers",
21 base::FEATURE_ENABLED_BY_DEFAULT};
22
Eric Karl0623ec72018-10-30 19:43:2623// Controls the user-specified viewport restriction for GPU Rasterization on
24// mobile. See https://crbug.com/899399
25const base::Feature kEnableGpuRasterizationViewportRestriction{
26 "EnableGpuRasterizationViewportRestriction",
27 base::FEATURE_ENABLED_BY_DEFAULT};
28
Peter Kvitek197eaf72018-12-04 19:14:5629// Controls script streaming.
30const base::Feature kScriptStreaming{"ScriptStreaming",
31 base::FEATURE_ENABLED_BY_DEFAULT};
32
Liquan(Max) Gu4e243fc2018-11-17 00:13:0233// Enable FCP++ by experiment. See https://crbug.com/869924
34const base::Feature kFirstContentfulPaintPlusPlus{
35 "FirstContentfulPaintPlusPlus", base::FEATURE_DISABLED_BY_DEFAULT};
36
Steve Kobesb51c2fed2019-02-27 15:36:3137// Enables the experimental sweep-line algorithm for tracking "jank" from
38// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1339const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
40 base::FEATURE_DISABLED_BY_DEFAULT};
41
Philip Rogers63481332018-12-01 22:16:5142// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
43// generates the compositor property trees. See: https://crbug.com/836884.
44const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers9cdf4322019-02-25 21:37:1545 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5146
Ian Kilpatricke68ef11a2018-07-04 03:52:1047// Enable LayoutNG.
48const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
49
Makoto Shimazu172eec02018-11-29 06:21:4450const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
51 base::FEATURE_DISABLED_BY_DEFAULT};
52
Marijn Kruisselbrinkcde64632018-06-22 22:45:1653// Enable mojo Blob URL interface and better blob URL lifetime management.
54// Can be enabled independently of NetworkService.
55const base::Feature kMojoBlobURLs{"MojoBlobURLs",
56 base::FEATURE_DISABLED_BY_DEFAULT};
57
Tarun Bansal422f9012019-01-23 16:55:5858// Used to control the collection of anchor element metrics (crbug.com/856683).
59// If kNavigationPredictor is enabled, then metrics of anchor elements
60// in the first viewport after the page load and the metrics of the clicked
61// anchor element will be extracted and recorded. Additionally, navigation
62// predictor may preconnect/prefetch to resources/origins to make the
63// future navigations faster.
64const base::Feature kNavigationPredictor{"NavigationPredictor",
65 base::FEATURE_DISABLED_BY_DEFAULT};
66
Hiroki Nakagawadf83a6f2019-01-28 06:07:4667// Enable off-the-main-thread dedicated worker script fetch.
68// (https://crbug.com/835717)
69const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
70 "OffMainThreadDedicatedWorkerScriptFetch",
71 base::FEATURE_DISABLED_BY_DEFAULT};
72
Kenichi Ishibashi5aa265a92019-02-28 07:01:4573// Enable off-the-main-thread service worker script fetch.
74// (https://crbug.com/924043)
75const base::Feature kOffMainThreadServiceWorkerScriptFetch{
76 "OffMainThreadServiceWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
77
Hiroki Nakagawa893ee502019-02-04 06:49:5378// Enable off-the-main-thread shared worker script fetch.
79// (https://crbug.com/924041)
80const base::Feature kOffMainThreadSharedWorkerScriptFetch{
81 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
82
Daniel Murphy80ce3022018-10-18 07:28:0783// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:5584const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:4785 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:5586
Hiroki Nakagawa61ee0042019-01-22 06:30:2687// Enable browser-initiated dedicated worker script loading
88// (PlzDedicatedWorker). https://crbug.com/906991
89const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
90 base::FEATURE_DISABLED_BY_DEFAULT};
91
Daniel Murphy95792ef2018-10-04 01:29:5592// Enable Portals. https://crbug.com/865123.
93const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
94
Tarun Bansal8df12b52019-02-15 05:46:3095// Enable limiting previews loading hints to specific resource types.
96const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
97 "PreviewsResourceLoadingHintsSpecificResourceTypes",
98 base::FEATURE_DISABLED_BY_DEFAULT};
99
Aditya Keerthiacee82f2019-02-15 16:48:08100// Purge memory when freezing only if the renderer is backgrounded.
101const base::Feature kPurgeMemoryOnlyForBackgroundedProcesses{
102 "FreezePurgeMemoryBackgroundedOnly", base::FEATURE_DISABLED_BY_DEFAULT};
103
David Bokan911bded2018-11-27 23:23:32104// Enable Implicit Root Scroller. https://crbug.com/903260.
105const base::Feature kImplicitRootScroller{"ImplicitRootScroller",
David Bokan5173a502019-01-11 22:06:48106 base::FEATURE_ENABLED_BY_DEFAULT};
David Bokan911bded2018-11-27 23:23:32107
Makoto Shimazu172eec02018-11-29 06:21:44108// Enables usage of getDisplayMedia() that allows capture of web content, see
109// https://crbug.com/865060.
110const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia",
111 base::FEATURE_ENABLED_BY_DEFAULT};
112
113// Changes the default RTCPeerConnection constructor behavior to use Unified
114// Plan as the SDP semantics. When the feature is enabled, Unified Plan is used
115// unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the
116// argument).
117const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault",
Henrik Boström07021ec82019-01-17 22:23:56118 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44119
Johannes Kronad5a4532019-01-09 11:17:46120// Determines if the SDP attrbute extmap-allow-mixed should be offered by
121// default or not. The default value can be overridden by passing
122// {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection
123// constructor.
124const base::Feature kRTCOfferExtmapAllowMixed{
125 "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT};
126
Makoto Shimazufc82e992018-12-05 07:14:28127// Enables to load the response body through Mojo data pipe passed by
128// WebURLLoaderClient::DidStartLoadingResponseBody() instead of
129// WebURLLoaderClient::DidReceiveData().
130const base::Feature kResourceLoadViaDataPipe{"ResourceLoadViaDataPipe",
Yutaka Hiranoce92866e2019-02-21 07:57:36131 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazufc82e992018-12-05 07:14:28132
momohattfc352292018-08-29 05:12:36133const base::Feature kServiceWorkerImportedScriptUpdateCheck{
134 "ServiceWorkerImportedScriptUpdateCheck",
135 base::FEATURE_DISABLED_BY_DEFAULT};
136
Ben Kellye20dc402018-09-18 01:55:42137// Enables reading a subresource's body data and side data in parallel.
138const base::Feature kServiceWorkerParallelSideDataReading{
139 "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT};
140
Kenichi Ishibashi42f883d2019-01-11 08:26:14141const base::Feature kServiceWorkerAggressiveCodeCache{
142 "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
143
Matt Falkenhagen5cc652792018-06-21 10:34:33144// Enable new service worker glue for NetworkService. Can be
145// enabled independently of NetworkService.
146const base::Feature kServiceWorkerServicification{
Matt Falkenhagen5d2271c2018-10-17 10:12:44147 "ServiceWorkerServicification", base::FEATURE_ENABLED_BY_DEFAULT};
Matt Falkenhagen5cc652792018-06-21 10:34:33148
Scott Haseley8eefdcd2018-08-22 16:50:19149// Freeze scheduler task queues in background after allowed grace time.
150// "stop" is a legacy name.
151const base::Feature kStopInBackground {
152 "stop-in-background",
153#if defined(OS_ANDROID)
154 base::FEATURE_ENABLED_BY_DEFAULT
155#else
156 base::FEATURE_DISABLED_BY_DEFAULT
157#endif
158};
159
Shubhie Panicker60bd4b02018-09-26 00:02:15160// Freeze non-timer task queues in background, after allowed grace time.
161// "stop" is a legacy name.
162const base::Feature kStopNonTimersInBackground {
163 "stop-non-timers-in-background",
164#if defined(OS_ANDROID)
165 base::FEATURE_ENABLED_BY_DEFAULT
166#else
167 base::FEATURE_DISABLED_BY_DEFAULT
168#endif
169};
Scott Haseley7757f6c2018-08-03 14:33:23170
David Bokane9370c22019-02-14 15:19:58171// Enable text snippets in URL fragments. https://crbug.com/919204.
172const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
173 base::FEATURE_DISABLED_BY_DEFAULT};
174
Bill Budge4d028f12018-11-20 15:05:12175// Enables the site isolated Wasm code cache that is keyed on the resource URL
176// and the origin lock of the renderer that is requesting the resource. When
177// this flag is enabled, content/GeneratedCodeCache handles code cache requests.
178const base::Feature kWasmCodeCache = {"WasmCodeCache",
179 base::FEATURE_DISABLED_BY_DEFAULT};
180
Makoto Shimazu172eec02018-11-29 06:21:44181// Writable files and native filesystem access. https://crbug.com/853326
182const base::Feature kWritableFilesAPI{"WritableFilesAPI",
183 base::FEATURE_DISABLED_BY_DEFAULT};
184
kdillon66bf5b522019-01-02 22:08:30185// Allows for synchronous XHR requests during page dismissal
186const base::Feature kForbidSyncXHRInPageDismissal{
187 "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT};
188
Balazs Engedy130ab802019-02-22 12:14:00189// Emergency lever that can be used to restore DeviceOrientationEvent and
190// DeviceMotionEvent functionality in non-secure browsing contexts.
191// See: https://crbug.com/932078.
192const base::Feature kRestrictDeviceSensorEventsToSecureContexts{
193 "RestrictDeviceSensorEventsToSecureContexts",
Balazs Engedy4665f962019-02-27 10:53:09194 base::FEATURE_ENABLED_BY_DEFAULT};
Balazs Engedy130ab802019-02-22 12:14:00195
Carlos ILd3be52b2018-10-08 17:57:18196const char kMixedContentAutoupgradeModeParamName[] = "mode";
197const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
198const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
199 "optionally-blockable";
200
Madeleine Barowsky45be21a42018-12-07 18:39:30201// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
202// in the image decode cache. See crbug.com/900264 for details on the feature.
203const base::Feature kDecodeLossyWebPImagesToYUV{
204 "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
205
Aaron Krajeskif2f827d422019-01-08 15:08:34206// Use accelerated canvases whenever possible see https://crbug.com/909937
207const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas",
208 base::FEATURE_DISABLED_BY_DEFAULT};
209
Hiroki Nakagawa893ee502019-02-04 06:49:53210bool IsOffMainThreadSharedWorkerScriptFetchEnabled() {
211 // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker
212 // (NetworkService).
213 DCHECK(!base::FeatureList::IsEnabled(
214 features::kOffMainThreadSharedWorkerScriptFetch) ||
215 base::FeatureList::IsEnabled(network::features::kNetworkService))
216 << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService "
217 << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService.";
218 return base::FeatureList::IsEnabled(network::features::kNetworkService) &&
219 base::FeatureList::IsEnabled(
220 features::kOffMainThreadSharedWorkerScriptFetch);
221}
222
Hiroki Nakagawa7d8cbfa2019-02-07 11:01:28223bool IsPlzDedicatedWorkerEnabled() {
224 // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script
225 // fetch and NetworkService.
226#if DCHECK_IS_ON()
227 if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) {
228 DCHECK(base::FeatureList::IsEnabled(
229 features::kOffMainThreadDedicatedWorkerScriptFetch))
230 << "PlzDedicatedWorker is enabled but "
231 << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker "
232 << "requires OffMainThreadDedicatedWorkerScriptFetch.";
233 DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService))
234 << "PlzDedicatedWorker is enabled but NetworkService isn't. "
235 << "PlzDedicatedWorker requires NetworkService.";
236 }
237#endif // DCHECK_IS_ON()
238 return base::FeatureList::IsEnabled(
239 features::kOffMainThreadDedicatedWorkerScriptFetch) &&
240 base::FeatureList::IsEnabled(network::features::kNetworkService) &&
241 base::FeatureList::IsEnabled(features::kPlzDedicatedWorker);
242}
243
Matt Falkenhagen5cc652792018-06-21 10:34:33244} // namespace features
245} // namespace blink