blob: 01a4ec793e2910286d1e5c9d55b509f7e3aed750 [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
Steve Kobesb51c2fed2019-02-27 15:36:3151// Enables the experimental sweep-line algorithm for tracking "jank" from
52// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1353const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
54 base::FEATURE_DISABLED_BY_DEFAULT};
55
Philip Rogers63481332018-12-01 22:16:5156// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
57// generates the compositor property trees. See: https://crbug.com/836884.
58const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers3010556c2019-03-12 20:53:2259 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5160
Ian Kilpatricke68ef11a2018-07-04 03:52:1061// Enable LayoutNG.
62const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
63
Makoto Shimazu172eec02018-11-29 06:21:4464const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
65 base::FEATURE_DISABLED_BY_DEFAULT};
66
Marijn Kruisselbrinkcde64632018-06-22 22:45:1667// Enable mojo Blob URL interface and better blob URL lifetime management.
68// Can be enabled independently of NetworkService.
69const base::Feature kMojoBlobURLs{"MojoBlobURLs",
70 base::FEATURE_DISABLED_BY_DEFAULT};
71
Tarun Bansal422f9012019-01-23 16:55:5872// Used to control the collection of anchor element metrics (crbug.com/856683).
73// If kNavigationPredictor is enabled, then metrics of anchor elements
74// in the first viewport after the page load and the metrics of the clicked
75// anchor element will be extracted and recorded. Additionally, navigation
76// predictor may preconnect/prefetch to resources/origins to make the
77// future navigations faster.
78const base::Feature kNavigationPredictor{"NavigationPredictor",
79 base::FEATURE_DISABLED_BY_DEFAULT};
80
Hiroki Nakagawadf83a6f2019-01-28 06:07:4681// Enable off-the-main-thread dedicated worker script fetch.
82// (https://crbug.com/835717)
83const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
84 "OffMainThreadDedicatedWorkerScriptFetch",
85 base::FEATURE_DISABLED_BY_DEFAULT};
86
Kenichi Ishibashi5aa265a92019-02-28 07:01:4587// Enable off-the-main-thread service worker script fetch.
88// (https://crbug.com/924043)
89const base::Feature kOffMainThreadServiceWorkerScriptFetch{
90 "OffMainThreadServiceWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
91
Hiroki Nakagawa893ee502019-02-04 06:49:5392// Enable off-the-main-thread shared worker script fetch.
93// (https://crbug.com/924041)
94const base::Feature kOffMainThreadSharedWorkerScriptFetch{
95 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
96
Daniel Murphy80ce3022018-10-18 07:28:0797// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:5598const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:4799 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:55100
Hiroki Nakagawa61ee0042019-01-22 06:30:26101// Enable browser-initiated dedicated worker script loading
102// (PlzDedicatedWorker). https://crbug.com/906991
103const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
104 base::FEATURE_DISABLED_BY_DEFAULT};
105
Daniel Murphy95792ef2018-10-04 01:29:55106// Enable Portals. https://crbug.com/865123.
107const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
108
Tarun Bansal8df12b52019-02-15 05:46:30109// Enable limiting previews loading hints to specific resource types.
110const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
111 "PreviewsResourceLoadingHintsSpecificResourceTypes",
112 base::FEATURE_DISABLED_BY_DEFAULT};
113
Aditya Keerthie84331b32019-03-20 15:25:52114// Perform a memory purge after a renderer is backgrounded. Formerly labelled as
115// the "PurgeAndSuspend" experiment.
116//
117// TODO(adityakeerthi): Disabled by default on Mac and Android for historical
118// reasons. Consider enabling by default if experiment results are positive.
119// https://crbug.com/926186
120const base::Feature kPurgeRendererMemoryWhenBackgrounded {
121 "PurgeRendererMemoryWhenBackgrounded",
122#if defined(OS_MACOSX) || defined(OS_ANDROID)
123 base::FEATURE_DISABLED_BY_DEFAULT
124#else
125 base::FEATURE_ENABLED_BY_DEFAULT
126#endif
127};
128
David Bokan911bded2018-11-27 23:23:32129// Enable Implicit Root Scroller. https://crbug.com/903260.
130const base::Feature kImplicitRootScroller{"ImplicitRootScroller",
David Bokan5173a502019-01-11 22:06:48131 base::FEATURE_ENABLED_BY_DEFAULT};
David Bokan911bded2018-11-27 23:23:32132
Makoto Shimazu172eec02018-11-29 06:21:44133// Enables usage of getDisplayMedia() that allows capture of web content, see
134// https://crbug.com/865060.
135const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia",
136 base::FEATURE_ENABLED_BY_DEFAULT};
137
138// Changes the default RTCPeerConnection constructor behavior to use Unified
139// Plan as the SDP semantics. When the feature is enabled, Unified Plan is used
140// unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the
141// argument).
142const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault",
Henrik Boström07021ec82019-01-17 22:23:56143 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44144
Johannes Kronad5a4532019-01-09 11:17:46145// Determines if the SDP attrbute extmap-allow-mixed should be offered by
146// default or not. The default value can be overridden by passing
147// {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection
148// constructor.
149const base::Feature kRTCOfferExtmapAllowMixed{
150 "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT};
151
Ben Kelly24e20aa2019-04-25 21:27:16152const base::Feature kServiceWorkerIsolateInForeground{
153 "ServiceWorkerIsolateInForeground", base::FEATURE_DISABLED_BY_DEFAULT};
154
momohattfc352292018-08-29 05:12:36155const base::Feature kServiceWorkerImportedScriptUpdateCheck{
156 "ServiceWorkerImportedScriptUpdateCheck",
157 base::FEATURE_DISABLED_BY_DEFAULT};
158
Ben Kellye20dc402018-09-18 01:55:42159// Enables reading a subresource's body data and side data in parallel.
160const base::Feature kServiceWorkerParallelSideDataReading{
161 "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT};
162
Kenichi Ishibashi42f883d2019-01-11 08:26:14163const base::Feature kServiceWorkerAggressiveCodeCache{
164 "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
165
Makoto Shimazua8b3d742019-04-05 06:55:51166// Experiment of the delay from navigation to starting an update of a service
167// worker's script.
168const base::Feature kServiceWorkerUpdateDelay{
169 "ServiceWorkerUpdateDelay", base::FEATURE_DISABLED_BY_DEFAULT};
170
Scott Haseley8eefdcd2018-08-22 16:50:19171// Freeze scheduler task queues in background after allowed grace time.
172// "stop" is a legacy name.
173const base::Feature kStopInBackground {
174 "stop-in-background",
175#if defined(OS_ANDROID)
176 base::FEATURE_ENABLED_BY_DEFAULT
177#else
178 base::FEATURE_DISABLED_BY_DEFAULT
179#endif
180};
181
Takashi Sakamotoc19fc2b2019-04-10 06:30:52182// Freeze scheduler task queues in background on network idle.
183// This feature only works if stop-in-background is enabled.
184const base::Feature kFreezeBackgroundTabOnNetworkIdle{
185 "freeze-background-tab-on-network-idle", base::FEATURE_DISABLED_BY_DEFAULT};
186
Shubhie Panicker60bd4b02018-09-26 00:02:15187// Freeze non-timer task queues in background, after allowed grace time.
188// "stop" is a legacy name.
189const base::Feature kStopNonTimersInBackground {
190 "stop-non-timers-in-background",
191#if defined(OS_ANDROID)
192 base::FEATURE_ENABLED_BY_DEFAULT
193#else
194 base::FEATURE_DISABLED_BY_DEFAULT
195#endif
196};
Scott Haseley7757f6c2018-08-03 14:33:23197
David Bokane9370c22019-02-14 15:19:58198// Enable text snippets in URL fragments. https://crbug.com/919204.
199const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
200 base::FEATURE_DISABLED_BY_DEFAULT};
201
Bill Budge4d028f12018-11-20 15:05:12202// Enables the site isolated Wasm code cache that is keyed on the resource URL
203// and the origin lock of the renderer that is requesting the resource. When
204// this flag is enabled, content/GeneratedCodeCache handles code cache requests.
205const base::Feature kWasmCodeCache = {"WasmCodeCache",
206 base::FEATURE_DISABLED_BY_DEFAULT};
207
Marijn Kruisselbrinkca4bb5e2019-04-22 18:19:42208// Writable files and native file system access. https://crbug.com/853326
209const base::Feature kNativeFileSystemAPI{"NativeFileSystemAPI",
Marijn Kruisselbrinkfa0e1052019-03-05 22:32:55210 base::FEATURE_DISABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44211
kdillon66bf5b522019-01-02 22:08:30212// Allows for synchronous XHR requests during page dismissal
213const base::Feature kForbidSyncXHRInPageDismissal{
Katie Dillon54c1ad222019-04-18 23:49:52214 "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT};
kdillon66bf5b522019-01-02 22:08:30215
Balazs Engedy130ab802019-02-22 12:14:00216// Emergency lever that can be used to restore DeviceOrientationEvent and
217// DeviceMotionEvent functionality in non-secure browsing contexts.
218// See: https://crbug.com/932078.
219const base::Feature kRestrictDeviceSensorEventsToSecureContexts{
220 "RestrictDeviceSensorEventsToSecureContexts",
Balazs Engedy4665f962019-02-27 10:53:09221 base::FEATURE_ENABLED_BY_DEFAULT};
Balazs Engedy130ab802019-02-22 12:14:00222
Carlos ILd3be52b2018-10-08 17:57:18223const char kMixedContentAutoupgradeModeParamName[] = "mode";
224const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
225const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
226 "optionally-blockable";
227
Madeleine Barowsky45be21a42018-12-07 18:39:30228// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
229// in the image decode cache. See crbug.com/900264 for details on the feature.
230const base::Feature kDecodeLossyWebPImagesToYUV{
231 "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
232
Aaron Krajeskif2f827d422019-01-08 15:08:34233// Use accelerated canvases whenever possible see https://crbug.com/909937
234const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas",
Aaron Krajeskiccfb9122019-04-25 21:28:44235 base::FEATURE_ENABLED_BY_DEFAULT};
Aaron Krajeskif2f827d422019-01-08 15:08:34236
Takashi Toyoshimaa91506d2019-03-28 05:44:42237// Enables cache-aware WebFonts loading. See https://crbug.com/570205.
238// The feature is disabled on Android for WebView API issue discussed at
239// https://crbug.com/942440.
240const base::Feature kWebFontsCacheAwareTimeoutAdaption {
241 "WebFontsCacheAwareTimeoutAdaption",
242#if defined(OS_ANDROID)
243 base::FEATURE_DISABLED_BY_DEFAULT
244#else
245 base::FEATURE_ENABLED_BY_DEFAULT
246#endif
247};
248
Hiroki Nakagawa893ee502019-02-04 06:49:53249bool IsOffMainThreadSharedWorkerScriptFetchEnabled() {
250 // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker
251 // (NetworkService).
252 DCHECK(!base::FeatureList::IsEnabled(
253 features::kOffMainThreadSharedWorkerScriptFetch) ||
254 base::FeatureList::IsEnabled(network::features::kNetworkService))
255 << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService "
256 << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService.";
257 return base::FeatureList::IsEnabled(network::features::kNetworkService) &&
258 base::FeatureList::IsEnabled(
259 features::kOffMainThreadSharedWorkerScriptFetch);
260}
261
Hiroki Nakagawa7d8cbfa2019-02-07 11:01:28262bool IsPlzDedicatedWorkerEnabled() {
263 // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script
264 // fetch and NetworkService.
265#if DCHECK_IS_ON()
266 if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) {
267 DCHECK(base::FeatureList::IsEnabled(
268 features::kOffMainThreadDedicatedWorkerScriptFetch))
269 << "PlzDedicatedWorker is enabled but "
270 << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker "
271 << "requires OffMainThreadDedicatedWorkerScriptFetch.";
272 DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService))
273 << "PlzDedicatedWorker is enabled but NetworkService isn't. "
274 << "PlzDedicatedWorker requires NetworkService.";
275 }
276#endif // DCHECK_IS_ON()
277 return base::FeatureList::IsEnabled(
278 features::kOffMainThreadDedicatedWorkerScriptFetch) &&
279 base::FeatureList::IsEnabled(network::features::kNetworkService) &&
280 base::FeatureList::IsEnabled(features::kPlzDedicatedWorker);
281}
282
Matt Falkenhagen5cc652792018-06-21 10:34:33283} // namespace features
284} // namespace blink