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/public/common/content_switches.h"
9 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
11 #if defined(OS_ANDROID)
12 #include <cpu-features.h>
13 #include "base/android/build_info.h"
16 using WebKit::WebRuntimeFeatures
;
20 static void SetRuntimeFeatureDefaultsForPlatform() {
21 #if defined(OS_ANDROID)
22 #if !defined(GOOGLE_TV)
23 // MSE/EME implementation needs Android MediaCodec API that was introduced
25 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
26 WebRuntimeFeatures::enableWebKitMediaSource(false);
27 WebRuntimeFeatures::enableLegacyEncryptedMedia(false);
29 #endif // !defined(GOOGLE_TV)
30 bool enable_webaudio
= false;
31 #if defined(ARCH_CPU_ARMEL)
32 // WebAudio needs Android MediaCodec API that was introduced in
33 // JellyBean, and also currently needs NEON support for the FFT.
35 (base::android::BuildInfo::GetInstance()->sdk_int() >= 16) &&
36 ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON
) != 0);
37 #endif // defined(ARCH_CPU_ARMEL)
38 WebRuntimeFeatures::enableWebAudio(enable_webaudio
);
39 // Android does not support the Gamepad API.
40 WebRuntimeFeatures::enableGamepad(false);
41 // Android does not have support for PagePopup
42 WebRuntimeFeatures::enablePagePopup(false);
43 // datalist on Android is not enabled
44 WebRuntimeFeatures::enableDataListElement(false);
45 // Android does not yet support the Web Notification API. crbug.com/115320
46 WebRuntimeFeatures::enableNotifications(false);
47 #endif // defined(OS_ANDROID)
50 void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
51 const CommandLine
& command_line
) {
52 WebRuntimeFeatures::enableStableFeatures(true);
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::kDisableLocalStorage
))
69 WebRuntimeFeatures::enableLocalStorage(false);
71 if (command_line
.HasSwitch(switches::kDisableSessionStorage
))
72 WebRuntimeFeatures::enableSessionStorage(false);
74 if (command_line
.HasSwitch(switches::kDisableGeolocation
))
75 WebRuntimeFeatures::enableGeolocation(false);
77 if (command_line
.HasSwitch(switches::kDisableWebKitMediaSource
))
78 WebRuntimeFeatures::enableWebKitMediaSource(false);
80 #if defined(OS_ANDROID)
81 if (command_line
.HasSwitch(switches::kDisableWebRTC
)) {
82 WebRuntimeFeatures::enableMediaStream(false);
83 WebRuntimeFeatures::enablePeerConnection(false);
86 if (!command_line
.HasSwitch(switches::kEnableSpeechRecognition
))
87 WebRuntimeFeatures::enableScriptedSpeech(false);
90 if (command_line
.HasSwitch(switches::kDisableWebAudio
))
91 WebRuntimeFeatures::enableWebAudio(false);
93 if (command_line
.HasSwitch(switches::kDisableFullScreen
))
94 WebRuntimeFeatures::enableFullscreen(false);
96 if (command_line
.HasSwitch(switches::kEnableEncryptedMedia
))
97 WebRuntimeFeatures::enableEncryptedMedia(true);
99 if (command_line
.HasSwitch(switches::kDisableLegacyEncryptedMedia
))
100 WebRuntimeFeatures::enableLegacyEncryptedMedia(false);
102 if (command_line
.HasSwitch(switches::kEnableWebAnimationsCSS
))
103 WebRuntimeFeatures::enableWebAnimationsCSS();
105 if (command_line
.HasSwitch(switches::kEnableWebAnimationsSVG
))
106 WebRuntimeFeatures::enableWebAnimationsSVG();
108 if (command_line
.HasSwitch(switches::kEnableWebMIDI
))
109 WebRuntimeFeatures::enableWebMIDI(true);
111 if (command_line
.HasSwitch(switches::kDisableDeviceMotion
))
112 WebRuntimeFeatures::enableDeviceMotion(false);
114 if (command_line
.HasSwitch(switches::kDisableDeviceOrientation
))
115 WebRuntimeFeatures::enableDeviceOrientation(false);
117 if (command_line
.HasSwitch(switches::kDisableSpeechInput
))
118 WebRuntimeFeatures::enableSpeechInput(false);
120 if (command_line
.HasSwitch(switches::kDisableFileSystem
))
121 WebRuntimeFeatures::enableFileSystem(false);
123 if (command_line
.HasSwitch(switches::kEnableExperimentalCanvasFeatures
))
124 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
126 if (command_line
.HasSwitch(switches::kEnableSpeechSynthesis
))
127 WebRuntimeFeatures::enableSpeechSynthesis(true);
129 if (command_line
.HasSwitch(switches::kEnableWebGLDraftExtensions
))
130 WebRuntimeFeatures::enableWebGLDraftExtensions(true);
132 if (command_line
.HasSwitch(switches::kEnableHTMLImports
))
133 WebRuntimeFeatures::enableHTMLImports(true);
135 if (command_line
.HasSwitch(switches::kEnableOverlayScrollbars
))
136 WebRuntimeFeatures::enableOverlayScrollbars(true);
138 if (command_line
.HasSwitch(switches::kEnableInputModeAttribute
))
139 WebRuntimeFeatures::enableInputModeAttribute(true);
142 } // namespace content