blob: 8e44bec519ae60b36abf01abfa202370006fc60a [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
Aditya Keerthi6a933902019-03-14 21:09:2737// Perform memory purges after freezing only if all pages are frozen.
38const base::Feature kFreezePurgeMemoryAllPagesFrozen{
39 "FreezePurgeMemoryAllPagesFrozen", base::FEATURE_DISABLED_BY_DEFAULT};
40
Steve Kobesb51c2fed2019-02-27 15:36:3141// Enables the experimental sweep-line algorithm for tracking "jank" from
42// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1343const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
44 base::FEATURE_DISABLED_BY_DEFAULT};
45
Philip Rogers63481332018-12-01 22:16:5146// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
47// generates the compositor property trees. See: https://crbug.com/836884.
48const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers3010556c2019-03-12 20:53:2249 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5150
Ian Kilpatricke68ef11a2018-07-04 03:52:1051// Enable LayoutNG.
52const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
53
Makoto Shimazu172eec02018-11-29 06:21:4454const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
55 base::FEATURE_DISABLED_BY_DEFAULT};
56
Marijn Kruisselbrinkcde64632018-06-22 22:45:1657// Enable mojo Blob URL interface and better blob URL lifetime management.
58// Can be enabled independently of NetworkService.
59const base::Feature kMojoBlobURLs{"MojoBlobURLs",
60 base::FEATURE_DISABLED_BY_DEFAULT};
61
Tarun Bansal422f9012019-01-23 16:55:5862// Used to control the collection of anchor element metrics (crbug.com/856683).
63// If kNavigationPredictor is enabled, then metrics of anchor elements
64// in the first viewport after the page load and the metrics of the clicked
65// anchor element will be extracted and recorded. Additionally, navigation
66// predictor may preconnect/prefetch to resources/origins to make the
67// future navigations faster.
68const base::Feature kNavigationPredictor{"NavigationPredictor",
69 base::FEATURE_DISABLED_BY_DEFAULT};
70
Hiroki Nakagawadf83a6f2019-01-28 06:07:4671// Enable off-the-main-thread dedicated worker script fetch.
72// (https://crbug.com/835717)
73const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
74 "OffMainThreadDedicatedWorkerScriptFetch",
75 base::FEATURE_DISABLED_BY_DEFAULT};
76
Kenichi Ishibashi5aa265a92019-02-28 07:01:4577// Enable off-the-main-thread service worker script fetch.
78// (https://crbug.com/924043)
79const base::Feature kOffMainThreadServiceWorkerScriptFetch{
80 "OffMainThreadServiceWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
81
Hiroki Nakagawa893ee502019-02-04 06:49:5382// Enable off-the-main-thread shared worker script fetch.
83// (https://crbug.com/924041)
84const base::Feature kOffMainThreadSharedWorkerScriptFetch{
85 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
86
Daniel Murphy80ce3022018-10-18 07:28:0787// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:5588const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:4789 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:5590
Hiroki Nakagawa61ee0042019-01-22 06:30:2691// Enable browser-initiated dedicated worker script loading
92// (PlzDedicatedWorker). https://crbug.com/906991
93const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
94 base::FEATURE_DISABLED_BY_DEFAULT};
95
Daniel Murphy95792ef2018-10-04 01:29:5596// Enable Portals. https://crbug.com/865123.
97const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
98
Tarun Bansal8df12b52019-02-15 05:46:3099// Enable limiting previews loading hints to specific resource types.
100const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
101 "PreviewsResourceLoadingHintsSpecificResourceTypes",
102 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
Scott Haseley8eefdcd2018-08-22 16:50:19144// Freeze scheduler task queues in background after allowed grace time.
145// "stop" is a legacy name.
146const base::Feature kStopInBackground {
147 "stop-in-background",
148#if defined(OS_ANDROID)
149 base::FEATURE_ENABLED_BY_DEFAULT
150#else
151 base::FEATURE_DISABLED_BY_DEFAULT
152#endif
153};
154
Shubhie Panicker60bd4b02018-09-26 00:02:15155// Freeze non-timer task queues in background, after allowed grace time.
156// "stop" is a legacy name.
157const base::Feature kStopNonTimersInBackground {
158 "stop-non-timers-in-background",
159#if defined(OS_ANDROID)
160 base::FEATURE_ENABLED_BY_DEFAULT
161#else
162 base::FEATURE_DISABLED_BY_DEFAULT
163#endif
164};
Scott Haseley7757f6c2018-08-03 14:33:23165
David Bokane9370c22019-02-14 15:19:58166// Enable text snippets in URL fragments. https://crbug.com/919204.
167const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
168 base::FEATURE_DISABLED_BY_DEFAULT};
169
Bill Budge4d028f12018-11-20 15:05:12170// Enables the site isolated Wasm code cache that is keyed on the resource URL
171// and the origin lock of the renderer that is requesting the resource. When
172// this flag is enabled, content/GeneratedCodeCache handles code cache requests.
173const base::Feature kWasmCodeCache = {"WasmCodeCache",
174 base::FEATURE_DISABLED_BY_DEFAULT};
175
Makoto Shimazu172eec02018-11-29 06:21:44176// Writable files and native filesystem access. https://crbug.com/853326
Marijn Kruisselbrinkfa0e1052019-03-05 22:32:55177const base::Feature kNativeFilesystemAPI{"NativeFilesystemAPI",
178 base::FEATURE_DISABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44179
kdillon66bf5b522019-01-02 22:08:30180// Allows for synchronous XHR requests during page dismissal
181const base::Feature kForbidSyncXHRInPageDismissal{
182 "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT};
183
Balazs Engedy130ab802019-02-22 12:14:00184// Emergency lever that can be used to restore DeviceOrientationEvent and
185// DeviceMotionEvent functionality in non-secure browsing contexts.
186// See: https://crbug.com/932078.
187const base::Feature kRestrictDeviceSensorEventsToSecureContexts{
188 "RestrictDeviceSensorEventsToSecureContexts",
Balazs Engedy4665f962019-02-27 10:53:09189 base::FEATURE_ENABLED_BY_DEFAULT};
Balazs Engedy130ab802019-02-22 12:14:00190
Carlos ILd3be52b2018-10-08 17:57:18191const char kMixedContentAutoupgradeModeParamName[] = "mode";
192const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
193const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
194 "optionally-blockable";
195
Madeleine Barowsky45be21a42018-12-07 18:39:30196// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
197// in the image decode cache. See crbug.com/900264 for details on the feature.
198const base::Feature kDecodeLossyWebPImagesToYUV{
199 "DecodeLossyWebPImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
200
Aaron Krajeskif2f827d422019-01-08 15:08:34201// Use accelerated canvases whenever possible see https://crbug.com/909937
202const base::Feature kAlwaysAccelerateCanvas{"AlwaysAccelerateCanvas",
203 base::FEATURE_DISABLED_BY_DEFAULT};
204
Hiroki Nakagawa893ee502019-02-04 06:49:53205bool IsOffMainThreadSharedWorkerScriptFetchEnabled() {
206 // Off-the-main-thread shared worker script fetch depends on PlzSharedWorker
207 // (NetworkService).
208 DCHECK(!base::FeatureList::IsEnabled(
209 features::kOffMainThreadSharedWorkerScriptFetch) ||
210 base::FeatureList::IsEnabled(network::features::kNetworkService))
211 << "OffMainThreadSharedWorkerScriptFetch is enabled but NetworkService "
212 << "isn't. OffMainThreadSharedWorkerScriptFetch requires NetworkService.";
213 return base::FeatureList::IsEnabled(network::features::kNetworkService) &&
214 base::FeatureList::IsEnabled(
215 features::kOffMainThreadSharedWorkerScriptFetch);
216}
217
Hiroki Nakagawa7d8cbfa2019-02-07 11:01:28218bool IsPlzDedicatedWorkerEnabled() {
219 // PlzDedicatedWorker depends on off-the-main-thread dedicated worker script
220 // fetch and NetworkService.
221#if DCHECK_IS_ON()
222 if (base::FeatureList::IsEnabled(features::kPlzDedicatedWorker)) {
223 DCHECK(base::FeatureList::IsEnabled(
224 features::kOffMainThreadDedicatedWorkerScriptFetch))
225 << "PlzDedicatedWorker is enabled but "
226 << "OffMainThreadDedicatedWorkerScriptFetch isn't. PlzDedicatedWorker "
227 << "requires OffMainThreadDedicatedWorkerScriptFetch.";
228 DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService))
229 << "PlzDedicatedWorker is enabled but NetworkService isn't. "
230 << "PlzDedicatedWorker requires NetworkService.";
231 }
232#endif // DCHECK_IS_ON()
233 return base::FeatureList::IsEnabled(
234 features::kOffMainThreadDedicatedWorkerScriptFetch) &&
235 base::FeatureList::IsEnabled(network::features::kNetworkService) &&
236 base::FeatureList::IsEnabled(features::kPlzDedicatedWorker);
237}
238
Matt Falkenhagen5cc652792018-06-21 10:34:33239} // namespace features
240} // namespace blink