1/* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * * Neither the name of Google Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include "config.h" 33#include "RuntimeEnabledFeatures.h" 34 35#include "DatabaseManager.h" 36#include "MediaPlayer.h" 37#include "SharedWorkerRepository.h" 38#include "WebSocket.h" 39#include <wtf/NeverDestroyed.h> 40 41namespace WebCore { 42 43RuntimeEnabledFeatures::RuntimeEnabledFeatures() 44 : m_isLocalStorageEnabled(true) 45 , m_isSessionStorageEnabled(true) 46 , m_isWebkitNotificationsEnabled(false) 47 , m_isApplicationCacheEnabled(true) 48 , m_isDataTransferItemsEnabled(true) 49 , m_isGeolocationEnabled(true) 50 , m_isIndexedDBEnabled(false) 51 , m_isTouchEnabled(true) 52 , m_isDeviceMotionEnabled(true) 53 , m_isDeviceOrientationEnabled(true) 54 , m_isSpeechInputEnabled(true) 55 , m_isCSSExclusionsEnabled(true) 56 , m_isCSSShapesEnabled(true) 57 , m_isCSSRegionsEnabled(false) 58 , m_isCSSCompositingEnabled(false) 59 , m_isLangAttributeAwareFormControlUIEnabled(false) 60#if PLATFORM(IOS) 61 , m_isPluginReplacementEnabled(true) 62#else 63 , m_isPluginReplacementEnabled(false) 64#endif 65#if ENABLE(SCRIPTED_SPEECH) 66 , m_isScriptedSpeechEnabled(false) 67#endif 68#if ENABLE(MEDIA_STREAM) 69 , m_isMediaStreamEnabled(true) 70 , m_isPeerConnectionEnabled(true) 71#endif 72#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) 73 , m_isLegacyCSSVendorPrefixesEnabled(false) 74#endif 75#if ENABLE(JAVASCRIPT_I18N_API) 76 , m_isJavaScriptI18NAPIEnabled(false) 77#endif 78#if ENABLE(VIDEO_TRACK) 79 , m_isVideoTrackEnabled(true) 80#endif 81#if ENABLE(INPUT_TYPE_DATE) 82 , m_isInputTypeDateEnabled(true) 83#endif 84#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE) 85 , m_isInputTypeDateTimeEnabled(false) 86#endif 87#if ENABLE(INPUT_TYPE_DATETIMELOCAL) 88 , m_isInputTypeDateTimeLocalEnabled(true) 89#endif 90#if ENABLE(INPUT_TYPE_MONTH) 91 , m_isInputTypeMonthEnabled(true) 92#endif 93#if ENABLE(INPUT_TYPE_TIME) 94 , m_isInputTypeTimeEnabled(true) 95#endif 96#if ENABLE(INPUT_TYPE_WEEK) 97 , m_isInputTypeWeekEnabled(true) 98#endif 99#if ENABLE(CSP_NEXT) 100 , m_areExperimentalContentSecurityPolicyFeaturesEnabled(false) 101#endif 102#if ENABLE(FONT_LOAD_EVENTS) 103 , m_isFontLoadEventsEnabled(false) 104#endif 105#if ENABLE(GAMEPAD) 106 , m_areGamepadsEnabled(false) 107#endif 108{ 109} 110 111RuntimeEnabledFeatures& RuntimeEnabledFeatures::sharedFeatures() 112{ 113 static NeverDestroyed<RuntimeEnabledFeatures> runtimeEnabledFeatures; 114 115 return runtimeEnabledFeatures; 116} 117 118#if ENABLE(JAVASCRIPT_I18N_API) 119bool RuntimeEnabledFeatures::javaScriptI18NAPIEnabled() 120{ 121 return m_isJavaScriptI18NAPIEnabled; 122} 123#endif 124 125#if ENABLE(VIDEO) 126bool RuntimeEnabledFeatures::audioEnabled() const 127{ 128 return MediaPlayer::isAvailable(); 129} 130 131bool RuntimeEnabledFeatures::htmlMediaElementEnabled() const 132{ 133 return MediaPlayer::isAvailable(); 134} 135 136bool RuntimeEnabledFeatures::htmlAudioElementEnabled() const 137{ 138 return MediaPlayer::isAvailable(); 139} 140 141bool RuntimeEnabledFeatures::htmlVideoElementEnabled() const 142{ 143 return MediaPlayer::isAvailable(); 144} 145 146bool RuntimeEnabledFeatures::htmlSourceElementEnabled() const 147{ 148 return MediaPlayer::isAvailable(); 149} 150 151bool RuntimeEnabledFeatures::mediaControllerEnabled() const 152{ 153 return MediaPlayer::isAvailable(); 154} 155 156bool RuntimeEnabledFeatures::mediaErrorEnabled() const 157{ 158 return MediaPlayer::isAvailable(); 159} 160 161bool RuntimeEnabledFeatures::timeRangesEnabled() const 162{ 163 return MediaPlayer::isAvailable(); 164} 165#endif 166 167#if ENABLE(SHARED_WORKERS) 168bool RuntimeEnabledFeatures::sharedWorkerEnabled() const 169{ 170 return SharedWorkerRepository::isAvailable(); 171} 172#endif 173 174#if ENABLE(WEB_SOCKETS) 175bool RuntimeEnabledFeatures::webSocketEnabled() const 176{ 177 return WebSocket::isAvailable(); 178} 179#endif 180 181} // namespace WebCore 182