blob: 4c520a046425c155418bc657633809218f84c2a9 [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
Liquan(Max) Gu4e243fc2018-11-17 00:13:0239// Enable FCP++ by experiment. See https://crbug.com/869924
40const base::Feature kFirstContentfulPaintPlusPlus{
41 "FirstContentfulPaintPlusPlus", base::FEATURE_DISABLED_BY_DEFAULT};
42
Aditya Keerthi6a933902019-03-14 21:09:2743// Perform memory purges after freezing only if all pages are frozen.
44const base::Feature kFreezePurgeMemoryAllPagesFrozen{
45 "FreezePurgeMemoryAllPagesFrozen", base::FEATURE_DISABLED_BY_DEFAULT};
46
Aditya Keerthi8e3c4832019-03-28 14:50:3647// Controls whether or not the font cache is invalidated when a critical memory
48// pressure signal is sent.
49const base::Feature kInvalidateFontCacheOnPurge{
50 "InvalidateFontCacheOnPurge", base::FEATURE_ENABLED_BY_DEFAULT};
51
Steve Kobesb51c2fed2019-02-27 15:36:3152// Enables the experimental sweep-line algorithm for tracking "jank" from
53// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1354const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
55 base::FEATURE_DISABLED_BY_DEFAULT};
56
Philip Rogers63481332018-12-01 22:16:5157// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
58// generates the compositor property trees. See: https://crbug.com/836884.
59const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers3010556c2019-03-12 20:53:2260 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5161
Ian Kilpatricke68ef11a2018-07-04 03:52:1062// Enable LayoutNG.
63const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
64
Makoto Shimazu172eec02018-11-29 06:21:4465const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
66 base::FEATURE_DISABLED_BY_DEFAULT};
67
Marijn Kruisselbrinkcde64632018-06-22 22:45:1668// Enable mojo Blob URL interface and better blob URL lifetime management.
69// Can be enabled independently of NetworkService.
70const base::Feature kMojoBlobURLs{"MojoBlobURLs",
71 base::FEATURE_DISABLED_BY_DEFAULT};
72
Tarun Bansal422f9012019-01-23 16:55:5873// Used to control the collection of anchor element metrics (crbug.com/856683).
74// If kNavigationPredictor is enabled, then metrics of anchor elements
75// in the first viewport after the page load and the metrics of the clicked
76// anchor element will be extracted and recorded. Additionally, navigation
77// predictor may preconnect/prefetch to resources/origins to make the
78// future navigations faster.
79const base::Feature kNavigationPredictor{"NavigationPredictor",
80 base::FEATURE_DISABLED_BY_DEFAULT};
81
Hiroki Nakagawadf83a6f2019-01-28 06:07:4682// Enable off-the-main-thread dedicated worker script fetch.
83// (https://crbug.com/835717)
84const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
85 "OffMainThreadDedicatedWorkerScriptFetch",
86 base::FEATURE_DISABLED_BY_DEFAULT};
87
Kenichi Ishibashi5aa265a92019-02-28 07:01:4588// Enable off-the-main-thread service worker script fetch.
89// (https://crbug.com/924043)
90const base::Feature kOffMainThreadServiceWorkerScriptFetch{
91 "OffMainThreadServiceWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
92
Hiroki Nakagawa893ee502019-02-04 06:49:5393// Enable off-the-main-thread shared worker script fetch.
94// (https://crbug.com/924041)
95const base::Feature kOffMainThreadSharedWorkerScriptFetch{
96 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
97
Daniel Murphy80ce3022018-10-18 07:28:0798// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:5599const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:47100 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:55101
Hiroki Nakagawa61ee0042019-01-22 06:30:26102// Enable browser-initiated dedicated worker script loading
103// (PlzDedicatedWorker). https://crbug.com/906991
104const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
105 base::FEATURE_DISABLED_BY_DEFAULT};
106
Daniel Murphy95792ef2018-10-04 01:29:55107// Enable Portals. https://crbug.com/865123.
108const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
109
Tarun Bansal8df12b52019-02-15 05:46:30110// Enable limiting previews loading hints to specific resource types.
111const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
112 "PreviewsResourceLoadingHintsSpecificResourceTypes",
113 base::FEATURE_DISABLED_BY_DEFAULT};
114
Aditya Keerthie84331b32019-03-20 15:25:52115// Perform a memory purge after a renderer is backgrounded. Formerly labelled as
116// the "PurgeAndSuspend" experiment.
117//
118// TODO(adityakeerthi): Disabled by default on Mac and Android for historical
119// reasons. Consider enabling by default if experiment results are positive.
120// https://crbug.com/926186
121const base::Feature kPurgeRendererMemoryWhenBackgrounded {
122 "PurgeRendererMemoryWhenBackgrounded",
123#if defined(OS_MACOSX) || defined(OS_ANDROID)
124 base::FEATURE_DISABLED_BY_DEFAULT
125#else
126 base::FEATURE_ENABLED_BY_DEFAULT
127#endif
128};
129
David Bokan911bded2018-11-27 23:23:32130// Enable Implicit Root Scroller. https://crbug.com/903260.
131const base::Feature kImplicitRootScroller{"ImplicitRootScroller",
David Bokan5173a502019-01-11 22:06:48132 base::FEATURE_ENABLED_BY_DEFAULT};
David Bokan911bded2018-11-27 23:23:32133
Makoto Shimazu172eec02018-11-29 06:21:44134// Enables usage of getDisplayMedia() that allows capture of web content, see
135// https://crbug.com/865060.
136const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia",
137 base::FEATURE_ENABLED_BY_DEFAULT};
138
139// Changes the default RTCPeerConnection constructor behavior to use Unified
140// Plan as the SDP semantics. When the feature is enabled, Unified Plan is used
141// unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the
142// argument).
143const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault",
Henrik Boström07021ec82019-01-17 22:23:56144 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44145
Johannes Kronad5a4532019-01-09 11:17:46146// Determines if the SDP attrbute extmap-allow-mixed should be offered by
147// default or not. The default value can be overridden by passing
148// {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection
149// constructor.
150const base::Feature kRTCOfferExtmapAllowMixed{
151 "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT};
152
momohattfc352292018-08-29 05:12:36153const base::Feature kServiceWorkerImportedScriptUpdateCheck{
154 "ServiceWorkerImportedScriptUpdateCheck",
155 base::FEATURE_DISABLED_BY_DEFAULT};
156
Ben Kellye20dc402018-09-18 01:55:42157// Enables reading a subresource's body data and side data in parallel.
158const base::Feature kServiceWorkerParallelSideDataReading{
159 "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT};
160
Kenichi Ishibashi42f883d2019-01-11 08:26:14161const base::Feature kServiceWorkerAggressiveCodeCache{
162 "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
163
Makoto Shimazua8b3d742019-04-05 06:55:51164// Experiment of the delay from navigation to starting an update of a service
165// worker's script.
166const base::Feature kServiceWorkerUpdateDelay{
167 "ServiceWorkerUpdateDelay", base::FEATURE_DISABLED_BY_DEFAULT};
168
Scott Haseley8eefdcd2018-08-22 16:50:19169// Freeze scheduler task queues in background after allowed grace time.
170// "stop" is a legacy name.
171const base::Feature kStopInBackground {
172 "stop-in-background",
173#if defined(OS_ANDROID)
174 base::FEATURE_ENABLED_BY_DEFAULT
175#else
176 base::FEATURE_DISABLED_BY_DEFAULT
177#endif
178};
179
Shubhie Panicker60bd4b02018-09-26 00:02:15180// Freeze non-timer task queues in background, after allowed grace time.
181// "stop" is a legacy name.
182const base::Feature kStopNonTimersInBackground {
183 "stop-non-timers-in-background",
184#if defined(OS_ANDROID)
185 base::FEATURE_ENABLED_BY_DEFAULT
186#else
187 base::FEATURE_DISABLED_BY_DEFAULT
188#endif
189};
Scott Haseley7757f6c2018-08-03 14:33:23190
David Bokane9370c22019-02-14 15:19:58191// Enable text snippets in URL fragments. https://crbug.com/919204.
192const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
193 base::FEATURE_DISABLED_BY_DEFAULT};
194
Bill Budge4d028f12018-11-20 15:05:12195// Enables the site isolated Wasm code cache that is keyed on the resource URL
196// and the origin lock of the renderer that is requesting the resource. When
197// this flag is enabled, content/GeneratedCodeCache handles code cache requests.
198const base::Feature kWasmCodeCache = {"WasmCodeCache",
199 base::FEATURE_DISABLED_BY_DEFAULT};
200
Makoto Shimazu172eec02018-11-29 06:21:44201// Writable files and native filesystem access. https://crbug.com/853326
Marijn Kruisselbrinkfa0e1052019-03-05 22:32:55202const base::Feature kNativeFilesystemAPI{"NativeFilesystemAPI",
203 base::FEATURE_DISABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44204
kdillon66bf5b522019-01-02 22:08:30205// Allows for synchronous XHR requests during page dismissal
206const base::Feature kForbidSyncXHRInPageDismissal{
207 "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT};
208
Balazs Engedy130ab802019-02-22 12:14:00209// Emergency lever that can be used to restore DeviceOrientationEvent and
210// DeviceMotionEvent functionality in non-secure browsing contexts.
211// See: https://crbug.com/932078.
212const base::Feature kRestrictDeviceSensorEventsToSecureContexts{
213 "RestrictDeviceSensorEventsToSecureContexts",
Balazs Engedy4665f962019-02-27 10:53:09214 base::FEATURE_ENABLED_BY_DEFAULT};
Balazs Engedy130ab802019-02-22 12:14:00215
Carlos ILd3be52b2018-10-08 17:57:18216const char kMixedContentAutoupgradeModeParamName[] = "mode";
217const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
218const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
219 "optionally-blockable";
220
Madeleine Barowsky45be21a42018-12-07 18:39:30221// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
222// in the image decode cache. See crbug.com/900264 for details on the feature.
223const base::Feature kDecodeLossyWebPImagesToYUV{
224 "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
225
Aaron Krajeskif2f827d422019-01-08 15:08:34226// Use accelerated canvases whenever possible see https://crbug.com/909937
227const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas",
228 base::FEATURE_DISABLED_BY_DEFAULT};
229
Takashi Toyoshimaa91506d2019-03-28 05:44:42230// Enables cache-aware WebFonts loading. See https://crbug.com/570205.
231// The feature is disabled on Android for WebView API issue discussed at
232// https://crbug.com/942440.
233const base::Feature kWebFontsCacheAwareTimeoutAdaption {
234 "WebFontsCacheAwareTimeoutAdaption",
235#if defined(OS_ANDROID)
236 base::FEATURE_DISABLED_BY_DEFAULT
237#else
238 base::FEATURE_ENABLED_BY_DEFAULT
239#endif
240};
241
Hiroki Nakagawa893ee502019-02-04 06:49:53242bool IsOffMainThreadSharedWorkerScriptFetchEnabled() {
243 // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker
244 // (NetworkService).
245 DCHECK(!base::FeatureList::IsEnabled(
246 features::kOffMainThreadSharedWorkerScriptFetch) ||
247 base::FeatureList::IsEnabled(network::features::kNetworkService))
248 << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService "
249 << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService.";
250 return base::FeatureList::IsEnabled(network::features::kNetworkService) &&
251 base::FeatureList::IsEnabled(
252 features::kOffMainThreadSharedWorkerScriptFetch);
253}
254
Hiroki Nakagawa7d8cbfa2019-02-07 11:01:28255bool IsPlzDedicatedWorkerEnabled() {
256 // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script
257 // fetch and NetworkService.
258#if DCHECK_IS_ON()
259 if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) {
260 DCHECK(base::FeatureList::IsEnabled(
261 features::kOffMainThreadDedicatedWorkerScriptFetch))
262 << "PlzDedicatedWorker is enabled but "
263 << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker "
264 << "requires OffMainThreadDedicatedWorkerScriptFetch.";
265 DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService))
266 << "PlzDedicatedWorker is enabled but NetworkService isn't. "
267 << "PlzDedicatedWorker requires NetworkService.";
268 }
269#endif // DCHECK_IS_ON()
270 return base::FeatureList::IsEnabled(
271 features::kOffMainThreadDedicatedWorkerScriptFetch) &&
272 base::FeatureList::IsEnabled(network::features::kNetworkService) &&
273 base::FeatureList::IsEnabled(features::kPlzDedicatedWorker);
274}
275
Matt Falkenhagen5cc652792018-06-21 10:34:33276} // namespace features
277} // namespace blink