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 "content/common/content_switches_internal.h"
9 #include "content/public/common/content_switches.h"
10 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
11 #include "ui/native_theme/native_theme_switches.h"
13 #if defined(OS_ANDROID)
14 #include <cpu-features.h>
15 #include "media/base/android/media_codec_bridge.h"
18 using blink::WebRuntimeFeatures
;
22 static void SetRuntimeFeatureDefaultsForPlatform() {
23 #if defined(OS_ANDROID)
24 // MSE/EME implementation needs Android MediaCodec API.
25 if (!media::MediaCodecBridge::IsAvailable()) {
26 WebRuntimeFeatures::enableWebKitMediaSource(false);
27 WebRuntimeFeatures::enableMediaSource(false);
28 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
30 // WebAudio is enabled by default only on ARM and only when the
31 // MediaCodec API is available.
32 WebRuntimeFeatures::enableWebAudio(
33 media::MediaCodecBridge::IsAvailable() &&
34 (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM
));
35 // Android does not support the Gamepad API.
36 WebRuntimeFeatures::enableGamepad(false);
37 // Android does not have support for PagePopup
38 WebRuntimeFeatures::enablePagePopup(false);
39 // Android does not yet support the Web Notification API. crbug.com/115320
40 WebRuntimeFeatures::enableNotifications(false);
41 // Android does not yet support SharedWorker. crbug.com/154571
42 WebRuntimeFeatures::enableSharedWorker(false);
43 // Android does not yet support NavigatorContentUtils.
44 WebRuntimeFeatures::enableNavigatorContentUtils(false);
45 WebRuntimeFeatures::enableTouchIconLoading(true);
46 WebRuntimeFeatures::enableOrientationEvent(true);
48 WebRuntimeFeatures::enableNavigatorContentUtils(true);
49 #endif // defined(OS_ANDROID)
52 void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
53 const CommandLine
& command_line
) {
54 if (command_line
.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures
))
55 WebRuntimeFeatures::enableExperimentalFeatures(true);
57 SetRuntimeFeatureDefaultsForPlatform();
59 if (command_line
.HasSwitch(switches::kDisableDatabases
))
60 WebRuntimeFeatures::enableDatabase(false);
62 if (command_line
.HasSwitch(switches::kDisableApplicationCache
))
63 WebRuntimeFeatures::enableApplicationCache(false);
65 if (command_line
.HasSwitch(switches::kDisableDesktopNotifications
))
66 WebRuntimeFeatures::enableNotifications(false);
68 if (command_line
.HasSwitch(switches::kDisableNavigatorContentUtils
))
69 WebRuntimeFeatures::enableNavigatorContentUtils(false);
71 if (command_line
.HasSwitch(switches::kDisableLocalStorage
))
72 WebRuntimeFeatures::enableLocalStorage(false);
74 if (command_line
.HasSwitch(switches::kDisableSessionStorage
))
75 WebRuntimeFeatures::enableSessionStorage(false);
77 if (command_line
.HasSwitch(switches::kDisableWebKitMediaSource
))
78 WebRuntimeFeatures::enableWebKitMediaSource(false);
80 if (command_line
.HasSwitch(switches::kDisableUnprefixedMediaSource
))
81 WebRuntimeFeatures::enableMediaSource(false);
83 if (command_line
.HasSwitch(switches::kDisableSharedWorkers
))
84 WebRuntimeFeatures::enableSharedWorker(false);
86 #if defined(OS_ANDROID)
87 if (command_line
.HasSwitch(switches::kDisableWebRTC
)) {
88 WebRuntimeFeatures::enableMediaStream(false);
89 WebRuntimeFeatures::enablePeerConnection(false);
92 if (!command_line
.HasSwitch(switches::kEnableSpeechRecognition
))
93 WebRuntimeFeatures::enableScriptedSpeech(false);
96 if (command_line
.HasSwitch(switches::kEnableServiceWorker
))
97 WebRuntimeFeatures::enableServiceWorker(true);
99 #if defined(OS_ANDROID)
100 // WebAudio requires the MediaCodec API.
101 #if defined(ARCH_CPU_X86)
102 // WebAudio is disabled by default on x86.
103 WebRuntimeFeatures::enableWebAudio(
104 command_line
.HasSwitch(switches::kEnableWebAudio
) &&
105 media::MediaCodecBridge::IsAvailable());
106 #elif defined(ARCH_CPU_ARMEL)
107 // WebAudio is enabled by default on ARM.
108 WebRuntimeFeatures::enableWebAudio(
109 !command_line
.HasSwitch(switches::kDisableWebAudio
) &&
110 media::MediaCodecBridge::IsAvailable());
112 WebRuntimeFeatures::enableWebAudio(false);
115 if (command_line
.HasSwitch(switches::kDisableWebAudio
))
116 WebRuntimeFeatures::enableWebAudio(false);
119 if (command_line
.HasSwitch(switches::kEnableEncryptedMedia
))
120 WebRuntimeFeatures::enableEncryptedMedia(true);
122 if (command_line
.HasSwitch(switches::kDisablePrefixedEncryptedMedia
))
123 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
125 if (command_line
.HasSwitch(switches::kEnableWebAnimationsSVG
))
126 WebRuntimeFeatures::enableWebAnimationsSVG(true);
128 if (command_line
.HasSwitch(switches::kEnableWebMIDI
))
129 WebRuntimeFeatures::enableWebMIDI(true);
131 if (command_line
.HasSwitch(switches::kDisableSpeechInput
))
132 WebRuntimeFeatures::enableSpeechInput(false);
134 if (command_line
.HasSwitch(switches::kDisableFileSystem
))
135 WebRuntimeFeatures::enableFileSystem(false);
138 if (command_line
.HasSwitch(switches::kEnableDirectWrite
))
139 WebRuntimeFeatures::enableDirectWrite(true);
142 if (command_line
.HasSwitch(switches::kEnableExperimentalCanvasFeatures
))
143 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
145 if (command_line
.HasSwitch(switches::kEnableSpeechSynthesis
))
146 WebRuntimeFeatures::enableSpeechSynthesis(true);
148 if (command_line
.HasSwitch(switches::kEnableWebGLDraftExtensions
))
149 WebRuntimeFeatures::enableWebGLDraftExtensions(true);
151 if (command_line
.HasSwitch(switches::kEnableHTMLImports
))
152 WebRuntimeFeatures::enableHTMLImports(true);
154 if (command_line
.HasSwitch(switches::kEnableOverlayFullscreenVideo
))
155 WebRuntimeFeatures::enableOverlayFullscreenVideo(true);
157 if (ui::IsOverlayScrollbarEnabled())
158 WebRuntimeFeatures::enableOverlayScrollbars(true);
160 if (command_line
.HasSwitch(switches::kEnableFastTextAutosizing
))
161 WebRuntimeFeatures::enableFastTextAutosizing(true);
163 if (command_line
.HasSwitch(switches::kDisableRepaintAfterLayout
))
164 WebRuntimeFeatures::enableRepaintAfterLayout(false);
166 if (command_line
.HasSwitch(switches::kEnableRepaintAfterLayout
))
167 WebRuntimeFeatures::enableRepaintAfterLayout(true);
169 if (command_line
.HasSwitch(switches::kEnableTargetedStyleRecalc
))
170 WebRuntimeFeatures::enableTargetedStyleRecalc(true);
172 if (command_line
.HasSwitch(switches::kEnableBleedingEdgeRenderingFastPaths
))
173 WebRuntimeFeatures::enableBleedingEdgeFastPaths(true);
176 } // namespace content