runtime_features.cc revision 558790d6acca3451cf3a6b497803a5f07d0bec58
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#endif 14 15using WebKit::WebRuntimeFeatures; 16 17namespace content { 18 19static void SetRuntimeFeatureDefaultsForPlatform() { 20#if defined(OS_ANDROID) 21 bool enable_webaudio = false; 22#if defined(ARCH_CPU_ARMEL) 23 enable_webaudio = 24 ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0); 25#endif 26 WebRuntimeFeatures::enableWebAudio(enable_webaudio); 27 // Android does not support the Gamepad API. 28 WebRuntimeFeatures::enableGamepad(false); 29 // Android does not have support for PagePopup 30 WebRuntimeFeatures::enablePagePopup(false); 31 // datalist on Android is not enabled 32 WebRuntimeFeatures::enableDataListElement(false); 33#endif 34} 35 36void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( 37 const CommandLine& command_line) { 38 WebRuntimeFeatures::enableStableFeatures(true); 39 40 if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)) 41 WebRuntimeFeatures::enableExperimentalFeatures(true); 42 43 SetRuntimeFeatureDefaultsForPlatform(); 44 45 if (command_line.HasSwitch(switches::kDisableDatabases)) 46 WebRuntimeFeatures::enableDatabase(false); 47 48 if (command_line.HasSwitch(switches::kDisableApplicationCache)) 49 WebRuntimeFeatures::enableApplicationCache(false); 50 51 if (command_line.HasSwitch(switches::kDisableDesktopNotifications)) 52 WebRuntimeFeatures::enableNotifications(false); 53 54 if (command_line.HasSwitch(switches::kDisableLocalStorage)) 55 WebRuntimeFeatures::enableLocalStorage(false); 56 57 if (command_line.HasSwitch(switches::kDisableSessionStorage)) 58 WebRuntimeFeatures::enableSessionStorage(false); 59 60 if (command_line.HasSwitch(switches::kDisableGeolocation)) 61 WebRuntimeFeatures::enableGeolocation(false); 62 63 if (command_line.HasSwitch(switches::kDisableWebKitMediaSource)) 64 WebRuntimeFeatures::enableWebKitMediaSource(false); 65 66#if defined(OS_ANDROID) 67 if (command_line.HasSwitch(switches::kDisableWebRTC)) { 68 WebRuntimeFeatures::enableMediaStream(false); 69 WebRuntimeFeatures::enablePeerConnection(false); 70 } 71 72 if (!command_line.HasSwitch(switches::kEnableSpeechRecognition)) 73 WebRuntimeFeatures::enableScriptedSpeech(false); 74#endif 75 76 if (command_line.HasSwitch(switches::kDisableWebAudio)) 77 WebRuntimeFeatures::enableWebAudio(false); 78 79 if (command_line.HasSwitch(switches::kDisableFullScreen)) 80 WebRuntimeFeatures::enableFullscreen(false); 81 82 if (command_line.HasSwitch(switches::kEnableEncryptedMedia)) 83 WebRuntimeFeatures::enableEncryptedMedia(true); 84 85 if (command_line.HasSwitch(switches::kDisableLegacyEncryptedMedia)) 86 WebRuntimeFeatures::enableLegacyEncryptedMedia(false); 87 88 if (command_line.HasSwitch(switches::kEnableWebAnimationsCSS)) 89 WebRuntimeFeatures::enableWebAnimationsCSS(); 90 91 if (command_line.HasSwitch(switches::kEnableWebAnimationsSVG)) 92 WebRuntimeFeatures::enableWebAnimationsSVG(); 93 94 if (command_line.HasSwitch(switches::kEnableWebMIDI)) 95 WebRuntimeFeatures::enableWebMIDI(true); 96 97 if (command_line.HasSwitch(switches::kEnableDeviceMotion)) 98 WebRuntimeFeatures::enableDeviceMotion(true); 99 100 if (command_line.HasSwitch(switches::kDisableDeviceOrientation)) 101 WebRuntimeFeatures::enableDeviceOrientation(false); 102 103 if (command_line.HasSwitch(switches::kDisableSpeechInput)) 104 WebRuntimeFeatures::enableSpeechInput(false); 105 106 if (command_line.HasSwitch(switches::kDisableFileSystem)) 107 WebRuntimeFeatures::enableFileSystem(false); 108 109 if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures)) 110 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true); 111 112 if (command_line.HasSwitch(switches::kEnableSpeechSynthesis)) 113 WebRuntimeFeatures::enableSpeechSynthesis(true); 114 115 if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions)) 116 WebRuntimeFeatures::enableWebGLDraftExtensions(true); 117} 118 119} // namespace content 120