- add sources.
[platform/framework/web/crosswalk.git] / src / content / child / runtime_features.cc
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.
4
5 #include "content/child/runtime_features.h"
6
7 #include "base/command_line.h"
8 #include "content/public/common/content_switches.h"
9 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
10
11 #if defined(OS_ANDROID)
12 #include <cpu-features.h>
13 #include "base/android/build_info.h"
14 #include "media/base/android/media_codec_bridge.h"
15 #endif
16
17 using WebKit::WebRuntimeFeatures;
18
19 namespace content {
20
21 static void SetRuntimeFeatureDefaultsForPlatform() {
22 #if defined(OS_ANDROID)
23 #if !defined(GOOGLE_TV)
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);
29   }
30 #endif  // !defined(GOOGLE_TV)
31   // WebAudio needs Android MediaCodec API that was introduced in
32   // JellyBean.
33   bool enable_webaudio =
34       (base::android::BuildInfo::GetInstance()->sdk_int() >= 16);
35   WebRuntimeFeatures::enableWebAudio(enable_webaudio);
36   // Android does not support the Gamepad API.
37   WebRuntimeFeatures::enableGamepad(false);
38   // Android does not have support for PagePopup
39   WebRuntimeFeatures::enablePagePopup(false);
40   // datalist on Android is not enabled
41   WebRuntimeFeatures::enableDataListElement(false);
42   // Android does not yet support the Web Notification API. crbug.com/115320
43   WebRuntimeFeatures::enableNotifications(false);
44   // Android does not yet support SharedWorker. crbug.com/154571
45   WebRuntimeFeatures::enableSharedWorker(false);
46 #endif  // defined(OS_ANDROID)
47 }
48
49 void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
50     const CommandLine& command_line) {
51   WebRuntimeFeatures::enableStableFeatures(true);
52
53   if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures))
54     WebRuntimeFeatures::enableExperimentalFeatures(true);
55
56   SetRuntimeFeatureDefaultsForPlatform();
57
58   if (command_line.HasSwitch(switches::kDisableDatabases))
59     WebRuntimeFeatures::enableDatabase(false);
60
61   if (command_line.HasSwitch(switches::kDisableApplicationCache))
62     WebRuntimeFeatures::enableApplicationCache(false);
63
64   if (command_line.HasSwitch(switches::kDisableDesktopNotifications))
65     WebRuntimeFeatures::enableNotifications(false);
66
67   if (command_line.HasSwitch(switches::kDisableLocalStorage))
68     WebRuntimeFeatures::enableLocalStorage(false);
69
70   if (command_line.HasSwitch(switches::kDisableSessionStorage))
71     WebRuntimeFeatures::enableSessionStorage(false);
72
73   if (command_line.HasSwitch(switches::kDisableGeolocation))
74     WebRuntimeFeatures::enableGeolocation(false);
75
76   if (command_line.HasSwitch(switches::kDisableWebKitMediaSource))
77     WebRuntimeFeatures::enableWebKitMediaSource(false);
78
79   if (command_line.HasSwitch(switches::kDisableUnprefixedMediaSource))
80     WebRuntimeFeatures::enableMediaSource(false);
81
82   if (command_line.HasSwitch(switches::kDisableSharedWorkers))
83     WebRuntimeFeatures::enableSharedWorker(false);
84
85 #if defined(OS_ANDROID)
86   if (command_line.HasSwitch(switches::kDisableWebRTC)) {
87     WebRuntimeFeatures::enableMediaStream(false);
88     WebRuntimeFeatures::enablePeerConnection(false);
89   }
90
91   if (!command_line.HasSwitch(switches::kEnableSpeechRecognition))
92     WebRuntimeFeatures::enableScriptedSpeech(false);
93 #endif
94
95   if (command_line.HasSwitch(switches::kEnableServiceWorker))
96     WebRuntimeFeatures::enableServiceWorker(true);
97
98   if (command_line.HasSwitch(switches::kDisableWebAudio))
99     WebRuntimeFeatures::enableWebAudio(false);
100
101   if (command_line.HasSwitch(switches::kDisableFullScreen))
102     WebRuntimeFeatures::enableFullscreen(false);
103
104   if (command_line.HasSwitch(switches::kEnableEncryptedMedia))
105     WebRuntimeFeatures::enableEncryptedMedia(true);
106
107   if (command_line.HasSwitch(switches::kDisablePrefixedEncryptedMedia))
108     WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
109
110   if (command_line.HasSwitch(switches::kEnableWebAnimationsCSS))
111     WebRuntimeFeatures::enableWebAnimationsCSS();
112
113   if (command_line.HasSwitch(switches::kEnableWebAnimationsSVG))
114     WebRuntimeFeatures::enableWebAnimationsSVG();
115
116   if (command_line.HasSwitch(switches::kEnableWebMIDI))
117     WebRuntimeFeatures::enableWebMIDI(true);
118
119   if (command_line.HasSwitch(switches::kDisableDeviceMotion))
120     WebRuntimeFeatures::enableDeviceMotion(false);
121
122   if (command_line.HasSwitch(switches::kDisableDeviceOrientation))
123     WebRuntimeFeatures::enableDeviceOrientation(false);
124
125   if (command_line.HasSwitch(switches::kDisableSpeechInput))
126     WebRuntimeFeatures::enableSpeechInput(false);
127
128   if (command_line.HasSwitch(switches::kDisableFileSystem))
129     WebRuntimeFeatures::enableFileSystem(false);
130
131   if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures))
132     WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
133
134   if (command_line.HasSwitch(switches::kEnableSpeechSynthesis))
135     WebRuntimeFeatures::enableSpeechSynthesis(true);
136
137   if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions))
138     WebRuntimeFeatures::enableWebGLDraftExtensions(true);
139
140   if (command_line.HasSwitch(switches::kEnableHTMLImports))
141     WebRuntimeFeatures::enableHTMLImports(true);
142
143   if (command_line.HasSwitch(switches::kEnableOverlayFullscreenVideo))
144     WebRuntimeFeatures::enableOverlayFullscreenVideo(true);
145
146   if (command_line.HasSwitch(switches::kEnableOverlayScrollbars))
147     WebRuntimeFeatures::enableOverlayScrollbars(true);
148
149   if (command_line.HasSwitch(switches::kEnableInputModeAttribute))
150     WebRuntimeFeatures::enableInputModeAttribute(true);
151
152   if (command_line.HasSwitch(switches::kEnableFastTextAutosizing))
153     WebRuntimeFeatures::enableFastTextAutosizing(true);
154
155   if (command_line.HasSwitch(switches::kEnableRepaintAfterLayout))
156     WebRuntimeFeatures::enableRepaintAfterLayout(true);
157 }
158
159 }  // namespace content