blob: 3b387d8f50b05518bb4219838d9e8cfcbe401f6f [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
John Delaneyac24e572019-04-30 19:47:0251// Freezes the user-agent as part of https://github.com/WICG/ua-client-hints.
52const base::Feature kFreezeUserAgent{"FreezeUserAgent",
53 base::FEATURE_DISABLED_BY_DEFAULT};
54
Steve Kobesb51c2fed2019-02-27 15:36:3155// Enables the experimental sweep-line algorithm for tracking "jank" from
56// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1357const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
58 base::FEATURE_DISABLED_BY_DEFAULT};
59
Philip Rogers63481332018-12-01 22:16:5160// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
61// generates the compositor property trees. See: https://crbug.com/836884.
62const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers3010556c2019-03-12 20:53:2263 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5164
Vladimir Levin43758ecc2019-05-09 18:04:0365// Enable Display Locking JavaScript APIs.
66const base::Feature kDisplayLocking{"DisplayLocking",
67 base::FEATURE_DISABLED_BY_DEFAULT};
68
Chris Harrelson6e41e3ae2019-05-03 23:09:4069// Enable applying rounded corner masks via a GL shader rather than
70// a mask layer.
71const base::Feature kFastBorderRadius{"FastBorderRadius",
72 base::FEATURE_DISABLED_BY_DEFAULT};
73
Ian Kilpatricke68ef11a2018-07-04 03:52:1074// Enable LayoutNG.
75const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
76
Makoto Shimazu172eec02018-11-29 06:21:4477const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
78 base::FEATURE_DISABLED_BY_DEFAULT};
79
Marijn Kruisselbrinkcde64632018-06-22 22:45:1680// Enable mojo Blob URL interface and better blob URL lifetime management.
81// Can be enabled independently of NetworkService.
82const base::Feature kMojoBlobURLs{"MojoBlobURLs",
83 base::FEATURE_DISABLED_BY_DEFAULT};
84
Tarun Bansal422f9012019-01-23 16:55:5885// Used to control the collection of anchor element metrics (crbug.com/856683).
86// If kNavigationPredictor is enabled, then metrics of anchor elements
87// in the first viewport after the page load and the metrics of the clicked
88// anchor element will be extracted and recorded. Additionally, navigation
89// predictor may preconnect/prefetch to resources/origins to make the
90// future navigations faster.
91const base::Feature kNavigationPredictor{"NavigationPredictor",
92 base::FEATURE_DISABLED_BY_DEFAULT};
93
Hiroki Nakagawadf83a6f2019-01-28 06:07:4694// Enable off-the-main-thread dedicated worker script fetch.
95// (https://crbug.com/835717)
96const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
97 "OffMainThreadDedicatedWorkerScriptFetch",
98 base::FEATURE_DISABLED_BY_DEFAULT};
99
Kenichi Ishibashi5aa265a92019-02-28 07:01:45100// Enable off-the-main-thread service worker script fetch.
101// (https://crbug.com/924043)
102const base::Feature kOffMainThreadServiceWorkerScriptFetch{
103 "OffMainThreadServiceWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
104
Hiroki Nakagawa893ee502019-02-04 06:49:53105// Enable off-the-main-thread shared worker script fetch.
106// (https://crbug.com/924041)
107const base::Feature kOffMainThreadSharedWorkerScriptFetch{
108 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
109
Daniel Murphy80ce3022018-10-18 07:28:07110// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:55111const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:47112 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:55113
Hiroki Nakagawa61ee0042019-01-22 06:30:26114// Enable browser-initiated dedicated worker script loading
115// (PlzDedicatedWorker). https://crbug.com/906991
116const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
117 base::FEATURE_DISABLED_BY_DEFAULT};
118
Daniel Murphy95792ef2018-10-04 01:29:55119// Enable Portals. https://crbug.com/865123.
120const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
121
Tarun Bansal8df12b52019-02-15 05:46:30122// Enable limiting previews loading hints to specific resource types.
123const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
124 "PreviewsResourceLoadingHintsSpecificResourceTypes",
125 base::FEATURE_DISABLED_BY_DEFAULT};
126
Aditya Keerthie84331b32019-03-20 15:25:52127// Perform a memory purge after a renderer is backgrounded. Formerly labelled as
128// the "PurgeAndSuspend" experiment.
129//
130// TODO(adityakeerthi): Disabled by default on Mac and Android for historical
131// reasons. Consider enabling by default if experiment results are positive.
132// https://crbug.com/926186
133const base::Feature kPurgeRendererMemoryWhenBackgrounded {
134 "PurgeRendererMemoryWhenBackgrounded",
135#if defined(OS_MACOSX) || defined(OS_ANDROID)
136 base::FEATURE_DISABLED_BY_DEFAULT
137#else
138 base::FEATURE_ENABLED_BY_DEFAULT
139#endif
140};
141
David Bokan911bded2018-11-27 23:23:32142// Enable Implicit Root Scroller. https://crbug.com/903260.
143const base::Feature kImplicitRootScroller{"ImplicitRootScroller",
David Bokan5173a502019-01-11 22:06:48144 base::FEATURE_ENABLED_BY_DEFAULT};
David Bokan911bded2018-11-27 23:23:32145
Makoto Shimazu172eec02018-11-29 06:21:44146// Enables usage of getDisplayMedia() that allows capture of web content, see
147// https://crbug.com/865060.
148const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia",
149 base::FEATURE_ENABLED_BY_DEFAULT};
150
151// Changes the default RTCPeerConnection constructor behavior to use Unified
152// Plan as the SDP semantics. When the feature is enabled, Unified Plan is used
153// unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the
154// argument).
155const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault",
Henrik Boström07021ec82019-01-17 22:23:56156 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44157
Johannes Kronad5a4532019-01-09 11:17:46158// Determines if the SDP attrbute extmap-allow-mixed should be offered by
159// default or not. The default value can be overridden by passing
160// {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection
161// constructor.
162const base::Feature kRTCOfferExtmapAllowMixed{
163 "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT};
164
Ben Kelly24e20aa2019-04-25 21:27:16165const base::Feature kServiceWorkerIsolateInForeground{
166 "ServiceWorkerIsolateInForeground", base::FEATURE_DISABLED_BY_DEFAULT};
167
momohattfc352292018-08-29 05:12:36168const base::Feature kServiceWorkerImportedScriptUpdateCheck{
169 "ServiceWorkerImportedScriptUpdateCheck",
170 base::FEATURE_DISABLED_BY_DEFAULT};
171
Ben Kellye20dc402018-09-18 01:55:42172// Enables reading a subresource's body data and side data in parallel.
173const base::Feature kServiceWorkerParallelSideDataReading{
174 "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT};
175
Kenichi Ishibashi42f883d2019-01-11 08:26:14176const base::Feature kServiceWorkerAggressiveCodeCache{
177 "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
178
Makoto Shimazua8b3d742019-04-05 06:55:51179// Experiment of the delay from navigation to starting an update of a service
180// worker's script.
181const base::Feature kServiceWorkerUpdateDelay{
182 "ServiceWorkerUpdateDelay", base::FEATURE_DISABLED_BY_DEFAULT};
183
Scott Haseley8eefdcd2018-08-22 16:50:19184// Freeze scheduler task queues in background after allowed grace time.
185// "stop" is a legacy name.
186const base::Feature kStopInBackground {
187 "stop-in-background",
188#if defined(OS_ANDROID)
189 base::FEATURE_ENABLED_BY_DEFAULT
190#else
191 base::FEATURE_DISABLED_BY_DEFAULT
192#endif
193};
194
Takashi Sakamotoc19fc2b2019-04-10 06:30:52195// Freeze scheduler task queues in background on network idle.
196// This feature only works if stop-in-background is enabled.
197const base::Feature kFreezeBackgroundTabOnNetworkIdle{
198 "freeze-background-tab-on-network-idle", base::FEATURE_DISABLED_BY_DEFAULT};
199
Shubhie Panicker60bd4b02018-09-26 00:02:15200// Freeze non-timer task queues in background, after allowed grace time.
201// "stop" is a legacy name.
202const base::Feature kStopNonTimersInBackground {
203 "stop-non-timers-in-background",
204#if defined(OS_ANDROID)
205 base::FEATURE_ENABLED_BY_DEFAULT
206#else
207 base::FEATURE_DISABLED_BY_DEFAULT
208#endif
209};
Scott Haseley7757f6c2018-08-03 14:33:23210
David Bokane9370c22019-02-14 15:19:58211// Enable text snippets in URL fragments. https://crbug.com/919204.
212const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
213 base::FEATURE_DISABLED_BY_DEFAULT};
214
Bill Budge4d028f12018-11-20 15:05:12215// Enables the site isolated Wasm code cache that is keyed on the resource URL
216// and the origin lock of the renderer that is requesting the resource. When
217// this flag is enabled, content/GeneratedCodeCache handles code cache requests.
218const base::Feature kWasmCodeCache = {"WasmCodeCache",
219 base::FEATURE_DISABLED_BY_DEFAULT};
220
Marijn Kruisselbrinkca4bb5e2019-04-22 18:19:42221// Writable files and native file system access. https://crbug.com/853326
222const base::Feature kNativeFileSystemAPI{"NativeFileSystemAPI",
Marijn Kruisselbrinkfa0e1052019-03-05 22:32:55223 base::FEATURE_DISABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44224
Jay Harris583f48922019-05-06 05:55:24225// File handling integration. https://crbug.com/829689
226const base::Feature kFileHandlingAPI{"FileHandlingAPI",
227 base::FEATURE_DISABLED_BY_DEFAULT};
228
kdillon66bf5b522019-01-02 22:08:30229// Allows for synchronous XHR requests during page dismissal
230const base::Feature kForbidSyncXHRInPageDismissal{
Katie Dillon54c1ad222019-04-18 23:49:52231 "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT};
kdillon66bf5b522019-01-02 22:08:30232
Balazs Engedy130ab802019-02-22 12:14:00233// Emergency lever that can be used to restore DeviceOrientationEvent and
234// DeviceMotionEvent functionality in non-secure browsing contexts.
235// See: https://crbug.com/932078.
236const base::Feature kRestrictDeviceSensorEventsToSecureContexts{
237 "RestrictDeviceSensorEventsToSecureContexts",
Balazs Engedy4665f962019-02-27 10:53:09238 base::FEATURE_ENABLED_BY_DEFAULT};
Balazs Engedy130ab802019-02-22 12:14:00239
Carlos ILd3be52b2018-10-08 17:57:18240const char kMixedContentAutoupgradeModeParamName[] = "mode";
241const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
242const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
243 "optionally-blockable";
244
Madeleine Barowsky45be21a42018-12-07 18:39:30245// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
246// in the image decode cache. See crbug.com/900264 for details on the feature.
247const base::Feature kDecodeLossyWebPImagesToYUV{
248 "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
249
Aaron Krajeskif2f827d422019-01-08 15:08:34250// Use accelerated canvases whenever possible see https://crbug.com/909937
251const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas",
Aaron Krajeskiccfb9122019-04-25 21:28:44252 base::FEATURE_ENABLED_BY_DEFAULT};
Aaron Krajeskif2f827d422019-01-08 15:08:34253
Takashi Toyoshimaa91506d2019-03-28 05:44:42254// Enables cache-aware WebFonts loading. See https://crbug.com/570205.
255// The feature is disabled on Android for WebView API issue discussed at
256// https://crbug.com/942440.
257const base::Feature kWebFontsCacheAwareTimeoutAdaption {
258 "WebFontsCacheAwareTimeoutAdaption",
259#if defined(OS_ANDROID)
260 base::FEATURE_DISABLED_BY_DEFAULT
261#else
262 base::FEATURE_ENABLED_BY_DEFAULT
263#endif
264};
265
Hiroki Nakagawa893ee502019-02-04 06:49:53266bool IsOffMainThreadSharedWorkerScriptFetchEnabled() {
267 // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker
268 // (NetworkService).
269 DCHECK(!base::FeatureList::IsEnabled(
270 features::kOffMainThreadSharedWorkerScriptFetch) ||
271 base::FeatureList::IsEnabled(network::features::kNetworkService))
272 << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService "
273 << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService.";
274 return base::FeatureList::IsEnabled(network::features::kNetworkService) &&
275 base::FeatureList::IsEnabled(
276 features::kOffMainThreadSharedWorkerScriptFetch);
277}
278
Hiroki Nakagawa7d8cbfa2019-02-07 11:01:28279bool IsPlzDedicatedWorkerEnabled() {
280 // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script
281 // fetch and NetworkService.
282#if DCHECK_IS_ON()
283 if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) {
284 DCHECK(base::FeatureList::IsEnabled(
285 features::kOffMainThreadDedicatedWorkerScriptFetch))
286 << "PlzDedicatedWorker is enabled but "
287 << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker "
288 << "requires OffMainThreadDedicatedWorkerScriptFetch.";
289 DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService))
290 << "PlzDedicatedWorker is enabled but NetworkService isn't. "
291 << "PlzDedicatedWorker requires NetworkService.";
292 }
293#endif // DCHECK_IS_ON()
294 return base::FeatureList::IsEnabled(
295 features::kOffMainThreadDedicatedWorkerScriptFetch) &&
296 base::FeatureList::IsEnabled(network::features::kNetworkService) &&
297 base::FeatureList::IsEnabled(features::kPlzDedicatedWorker);
298}
299
Matt Falkenhagen5cc652792018-06-21 10:34:33300} // namespace features
301} // namespace blink