blob: 8e3d3897f92f247f30c17dda777f85d56d57126a [file] [log] [blame]
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +01001// 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#endif
14
15using WebKit::WebRuntimeFeatures;
16
17namespace content {
18
19static void SetRuntimeFeatureDefaultsForPlatform() {
20#if defined(OS_ANDROID) && !defined(GOOGLE_TV)
21 WebRuntimeFeatures::enableWebKitMediaSource(false);
22 WebRuntimeFeatures::enableLegacyEncryptedMedia(false);
23 WebRuntimeFeatures::enableEncryptedMedia(false);
24#endif
25
26#if defined(OS_ANDROID)
27 bool enable_webaudio = true;
28#if defined(ARCH_CPU_ARMEL)
29 enable_webaudio =
30 ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
31#endif
32 WebRuntimeFeatures::enableWebAudio(enable_webaudio);
33 // Android does not support the Gamepad API.
34 WebRuntimeFeatures::enableGamepad(false);
35 // input[type=week] in Android is incomplete. crbug.com/135938
36 WebRuntimeFeatures::enableInputTypeWeek(false);
37 // Android does not have support for PagePopup
38 WebRuntimeFeatures::enablePagePopup(false);
39 // datalist on Android is not enabled
40 WebRuntimeFeatures::enableDataListElement(false);
41#endif
42}
43
44void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
45 const CommandLine& command_line) {
46 WebRuntimeFeatures::enableStableFeatures(true);
47
48 if (command_line.HasSwitch(switches::kEnableExperimentalWebKitFeatures))
49 WebRuntimeFeatures::enableExperimentalFeatures(true);
50
51 SetRuntimeFeatureDefaultsForPlatform();
52
53 if (command_line.HasSwitch(switches::kDisableDatabases))
54 WebRuntimeFeatures::enableDatabase(false);
55
56 if (command_line.HasSwitch(switches::kDisableApplicationCache))
57 WebRuntimeFeatures::enableApplicationCache(false);
58
59 if (command_line.HasSwitch(switches::kDisableDesktopNotifications))
60 WebRuntimeFeatures::enableNotifications(false);
61
62 if (command_line.HasSwitch(switches::kDisableLocalStorage))
63 WebRuntimeFeatures::enableLocalStorage(false);
64
65 if (command_line.HasSwitch(switches::kDisableSessionStorage))
66 WebRuntimeFeatures::enableSessionStorage(false);
67
68 if (command_line.HasSwitch(switches::kDisableGeolocation))
69 WebRuntimeFeatures::enableGeolocation(false);
70
71#if defined(OS_ANDROID) && !defined(GOOGLE_TV)
72 if (command_line.HasSwitch(switches::kEnableWebKitMediaSource))
73 WebRuntimeFeatures::enableWebKitMediaSource(true);
74#else
75 if (command_line.HasSwitch(switches::kDisableWebKitMediaSource))
76 WebRuntimeFeatures::enableWebKitMediaSource(false);
77#endif
78
79#if defined(OS_ANDROID)
80 if (command_line.HasSwitch(switches::kDisableWebRTC)) {
81 WebRuntimeFeatures::enableMediaStream(false);
82 WebRuntimeFeatures::enablePeerConnection(false);
83 }
84
85 if (!command_line.HasSwitch(switches::kEnableSpeechRecognition))
86 WebRuntimeFeatures::enableScriptedSpeech(false);
87#endif
88
89 if (command_line.HasSwitch(switches::kDisableWebAudio))
90 WebRuntimeFeatures::enableWebAudio(false);
91
92 if (command_line.HasSwitch(switches::kDisableFullScreen))
93 WebRuntimeFeatures::enableFullscreen(false);
94
95 if (command_line.HasSwitch(switches::kEnableEncryptedMedia))
96 WebRuntimeFeatures::enableEncryptedMedia(true);
97
98 if (command_line.HasSwitch(switches::kDisableLegacyEncryptedMedia))
99 WebRuntimeFeatures::enableLegacyEncryptedMedia(false);
100
101 if (command_line.HasSwitch(switches::kEnableWebMIDI))
102 WebRuntimeFeatures::enableWebMIDI(true);
103
104 if (command_line.HasSwitch(switches::kEnableDeviceMotion))
105 WebRuntimeFeatures::enableDeviceMotion(true);
106
107 if (command_line.HasSwitch(switches::kDisableDeviceOrientation))
108 WebRuntimeFeatures::enableDeviceOrientation(false);
109
110 if (command_line.HasSwitch(switches::kDisableSpeechInput))
111 WebRuntimeFeatures::enableSpeechInput(false);
112
113 if (command_line.HasSwitch(switches::kDisableFileSystem))
114 WebRuntimeFeatures::enableFileSystem(false);
115
116 if (command_line.HasSwitch(switches::kDisableJavaScriptI18NAPI))
117 WebRuntimeFeatures::enableJavaScriptI18NAPI(false);
118
119 if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures))
120 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
121
122 if (command_line.HasSwitch(switches::kEnableSpeechSynthesis))
123 WebRuntimeFeatures::enableSpeechSynthesis(true);
124
125 if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions))
126 WebRuntimeFeatures::enableWebGLDraftExtensions(true);
127
128 // Enabled by default for testing.
129 // TODO(urvang): Go back to using the command-line option after a few days.
130 // https://code.google.com/p/chromium/issues/detail?id=234437
131 WebRuntimeFeatures::enableWebPInAcceptHeader(true);
132}
133
134} // namespace content