blob: 80009d72155cc274da2e76a70f08f48593a55784 [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
Steve Kobesb51c2fed2019-02-27 15:36:3137// Enables the experimental sweep-line algorithm for tracking "jank" from
38// layout objects changing their visual location between animation frames.
Steve Kobesaa9c7c22019-01-21 18:24:1339const base::Feature kJankTrackingSweepLine{"JankTrackingSweepLine",
40 base::FEATURE_DISABLED_BY_DEFAULT};
41
Philip Rogers63481332018-12-01 22:16:5142// Enable a new compositing mode called BlinkGenPropertyTrees where Blink
43// generates the compositor property trees. See: https://crbug.com/836884.
44const base::Feature kBlinkGenPropertyTrees{"BlinkGenPropertyTrees",
Philip Rogers9cdf4322019-02-25 21:37:1545 base::FEATURE_ENABLED_BY_DEFAULT};
Philip Rogers63481332018-12-01 22:16:5146
Ian Kilpatricke68ef11a2018-07-04 03:52:1047// Enable LayoutNG.
48const base::Feature kLayoutNG{"LayoutNG", base::FEATURE_DISABLED_BY_DEFAULT};
49
Makoto Shimazu172eec02018-11-29 06:21:4450const base::Feature kMixedContentAutoupgrade{"AutoupgradeMixedContent",
51 base::FEATURE_DISABLED_BY_DEFAULT};
52
Marijn Kruisselbrinkcde64632018-06-22 22:45:1653// Enable mojo Blob URL interface and better blob URL lifetime management.
54// Can be enabled independently of NetworkService.
55const base::Feature kMojoBlobURLs{"MojoBlobURLs",
56 base::FEATURE_DISABLED_BY_DEFAULT};
57
Tarun Bansal422f9012019-01-23 16:55:5858// Used to control the collection of anchor element metrics (crbug.com/856683).
59// If kNavigationPredictor is enabled, then metrics of anchor elements
60// in the first viewport after the page load and the metrics of the clicked
61// anchor element will be extracted and recorded. Additionally, navigation
62// predictor may preconnect/prefetch to resources/origins to make the
63// future navigations faster.
64const base::Feature kNavigationPredictor{"NavigationPredictor",
65 base::FEATURE_DISABLED_BY_DEFAULT};
66
Hiroki Nakagawadf83a6f2019-01-28 06:07:4667// Enable off-the-main-thread dedicated worker script fetch.
68// (https://crbug.com/835717)
69const base::Feature kOffMainThreadDedicatedWorkerScriptFetch{
70 "OffMainThreadDedicatedWorkerScriptFetch",
71 base::FEATURE_DISABLED_BY_DEFAULT};
72
Hiroki Nakagawa893ee502019-02-04 06:49:5373// Enable off-the-main-thread shared worker script fetch.
74// (https://crbug.com/924041)
75const base::Feature kOffMainThreadSharedWorkerScriptFetch{
76 "OffMainThreadSharedWorkerScriptFetch", base::FEATURE_DISABLED_BY_DEFAULT};
77
Daniel Murphy80ce3022018-10-18 07:28:0778// Onion souping for all DOMStorage. https://crbug.com/781870
Daniel Murphy95792ef2018-10-04 01:29:5579const base::Feature kOnionSoupDOMStorage{"OnionSoupDOMStorage",
Daniel Murphydc4aa5a72019-02-07 22:08:4780 base::FEATURE_ENABLED_BY_DEFAULT};
Daniel Murphy95792ef2018-10-04 01:29:5581
Hiroki Nakagawa61ee0042019-01-22 06:30:2682// Enable browser-initiated dedicated worker script loading
83// (PlzDedicatedWorker). https://crbug.com/906991
84const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
85 base::FEATURE_DISABLED_BY_DEFAULT};
86
Daniel Murphy95792ef2018-10-04 01:29:5587// Enable Portals. https://crbug.com/865123.
88const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT};
89
Tarun Bansal8df12b52019-02-15 05:46:3090// Enable limiting previews loading hints to specific resource types.
91const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
92 "PreviewsResourceLoadingHintsSpecificResourceTypes",
93 base::FEATURE_DISABLED_BY_DEFAULT};
94
Aditya Keerthiacee82f2019-02-15 16:48:0895// Purge memory when freezing only if the renderer is backgrounded.
96const base::Feature kPurgeMemoryOnlyForBackgroundedProcesses{
97 "FreezePurgeMemoryBackgroundedOnly", base::FEATURE_DISABLED_BY_DEFAULT};
98
David Bokan911bded2018-11-27 23:23:3299// Enable Implicit Root Scroller. https://crbug.com/903260.
100const base::Feature kImplicitRootScroller{"ImplicitRootScroller",
David Bokan5173a502019-01-11 22:06:48101 base::FEATURE_ENABLED_BY_DEFAULT};
David Bokan911bded2018-11-27 23:23:32102
Makoto Shimazu172eec02018-11-29 06:21:44103// Enables usage of getDisplayMedia() that allows capture of web content, see
104// https://crbug.com/865060.
105const base::Feature kRTCGetDisplayMedia{"RTCGetDisplayMedia",
106 base::FEATURE_ENABLED_BY_DEFAULT};
107
108// Changes the default RTCPeerConnection constructor behavior to use Unified
109// Plan as the SDP semantics. When the feature is enabled, Unified Plan is used
110// unless the default is overridden (by passing {sdpSemantics:'plan-b'} as the
111// argument).
112const base::Feature kRTCUnifiedPlanByDefault{"RTCUnifiedPlanByDefault",
Henrik Boström07021ec82019-01-17 22:23:56113 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazu172eec02018-11-29 06:21:44114
Johannes Kronad5a4532019-01-09 11:17:46115// Determines if the SDP attrbute extmap-allow-mixed should be offered by
116// default or not. The default value can be overridden by passing
117// {offerExtmapAllowMixed:true} as an argument to the RTCPeerConnection
118// constructor.
119const base::Feature kRTCOfferExtmapAllowMixed{
120 "RTCOfferExtmapAllowMixed", base::FEATURE_DISABLED_BY_DEFAULT};
121
Makoto Shimazufc82e992018-12-05 07:14:28122// Enables to load the response body through Mojo data pipe passed by
123// WebURLLoaderClient::DidStartLoadingResponseBody() instead of
124// WebURLLoaderClient::DidReceiveData().
125const base::Feature kResourceLoadViaDataPipe{"ResourceLoadViaDataPipe",
Yutaka Hiranoce92866e2019-02-21 07:57:36126 base::FEATURE_ENABLED_BY_DEFAULT};
Makoto Shimazufc82e992018-12-05 07:14:28127
momohattfc352292018-08-29 05:12:36128const base::Feature kServiceWorkerImportedScriptUpdateCheck{
129 "ServiceWorkerImportedScriptUpdateCheck",
130 base::FEATURE_DISABLED_BY_DEFAULT};
131
Ben Kellye20dc402018-09-18 01:55:42132// Enables reading a subresource's body data and side data in parallel.
133const base::Feature kServiceWorkerParallelSideDataReading{
134 "ServiceWorkerParallelSideDataReading", base::FEATURE_ENABLED_BY_DEFAULT};
135
Kenichi Ishibashi42f883d2019-01-11 08:26:14136const base::Feature kServiceWorkerAggressiveCodeCache{
137 "ServiceWorkerAggressiveCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
138
Matt Falkenhagen5cc652792018-06-21 10:34:33139// Enable new service worker glue for NetworkService. Can be
140// enabled independently of NetworkService.
141const base::Feature kServiceWorkerServicification{
Matt Falkenhagen5d2271c2018-10-17 10:12:44142 "ServiceWorkerServicification", base::FEATURE_ENABLED_BY_DEFAULT};
Matt Falkenhagen5cc652792018-06-21 10:34:33143
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
177const base::Feature kWritableFilesAPI{"WritableFilesAPI",
178 base::FEATURE_DISABLED_BY_DEFAULT};
179
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