Upstream version 8.36.156.0
[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/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"
12
13 #if defined(OS_ANDROID)
14 #include <cpu-features.h>
15 #include "media/base/android/media_codec_bridge.h"
16 #endif
17
18 using blink::WebRuntimeFeatures;
19
20 namespace content {
21
22 static void SetRuntimeFeatureDefaultsForPlatform() {
23 #if defined(OS_ANDROID)
24   // MSE/EME implementation needs Android MediaCodec API.
25   if (!media::MediaCodecBridge::IsAvailable()) {
26     WebRuntimeFeatures::enableMediaSource(false);
27     WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
28     WebRuntimeFeatures::enableEncryptedMedia(false);
29   }
30   // WebAudio is enabled by default on ARM and X86 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_getCpuFamily() == ANDROID_CPU_FAMILY_X86)));
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   // Crosswalk supports the Web Notification API on Android.
41   WebRuntimeFeatures::enableNotifications(true);
42   // Android does not yet support SharedWorker. crbug.com/154571
43   WebRuntimeFeatures::enableSharedWorker(false);
44   // Android does not yet support NavigatorContentUtils.
45   WebRuntimeFeatures::enableNavigatorContentUtils(false);
46   WebRuntimeFeatures::enableTouchIconLoading(true);
47   WebRuntimeFeatures::enableScreenOrientation(true);
48   WebRuntimeFeatures::enableOrientationEvent(true);
49 #else
50   WebRuntimeFeatures::enableNavigatorContentUtils(true);
51 #endif  // defined(OS_ANDROID)
52 #if defined(OS_TIZEN)
53   WebRuntimeFeatures::enableScreenOrientation(true);
54   WebRuntimeFeatures::enableOrientationEvent(true);
55 #endif  // defined(OS_TIZEN)
56 }
57
58 void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
59     const CommandLine& command_line) {
60   if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures))
61     WebRuntimeFeatures::enableExperimentalFeatures(true);
62
63   SetRuntimeFeatureDefaultsForPlatform();
64
65   if (command_line.HasSwitch(switches::kDisableDatabases))
66     WebRuntimeFeatures::enableDatabase(false);
67
68   if (command_line.HasSwitch(switches::kDisableApplicationCache))
69     WebRuntimeFeatures::enableApplicationCache(false);
70
71   if (command_line.HasSwitch(switches::kDisableDesktopNotifications))
72     WebRuntimeFeatures::enableNotifications(false);
73
74   if (command_line.HasSwitch(switches::kDisableNavigatorContentUtils))
75     WebRuntimeFeatures::enableNavigatorContentUtils(false);
76
77   if (command_line.HasSwitch(switches::kDisableLocalStorage))
78     WebRuntimeFeatures::enableLocalStorage(false);
79
80   if (command_line.HasSwitch(switches::kDisableSessionStorage))
81     WebRuntimeFeatures::enableSessionStorage(false);
82
83   if (command_line.HasSwitch(switches::kDisableMediaSource))
84     WebRuntimeFeatures::enableMediaSource(false);
85
86   if (command_line.HasSwitch(switches::kDisableSharedWorkers))
87     WebRuntimeFeatures::enableSharedWorker(false);
88
89 #if defined(OS_ANDROID)
90   if (command_line.HasSwitch(switches::kDisableWebRTC)) {
91     WebRuntimeFeatures::enableMediaStream(false);
92     WebRuntimeFeatures::enablePeerConnection(false);
93   }
94
95   if (!command_line.HasSwitch(switches::kEnableSpeechRecognition))
96     WebRuntimeFeatures::enableScriptedSpeech(false);
97 #endif
98
99   if (command_line.HasSwitch(switches::kEnableServiceWorker))
100     WebRuntimeFeatures::enableServiceWorker(true);
101
102 #if defined(OS_ANDROID)
103   // WebAudio is enabled by default on ARM and X86, if the MediaCodec
104   // API is available.
105   WebRuntimeFeatures::enableWebAudio(
106       !command_line.HasSwitch(switches::kDisableWebAudio) &&
107       media::MediaCodecBridge::IsAvailable());
108 #else
109   if (command_line.HasSwitch(switches::kDisableWebAudio))
110     WebRuntimeFeatures::enableWebAudio(false);
111 #endif
112
113   if (command_line.HasSwitch(switches::kEnableEncryptedMedia))
114     WebRuntimeFeatures::enableEncryptedMedia(true);
115
116   if (command_line.HasSwitch(switches::kDisablePrefixedEncryptedMedia))
117     WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
118
119   if (command_line.HasSwitch(switches::kEnableWebAnimationsSVG))
120     WebRuntimeFeatures::enableWebAnimationsSVG(true);
121
122   if (command_line.HasSwitch(switches::kEnableWebMIDI))
123     WebRuntimeFeatures::enableWebMIDI(true);
124
125   if (command_line.HasSwitch(switches::kDisableFileSystem))
126     WebRuntimeFeatures::enableFileSystem(false);
127
128   if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures))
129     WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
130
131   if (command_line.HasSwitch(switches::kEnableSpeechSynthesis))
132     WebRuntimeFeatures::enableSpeechSynthesis(true);
133
134   if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions))
135     WebRuntimeFeatures::enableWebGLDraftExtensions(true);
136
137   if (command_line.HasSwitch(switches::kEnableOverlayFullscreenVideo))
138     WebRuntimeFeatures::enableOverlayFullscreenVideo(true);
139
140   if (ui::IsOverlayScrollbarEnabled())
141     WebRuntimeFeatures::enableOverlayScrollbars(true);
142
143   if (command_line.HasSwitch(switches::kEnableFastTextAutosizing)
144       && !command_line.HasSwitch(switches::kDisableFastTextAutosizing))
145     WebRuntimeFeatures::enableFastTextAutosizing(true);
146
147   if (command_line.HasSwitch(switches::kDisableRepaintAfterLayout))
148     WebRuntimeFeatures::enableRepaintAfterLayout(false);
149
150   if (command_line.HasSwitch(switches::kEnableRepaintAfterLayout))
151     WebRuntimeFeatures::enableRepaintAfterLayout(true);
152
153   if (command_line.HasSwitch(switches::kEnableTargetedStyleRecalc))
154     WebRuntimeFeatures::enableTargetedStyleRecalc(true);
155
156   if (command_line.HasSwitch(switches::kEnableBleedingEdgeRenderingFastPaths))
157     WebRuntimeFeatures::enableBleedingEdgeFastPaths(true);
158
159   if (command_line.HasSwitch(switches::kEnablePreciseMemoryInfo))
160     WebRuntimeFeatures::enablePreciseMemoryInfo(true);
161 }
162
163 }  // namespace content