blob: 3b57c2c4226ad6fe0d698183978051000ee0f657 [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
Yao Xiao2c1171a2019-04-01 23:44:3213// Enable intervention for download that was initiated from or occurred in an ad
14// frame without user activation.
15const base::Feature kBlockingDownloadsInAdFrameWithoutUserActivation{
16 "BlockingDownloadsInAdFrameWithoutUserActivation",
17 base::FEATURE_DISABLED_BY_DEFAULT};
18
Stephen Chenneyde6e5c82019-01-21 01:56:0419// Enable defer commits a bit to avoid flash.
20const base::Feature kAvoidFlashBetweenNavigation{
21 "AvoidFlashBetweenNavigation", base::FEATURE_DISABLED_BY_DEFAULT};
22
Matt Falkenhagenc25fea42018-07-17 07:13:5223// Enable eagerly setting up a CacheStorage interface pointer and
24// passing it to service workers on startup as an optimization.
25const base::Feature kEagerCacheStorageSetupForServiceWorkers{
26 "EagerCacheStorageSetupForServiceWorkers",
27 base::FEATURE_ENABLED_BY_DEFAULT};
28
Eric Karl0623ec72018-10-30 19:43:2629// Controls the user-specified viewport restriction for GPU Rasterization on
30// mobile. See https://crbug.com/899399
31const base::Feature kEnableGpuRasterizationViewportRestriction{
32 "EnableGpuRasterizationViewportRestriction",
33 base::FEATURE_ENABLED_BY_DEFAULT};
34
Peter Kvitek197eaf72018-12-04 19:14:5635// Controls script streaming.
36const base::Feature kScriptStreaming{"ScriptStreaming",
37 base::FEATURE_ENABLED_BY_DEFAULT};
38
Keishi Hattori9e106922019-04-15 09:06:0339// Enables user level memory pressure signal generation on Android.
40const base::Feature kUserLevelMemoryPressureSignal{
41 "UserLevelMemoryPressureSignal", base::FEATURE_DISABLED_BY_DEFAULT};
42
Liquan(Max) Gu4e243fc2018-11-17 00:13:0243// Enable FCP++ by experiment. See https://crbug.com/869924
44const base::Feature kFirstContentfulPaintPlusPlus{
45 "FirstContentfulPaintPlusPlus", base::FEATURE_DISABLED_BY_DEFAULT};
46
Aditya Keerthi6a933902019-03-14 21:09:2747// Perform memory purges after freezing only if all pages are frozen.
48const base::Feature kFreezePurgeMemoryAllPagesFrozen{
49 "FreezePurgeMemoryAllPagesFrozen", base::FEATURE_DISABLED_BY_DEFAULT};
50
Aditya Keerthi8e3c4832019-03-28 14:50:3651// Controls whether or not the font cache is invalidated when a critical memory
52// pressure signal is sent.
53const base::Feature kInvalidateFontCacheOnPurge{
54 "InvalidateFontCacheOnPurge", base::FEATURE_ENABLED_BY_DEFAULT};
55
Steve Kobesb51c2fed2019-02-27 15:36:3156// Enables the experimental sweep-line algorithm for tracking "jank" from
57// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1358const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
59 base::FEATURE_DISABLED_BY_DEFAULT};
60
Philip Rogers63481332018-12-01 22:16:5161// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
62// generates the compositor property trees. See: https://crbug.com/836884.
63const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers3010556c2019-03-12 20:53:2264 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5165
Ian Kilpatricke68ef11a2018-07-04 03:52:1066// Enable LayoutNG.
67const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
68
Makoto Shimazu172eec02018-11-29 06:21:4469const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
70 base::FEATURE_DISABLED_BY_DEFAULT};
71
Marijn Kruisselbrinkcde64632018-06-22 22:45:1672// Enable mojo Blob URL interface and better blob URL lifetime management.
73// Can be enabled independently of NetworkService.
74const base::Feature kMojoBlobURLs{"MojoBlobURLs",
75 base::FEATURE_DISABLED_BY_DEFAULT};
76
Tarun Bansal422f9012019-01-23 16:55:5877// Used to control the collection of anchor element metrics (crbug.com/856683).
78// If kNavigationPredictor is enabled, then metrics of anchor elements
79// in the first viewport after the page load and the metrics of the clicked
80// anchor element will be extracted and recorded. Additionally, navigation
81// predictor may preconnect/prefetch to resources/origins to make the
82// future navigations faster.
83const base::Feature kNavigationPredictor{"NavigationPredictor",
84 base::FEATURE_DISABLED_BY_DEFAULT};
85
Hiroki Nakagawadf83a6f2019-01-28 06:07:4686// Enable off-the-main-thread dedicated worker script fetch.
87// (https://crbug.com/835717)
88const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
89 "OffMainThreadDedicatedWorkerScriptFetch",
90 base::FEATURE_DISABLED_BY_DEFAULT};
91
Kenichi Ishibashi5aa265a92019-02-28 07:01:4592// Enable off-the-main-thread service worker script fetch.
93// (https://crbug.com/924043)
94const base::Feature kOffMainThreadServiceWorkerScriptFetch{
95 "OffMainThreadServiceWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
96
Hiroki Nakagawa893ee502019-02-04 06:49:5397// Enable off-the-main-thread shared worker script fetch.
98// (https://crbug.com/924041)
99const base::Feature kOffMainThreadSharedWorkerScriptFetch{
100 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
101
Daniel Murphy80ce3022018-10-18 07:28:07102// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:55103const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:47104 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:55105
Hiroki Nakagawa61ee0042019-01-22 06:30:26106// Enable browser-initiated dedicated worker script loading
107// (PlzDedicatedWorker). https://crbug.com/906991
108const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
109 base::FEATURE_DISABLED_BY_DEFAULT};
110
Daniel Murphy95792ef2018-10-04 01:29:55111// Enable Portals. https://crbug.com/865123.
112const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
113
Tarun Bansal8df12b52019-02-15 05:46:30114// Enable limiting previews loading hints to specific resource types.
115const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
116 "PreviewsResourceLoadingHintsSpecificResourceTypes",
117 base::FEATURE_DISABLED_BY_DEFAULT};
118
Aditya Keerthie84331b32019-03-20 15:25:52119// Perform a memory purge after a renderer is backgrounded. Formerly labelled as
120// the "PurgeAndSuspend" experiment.
121//
122// TODO(adityakeerthi): Disabled by default on Mac and Android for historical
123// reasons. Consider enabling by default if experiment results are positive.
124// https://crbug.com/926186
125const base::Feature kPurgeRendererMemoryWhenBackgrounded {
126 "PurgeRendererMemoryWhenBackgrounded",
127#if defined(OS_MACOSX) || defined(OS_ANDROID)
128 base::FEATURE_DISABLED_BY_DEFAULT
129#else
130 base::FEATURE_ENABLED_BY_DEFAULT
131#endif
132};
133
David Bokan911bded2018-11-27 23:23:32134// Enable Implicit Root Scroller. https://crbug.com/903260.
135const base::Feature kImplicitRootScroller{"ImplicitRootScroller",
David Bokan5173a502019-01-11 22:06:48136 base::FEATURE_ENABLED_BY_DEFAULT};
David Bokan911bded2018-11-27 23:23:32137
Makoto Shimazu172eec02018-11-29 06:21:44138// Enables usage of getDisplayMedia() that allows capture of web content, see
139// https://crbug.com/865060.
140const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia",
141 base::FEATURE_ENABLED_BY_DEFAULT};
142
143// Changes the default RTCPeerConnection constructor behavior to use Unified
144// Plan as the SDP semantics. When the feature is enabled, Unified Plan is used
145// unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the
146// argument).
147const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault",
Henrik Boström07021ec82019-01-17 22:23:56148 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44149
Johannes Kronad5a4532019-01-09 11:17:46150// Determines if the SDP attrbute extmap-allow-mixed should be offered by
151// default or not. The default value can be overridden by passing
152// {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection
153// constructor.
154const base::Feature kRTCOfferExtmapAllowMixed{
155 "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT};
156
momohattfc352292018-08-29 05:12:36157const base::Feature kServiceWorkerImportedScriptUpdateCheck{
158 "ServiceWorkerImportedScriptUpdateCheck",
159 base::FEATURE_DISABLED_BY_DEFAULT};
160
Ben Kellye20dc402018-09-18 01:55:42161// Enables reading a subresource's body data and side data in parallel.
162const base::Feature kServiceWorkerParallelSideDataReading{
163 "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT};
164
Kenichi Ishibashi42f883d2019-01-11 08:26:14165const base::Feature kServiceWorkerAggressiveCodeCache{
166 "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
167
Makoto Shimazua8b3d742019-04-05 06:55:51168// Experiment of the delay from navigation to starting an update of a service
169// worker's script.
170const base::Feature kServiceWorkerUpdateDelay{
171 "ServiceWorkerUpdateDelay", base::FEATURE_DISABLED_BY_DEFAULT};
172
Scott Haseley8eefdcd2018-08-22 16:50:19173// Freeze scheduler task queues in background after allowed grace time.
174// "stop" is a legacy name.
175const base::Feature kStopInBackground {
176 "stop-in-background",
177#if defined(OS_ANDROID)
178 base::FEATURE_ENABLED_BY_DEFAULT
179#else
180 base::FEATURE_DISABLED_BY_DEFAULT
181#endif
182};
183
Takashi Sakamotoc19fc2b2019-04-10 06:30:52184// Freeze scheduler task queues in background on network idle.
185// This feature only works if stop-in-background is enabled.
186const base::Feature kFreezeBackgroundTabOnNetworkIdle{
187 "freeze-background-tab-on-network-idle", base::FEATURE_DISABLED_BY_DEFAULT};
188
Shubhie Panicker60bd4b02018-09-26 00:02:15189// Freeze non-timer task queues in background, after allowed grace time.
190// "stop" is a legacy name.
191const base::Feature kStopNonTimersInBackground {
192 "stop-non-timers-in-background",
193#if defined(OS_ANDROID)
194 base::FEATURE_ENABLED_BY_DEFAULT
195#else
196 base::FEATURE_DISABLED_BY_DEFAULT
197#endif
198};
Scott Haseley7757f6c2018-08-03 14:33:23199
David Bokane9370c22019-02-14 15:19:58200// Enable text snippets in URL fragments. https://crbug.com/919204.
201const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
202 base::FEATURE_DISABLED_BY_DEFAULT};
203
Bill Budge4d028f12018-11-20 15:05:12204// Enables the site isolated Wasm code cache that is keyed on the resource URL
205// and the origin lock of the renderer that is requesting the resource. When
206// this flag is enabled, content/GeneratedCodeCache handles code cache requests.
207const base::Feature kWasmCodeCache = {"WasmCodeCache",
208 base::FEATURE_DISABLED_BY_DEFAULT};
209
Makoto Shimazu172eec02018-11-29 06:21:44210// Writable files and native filesystem access. https://crbug.com/853326
Marijn Kruisselbrinkfa0e1052019-03-05 22:32:55211const base::Feature kNativeFilesystemAPI{"NativeFilesystemAPI",
212 base::FEATURE_DISABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44213
kdillon66bf5b522019-01-02 22:08:30214// Allows for synchronous XHR requests during page dismissal
215const base::Feature kForbidSyncXHRInPageDismissal{
kdillon1c60a4f2019-04-11 16:57:30216 "ForbidSyncXHRInPageDismissal", base::FEATURE_ENABLED_BY_DEFAULT};
kdillon66bf5b522019-01-02 22:08:30217
Balazs Engedy130ab802019-02-22 12:14:00218// Emergency lever that can be used to restore DeviceOrientationEvent and
219// DeviceMotionEvent functionality in non-secure browsing contexts.
220// See: https://crbug.com/932078.
221const base::Feature kRestrictDeviceSensorEventsToSecureContexts{
222 "RestrictDeviceSensorEventsToSecureContexts",
Balazs Engedy4665f962019-02-27 10:53:09223 base::FEATURE_ENABLED_BY_DEFAULT};
Balazs Engedy130ab802019-02-22 12:14:00224
Carlos ILd3be52b2018-10-08 17:57:18225const char kMixedContentAutoupgradeModeParamName[] = "mode";
226const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
227const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
228 "optionally-blockable";
229
Madeleine Barowsky45be21a42018-12-07 18:39:30230// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
231// in the image decode cache. See crbug.com/900264 for details on the feature.
232const base::Feature kDecodeLossyWebPImagesToYUV{
233 "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
234
Aaron Krajeskif2f827d422019-01-08 15:08:34235// Use accelerated canvases whenever possible see https://crbug.com/909937
236const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas",
237 base::FEATURE_DISABLED_BY_DEFAULT};
238
Takashi Toyoshimaa91506d2019-03-28 05:44:42239// Enables cache-aware WebFonts loading. See https://crbug.com/570205.
240// The feature is disabled on Android for WebView API issue discussed at
241// https://crbug.com/942440.
242const base::Feature kWebFontsCacheAwareTimeoutAdaption {
243 "WebFontsCacheAwareTimeoutAdaption",
244#if defined(OS_ANDROID)
245 base::FEATURE_DISABLED_BY_DEFAULT
246#else
247 base::FEATURE_ENABLED_BY_DEFAULT
248#endif
249};
250
Hiroki Nakagawa893ee502019-02-04 06:49:53251bool IsOffMainThreadSharedWorkerScriptFetchEnabled() {
252 // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker
253 // (NetworkService).
254 DCHECK(!base::FeatureList::IsEnabled(
255 features::kOffMainThreadSharedWorkerScriptFetch) ||
256 base::FeatureList::IsEnabled(network::features::kNetworkService))
257 << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService "
258 << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService.";
259 return base::FeatureList::IsEnabled(network::features::kNetworkService) &&
260 base::FeatureList::IsEnabled(
261 features::kOffMainThreadSharedWorkerScriptFetch);
262}
263
Hiroki Nakagawa7d8cbfa2019-02-07 11:01:28264bool IsPlzDedicatedWorkerEnabled() {
265 // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script
266 // fetch and NetworkService.
267#if DCHECK_IS_ON()
268 if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) {
269 DCHECK(base::FeatureList::IsEnabled(
270 features::kOffMainThreadDedicatedWorkerScriptFetch))
271 << "PlzDedicatedWorker is enabled but "
272 << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker "
273 << "requires OffMainThreadDedicatedWorkerScriptFetch.";
274 DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService))
275 << "PlzDedicatedWorker is enabled but NetworkService isn't. "
276 << "PlzDedicatedWorker requires NetworkService.";
277 }
278#endif // DCHECK_IS_ON()
279 return base::FeatureList::IsEnabled(
280 features::kOffMainThreadDedicatedWorkerScriptFetch) &&
281 base::FeatureList::IsEnabled(network::features::kNetworkService) &&
282 base::FeatureList::IsEnabled(features::kPlzDedicatedWorker);
283}
284
Matt Falkenhagen5cc652792018-06-21 10:34:33285} // namespace features
286} // namespace blink