runtime_features.cc revision 7dbb3d5cf0c15f500944d211057644d6a2f37371
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) && !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 = false; 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 // Android does not have support for PagePopup 36 WebRuntimeFeatures::enablePagePopup(false); 37 // datalist on Android is not enabled 38 WebRuntimeFeatures::enableDataListElement(false); 39#endif 40} 41 42void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( 43 const CommandLine& command_line) { 44 WebRuntimeFeatures::enableStableFeatures(true); 45 46 if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)) 47 WebRuntimeFeatures::enableExperimentalFeatures(true); 48 49 SetRuntimeFeatureDefaultsForPlatform(); 50 51 if (command_line.HasSwitch(switches::kDisableDatabases)) 52 WebRuntimeFeatures::enableDatabase(false); 53 54 if (command_line.HasSwitch(switches::kDisableApplicationCache)) 55 WebRuntimeFeatures::enableApplicationCache(false); 56 57 if (command_line.HasSwitch(switches::kDisableDesktopNotifications)) 58 WebRuntimeFeatures::enableNotifications(false); 59 60 if (command_line.HasSwitch(switches::kDisableLocalStorage)) 61 WebRuntimeFeatures::enableLocalStorage(false); 62 63 if (command_line.HasSwitch(switches::kDisableSessionStorage)) 64 WebRuntimeFeatures::enableSessionStorage(false); 65 66 if (command_line.HasSwitch(switches::kDisableGeolocation)) 67 WebRuntimeFeatures::enableGeolocation(false); 68 69#if defined(OS_ANDROID) && !defined(GOOGLE_TV) 70 if (command_line.HasSwitch(switches::kEnableWebKitMediaSource)) 71 WebRuntimeFeatures::enableWebKitMediaSource(true); 72#else 73 if (command_line.HasSwitch(switches::kDisableWebKitMediaSource)) 74 WebRuntimeFeatures::enableWebKitMediaSource(false); 75#endif 76 77#if defined(OS_ANDROID) 78 if (command_line.HasSwitch(switches::kDisableWebRTC)) { 79 WebRuntimeFeatures::enableMediaStream(false); 80 WebRuntimeFeatures::enablePeerConnection(false); 81 } 82 83 if (!command_line.HasSwitch(switches::kEnableSpeechRecognition)) 84 WebRuntimeFeatures::enableScriptedSpeech(false); 85#endif 86 87 if (command_line.HasSwitch(switches::kDisableWebAudio)) 88 WebRuntimeFeatures::enableWebAudio(false); 89 90 if (command_line.HasSwitch(switches::kDisableFullScreen)) 91 WebRuntimeFeatures::enableFullscreen(false); 92 93 if (command_line.HasSwitch(switches::kEnableEncryptedMedia)) 94 WebRuntimeFeatures::enableEncryptedMedia(true); 95 96 if (command_line.HasSwitch(switches::kDisableLegacyEncryptedMedia)) 97 WebRuntimeFeatures::enableLegacyEncryptedMedia(false); 98 99 if (command_line.HasSwitch(switches::kEnableWebAnimationsCSS)) 100 WebRuntimeFeatures::enableWebAnimationsCSS(); 101 102 if (command_line.HasSwitch(switches::kEnableWebAnimationsSVG)) 103 WebRuntimeFeatures::enableWebAnimationsSVG(); 104 105 if (command_line.HasSwitch(switches::kEnableWebMIDI)) 106 WebRuntimeFeatures::enableWebMIDI(true); 107 108 if (command_line.HasSwitch(switches::kEnableDeviceMotion)) 109 WebRuntimeFeatures::enableDeviceMotion(true); 110 111 if (command_line.HasSwitch(switches::kDisableDeviceOrientation)) 112 WebRuntimeFeatures::enableDeviceOrientation(false); 113 114 if (command_line.HasSwitch(switches::kDisableSpeechInput)) 115 WebRuntimeFeatures::enableSpeechInput(false); 116 117 if (command_line.HasSwitch(switches::kDisableFileSystem)) 118 WebRuntimeFeatures::enableFileSystem(false); 119 120 if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures)) 121 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true); 122 123 if (command_line.HasSwitch(switches::kEnableSpeechSynthesis)) 124 WebRuntimeFeatures::enableSpeechSynthesis(true); 125 126 if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions)) 127 WebRuntimeFeatures::enableWebGLDraftExtensions(true); 128} 129 130} // namespace content 131