runtime_features.cc revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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 "media/base/android/media_codec_bridge.h" 14#endif 15 16using WebKit::WebRuntimeFeatures; 17 18namespace content { 19 20static void SetRuntimeFeatureDefaultsForPlatform() { 21#if defined(OS_ANDROID) 22#if !defined(GOOGLE_TV) 23 // MSE/EME implementation needs Android MediaCodec API. 24 if (!media::MediaCodecBridge::IsAvailable()) { 25 WebRuntimeFeatures::enableWebKitMediaSource(false); 26 WebRuntimeFeatures::enableMediaSource(false); 27 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false); 28 } 29#endif // !defined(GOOGLE_TV) 30 bool enable_webaudio = false; 31#if defined(ARCH_CPU_ARMEL) 32 // WebAudio needs Android MediaCodec API, and also currently needs NEON 33 // support for the FFT. 34 enable_webaudio = 35 (media::MediaCodecBridge::IsAvailable()) && 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) 48} 49 50void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( 51 const CommandLine& command_line) { 52 WebRuntimeFeatures::enableStableFeatures(true); 53 54 if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)) 55 WebRuntimeFeatures::enableExperimentalFeatures(true); 56 57 SetRuntimeFeatureDefaultsForPlatform(); 58 59 if (command_line.HasSwitch(switches::kDisableDatabases)) 60 WebRuntimeFeatures::enableDatabase(false); 61 62 if (command_line.HasSwitch(switches::kDisableApplicationCache)) 63 WebRuntimeFeatures::enableApplicationCache(false); 64 65 if (command_line.HasSwitch(switches::kDisableDesktopNotifications)) 66 WebRuntimeFeatures::enableNotifications(false); 67 68 if (command_line.HasSwitch(switches::kDisableLocalStorage)) 69 WebRuntimeFeatures::enableLocalStorage(false); 70 71 if (command_line.HasSwitch(switches::kDisableSessionStorage)) 72 WebRuntimeFeatures::enableSessionStorage(false); 73 74 if (command_line.HasSwitch(switches::kDisableGeolocation)) 75 WebRuntimeFeatures::enableGeolocation(false); 76 77 if (command_line.HasSwitch(switches::kDisableWebKitMediaSource)) 78 WebRuntimeFeatures::enableWebKitMediaSource(false); 79 80 if (command_line.HasSwitch(switches::kDisableUnprefixedMediaSource)) 81 WebRuntimeFeatures::enableMediaSource(false); 82 83#if defined(OS_ANDROID) 84 if (command_line.HasSwitch(switches::kDisableWebRTC)) { 85 WebRuntimeFeatures::enableMediaStream(false); 86 WebRuntimeFeatures::enablePeerConnection(false); 87 } 88 89 if (!command_line.HasSwitch(switches::kEnableSpeechRecognition)) 90 WebRuntimeFeatures::enableScriptedSpeech(false); 91#endif 92 93 if (command_line.HasSwitch(switches::kEnableServiceWorker)) 94 WebRuntimeFeatures::enableServiceWorker(true); 95 96 if (command_line.HasSwitch(switches::kDisableWebAudio)) 97 WebRuntimeFeatures::enableWebAudio(false); 98 99 if (command_line.HasSwitch(switches::kDisableFullScreen)) 100 WebRuntimeFeatures::enableFullscreen(false); 101 102 if (command_line.HasSwitch(switches::kEnableEncryptedMedia)) 103 WebRuntimeFeatures::enableEncryptedMedia(true); 104 105 if (command_line.HasSwitch(switches::kDisablePrefixedEncryptedMedia)) 106 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false); 107 108 if (command_line.HasSwitch(switches::kEnableWebAnimationsCSS)) 109 WebRuntimeFeatures::enableWebAnimationsCSS(); 110 111 if (command_line.HasSwitch(switches::kEnableWebAnimationsSVG)) 112 WebRuntimeFeatures::enableWebAnimationsSVG(); 113 114 if (command_line.HasSwitch(switches::kEnableWebMIDI)) 115 WebRuntimeFeatures::enableWebMIDI(true); 116 117 if (command_line.HasSwitch(switches::kDisableDeviceMotion)) 118 WebRuntimeFeatures::enableDeviceMotion(false); 119 120 if (command_line.HasSwitch(switches::kDisableDeviceOrientation)) 121 WebRuntimeFeatures::enableDeviceOrientation(false); 122 123 if (command_line.HasSwitch(switches::kDisableSpeechInput)) 124 WebRuntimeFeatures::enableSpeechInput(false); 125 126 if (command_line.HasSwitch(switches::kDisableFileSystem)) 127 WebRuntimeFeatures::enableFileSystem(false); 128 129 if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures)) 130 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true); 131 132 if (command_line.HasSwitch(switches::kEnableSpeechSynthesis)) 133 WebRuntimeFeatures::enableSpeechSynthesis(true); 134 135 if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions)) 136 WebRuntimeFeatures::enableWebGLDraftExtensions(true); 137 138 if (command_line.HasSwitch(switches::kEnableHTMLImports)) 139 WebRuntimeFeatures::enableHTMLImports(true); 140 141 if (command_line.HasSwitch(switches::kEnableOverlayFullscreenVideo)) 142 WebRuntimeFeatures::enableOverlayFullscreenVideo(true); 143 144 if (command_line.HasSwitch(switches::kEnableOverlayScrollbars)) 145 WebRuntimeFeatures::enableOverlayScrollbars(true); 146 147 if (command_line.HasSwitch(switches::kEnableInputModeAttribute)) 148 WebRuntimeFeatures::enableInputModeAttribute(true); 149 150 if (command_line.HasSwitch(switches::kEnableFastTextAutosizing)) 151 WebRuntimeFeatures::enableFastTextAutosizing(true); 152} 153 154} // namespace content 155