Delete SyncDecryptionPassphraseType.
[chromium-blink-merge.git] / content / child / runtime_features.cc
blob01cf2b38ea38460a3fd87376cb3209ae2083dbd6
1 // Copyright 2013 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.
5 #include "content/child/runtime_features.h"
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "content/common/content_switches_internal.h"
10 #include "content/public/common/content_switches.h"
11 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
12 #include "ui/native_theme/native_theme_switches.h"
14 #if defined(OS_ANDROID)
15 #include <cpu-features.h>
16 #include "base/android/build_info.h"
17 #include "base/metrics/field_trial.h"
18 #include "media/base/android/media_codec_bridge.h"
19 #elif defined(OS_WIN)
20 #include "base/win/windows_version.h"
21 #endif
23 using blink::WebRuntimeFeatures;
25 namespace content {
27 static void SetRuntimeFeatureDefaultsForPlatform() {
28 #if defined(OS_ANDROID)
29 // MSE/EME implementation needs Android MediaCodec API.
30 if (!media::MediaCodecBridge::IsAvailable()) {
31 WebRuntimeFeatures::enableMediaSource(false);
32 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
33 WebRuntimeFeatures::enableEncryptedMedia(false);
35 // WebAudio is enabled by default but only when the MediaCodec API
36 // is available.
37 AndroidCpuFamily cpu_family = android_getCpuFamily();
38 WebRuntimeFeatures::enableWebAudio(
39 media::MediaCodecBridge::IsAvailable() &&
40 ((cpu_family == ANDROID_CPU_FAMILY_ARM) ||
41 (cpu_family == ANDROID_CPU_FAMILY_ARM64) ||
42 (cpu_family == ANDROID_CPU_FAMILY_X86) ||
43 (cpu_family == ANDROID_CPU_FAMILY_MIPS)));
45 // Android does not have support for PagePopup
46 WebRuntimeFeatures::enablePagePopup(false);
47 // Android does not yet support the Web Notification API. crbug.com/115320
48 WebRuntimeFeatures::enableNotifications(false);
49 // Android does not yet support SharedWorker. crbug.com/154571
50 WebRuntimeFeatures::enableSharedWorker(false);
51 // Android does not yet support NavigatorContentUtils.
52 WebRuntimeFeatures::enableNavigatorContentUtils(false);
53 WebRuntimeFeatures::enableTouchIconLoading(true);
54 WebRuntimeFeatures::enableOrientationEvent(true);
55 WebRuntimeFeatures::enableFastMobileScrolling(true);
56 WebRuntimeFeatures::enableMediaCapture(true);
57 WebRuntimeFeatures::enableCompositedSelectionUpdate(true);
58 // If navigation transitions gets activated via field trial, enable it in
59 // blink. We don't set this to false in case the user has manually enabled
60 // the feature via experimental web platform features.
61 if (base::FieldTrialList::FindFullName("NavigationTransitions") == "Enabled")
62 WebRuntimeFeatures::enableNavigationTransitions(true);
63 #else
64 WebRuntimeFeatures::enableNavigatorContentUtils(true);
65 #endif // defined(OS_ANDROID)
67 #if !(defined OS_ANDROID || defined OS_CHROMEOS || defined OS_IOS)
68 // Only Android, ChromeOS, and IOS support NetInfo right now.
69 WebRuntimeFeatures::enableNetworkInformation(false);
70 #endif
72 #if defined(OS_WIN)
73 // Screen Orientation API is currently broken on Windows 8 Metro mode and
74 // until we can find how to disable it only for Blink instances running in a
75 // renderer process in Metro, we need to disable the API altogether for Win8.
76 // See http://crbug.com/400846
77 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_WIN8)
78 WebRuntimeFeatures::enableScreenOrientation(false);
79 #endif // OS_WIN
82 void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
83 const base::CommandLine& command_line) {
84 if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures))
85 WebRuntimeFeatures::enableExperimentalFeatures(true);
87 SetRuntimeFeatureDefaultsForPlatform();
89 if (command_line.HasSwitch(switches::kDisableDatabases))
90 WebRuntimeFeatures::enableDatabase(false);
92 if (command_line.HasSwitch(switches::kDisableApplicationCache))
93 WebRuntimeFeatures::enableApplicationCache(false);
95 if (command_line.HasSwitch(switches::kDisableBlinkScheduler))
96 WebRuntimeFeatures::enableBlinkScheduler(false);
98 if (command_line.HasSwitch(switches::kDisableLocalStorage))
99 WebRuntimeFeatures::enableLocalStorage(false);
101 if (command_line.HasSwitch(switches::kDisableSessionStorage))
102 WebRuntimeFeatures::enableSessionStorage(false);
104 if (command_line.HasSwitch(switches::kDisableMediaSource))
105 WebRuntimeFeatures::enableMediaSource(false);
107 if (command_line.HasSwitch(switches::kDisableSharedWorkers))
108 WebRuntimeFeatures::enableSharedWorker(false);
110 #if defined(OS_ANDROID)
111 if (command_line.HasSwitch(switches::kDisableWebRTC))
112 WebRuntimeFeatures::enablePeerConnection(false);
114 if (!command_line.HasSwitch(switches::kEnableSpeechRecognition))
115 WebRuntimeFeatures::enableScriptedSpeech(false);
117 if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures))
118 WebRuntimeFeatures::enableNotifications(true);
120 // WebAudio is enabled by default on ARM and X86, if the MediaCodec
121 // API is available.
122 WebRuntimeFeatures::enableWebAudio(
123 !command_line.HasSwitch(switches::kDisableWebAudio) &&
124 media::MediaCodecBridge::IsAvailable());
125 #else
126 if (command_line.HasSwitch(switches::kDisableWebAudio))
127 WebRuntimeFeatures::enableWebAudio(false);
128 #endif
130 if (command_line.HasSwitch(switches::kEnableEncryptedMedia))
131 WebRuntimeFeatures::enableEncryptedMedia(true);
133 if (command_line.HasSwitch(switches::kDisablePrefixedEncryptedMedia))
134 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
136 if (command_line.HasSwitch(switches::kEnableWebMIDI))
137 WebRuntimeFeatures::enableWebMIDI(true);
139 if (command_line.HasSwitch(switches::kDisableFileSystem))
140 WebRuntimeFeatures::enableFileSystem(false);
142 if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures))
143 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
145 if (!command_line.HasSwitch(switches::kDisableAcceleratedJpegDecoding))
146 WebRuntimeFeatures::enableDecodeToYUV(true);
148 if (command_line.HasSwitch(switches::kDisableDisplayList2dCanvas)) {
149 WebRuntimeFeatures::enableDisplayList2dCanvas(false);
150 } else if (command_line.HasSwitch(switches::kForceDisplayList2dCanvas)) {
151 WebRuntimeFeatures::forceDisplayList2dCanvas(true);
152 } else if (command_line.HasSwitch(switches::kEnableDisplayList2dCanvas)) {
153 WebRuntimeFeatures::enableDisplayList2dCanvas(true);
154 } else {
155 WebRuntimeFeatures::enableDisplayList2dCanvas(
156 base::FieldTrialList::FindFullName("DisplayList2dCanvas") == "Enabled"
160 if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions))
161 WebRuntimeFeatures::enableWebGLDraftExtensions(true);
163 if (command_line.HasSwitch(switches::kEnableWebGLImageChromium))
164 WebRuntimeFeatures::enableWebGLImageChromium(true);
166 if (command_line.HasSwitch(switches::kEnableOverlayFullscreenVideo))
167 WebRuntimeFeatures::enableOverlayFullscreenVideo(true);
169 if (ui::IsOverlayScrollbarEnabled())
170 WebRuntimeFeatures::enableOverlayScrollbars(true);
172 if (command_line.HasSwitch(switches::kEnableBleedingEdgeRenderingFastPaths))
173 WebRuntimeFeatures::enableBleedingEdgeFastPaths(true);
175 if (command_line.HasSwitch(switches::kEnablePreciseMemoryInfo))
176 WebRuntimeFeatures::enablePreciseMemoryInfo(true);
178 if (command_line.HasSwitch(switches::kEnableNetworkInformation) ||
179 command_line.HasSwitch(
180 switches::kEnableExperimentalWebPlatformFeatures)) {
181 WebRuntimeFeatures::enableNetworkInformation(true);
184 if (command_line.HasSwitch(switches::kEnableCredentialManagerAPI))
185 WebRuntimeFeatures::enableCredentialManagerAPI(true);
187 if (command_line.HasSwitch(switches::kDisableSVG1DOM)) {
188 WebRuntimeFeatures::enableSVG1DOM(false);
191 if (command_line.HasSwitch(switches::kReducedReferrerGranularity))
192 WebRuntimeFeatures::enableReducedReferrerGranularity(true);
195 } // namespace content