1 /* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef RuntimeEnabledFeatures_h 32 #define RuntimeEnabledFeatures_h 33 34 namespace WebCore { 35 36 // A class that stores static enablers for all experimental features. Note that 37 // the method names must line up with the JavaScript method they enable for code 38 // generation to work properly. 39 40 class RuntimeEnabledFeatures { 41 public: setLocalStorageEnabled(bool isEnabled)42 static void setLocalStorageEnabled(bool isEnabled) { isLocalStorageEnabled = isEnabled; } localStorageEnabled()43 static bool localStorageEnabled() { return isLocalStorageEnabled; } 44 setSessionStorageEnabled(bool isEnabled)45 static void setSessionStorageEnabled(bool isEnabled) { isSessionStorageEnabled = isEnabled; } sessionStorageEnabled()46 static bool sessionStorageEnabled() { return isSessionStorageEnabled; } 47 setWebkitNotificationsEnabled(bool isEnabled)48 static void setWebkitNotificationsEnabled(bool isEnabled) { isWebkitNotificationsEnabled = isEnabled; } webkitNotificationsEnabled()49 static bool webkitNotificationsEnabled() { return isWebkitNotificationsEnabled; } 50 setApplicationCacheEnabled(bool isEnabled)51 static void setApplicationCacheEnabled(bool isEnabled) { isApplicationCacheEnabled = isEnabled; } applicationCacheEnabled()52 static bool applicationCacheEnabled() { return isApplicationCacheEnabled; } 53 setDataTransferItemsEnabled(bool isEnabled)54 static void setDataTransferItemsEnabled(bool isEnabled) { isDataTransferItemsEnabled = isEnabled; } dataTransferItemsEnabled()55 static bool dataTransferItemsEnabled() { return isDataTransferItemsEnabled; } 56 setGeolocationEnabled(bool isEnabled)57 static void setGeolocationEnabled(bool isEnabled) { isGeolocationEnabled = isEnabled; } geolocationEnabled()58 static bool geolocationEnabled() { return isGeolocationEnabled; } 59 setWebkitIndexedDBEnabled(bool isEnabled)60 static void setWebkitIndexedDBEnabled(bool isEnabled) { isIndexedDBEnabled = isEnabled; } webkitIndexedDBEnabled()61 static bool webkitIndexedDBEnabled() { return isIndexedDBEnabled; } webkitIDBCursorEnabled()62 static bool webkitIDBCursorEnabled() { return isIndexedDBEnabled; } webkitIDBDatabaseEnabled()63 static bool webkitIDBDatabaseEnabled() { return isIndexedDBEnabled; } webkitIDBDatabaseErrorEnabled()64 static bool webkitIDBDatabaseErrorEnabled() { return isIndexedDBEnabled; } webkitIDBDatabaseExceptionEnabled()65 static bool webkitIDBDatabaseExceptionEnabled() { return isIndexedDBEnabled; } webkitIDBFactoryEnabled()66 static bool webkitIDBFactoryEnabled() { return isIndexedDBEnabled; } webkitIDBIndexEnabled()67 static bool webkitIDBIndexEnabled() { return isIndexedDBEnabled; } webkitIDBKeyRangeEnabled()68 static bool webkitIDBKeyRangeEnabled() { return isIndexedDBEnabled; } webkitIDBObjectStoreEnabled()69 static bool webkitIDBObjectStoreEnabled() { return isIndexedDBEnabled; } webkitIDBRequestEnabled()70 static bool webkitIDBRequestEnabled() { return isIndexedDBEnabled; } webkitIDBTransactionEnabled()71 static bool webkitIDBTransactionEnabled() { return isIndexedDBEnabled; } 72 73 #if ENABLE(VIDEO) 74 static bool audioEnabled(); 75 static bool htmlMediaElementEnabled(); 76 static bool htmlAudioElementEnabled(); 77 static bool htmlVideoElementEnabled(); 78 static bool mediaErrorEnabled(); 79 static bool timeRangesEnabled(); 80 #endif 81 82 #if ENABLE(SHARED_WORKERS) 83 static bool sharedWorkerEnabled(); 84 #endif 85 86 #if ENABLE(WEB_SOCKETS) 87 static bool webSocketEnabled(); 88 #endif 89 90 #if ENABLE(DATABASE) 91 static bool openDatabaseEnabled(); 92 static bool openDatabaseSyncEnabled(); 93 #endif 94 95 #if ENABLE(WEB_AUDIO) setWebkitAudioContextEnabled(bool isEnabled)96 static void setWebkitAudioContextEnabled(bool isEnabled) { isWebAudioEnabled = isEnabled; } webkitAudioContextEnabled()97 static bool webkitAudioContextEnabled() { return isWebAudioEnabled; } 98 #endif 99 setPushStateEnabled(bool isEnabled)100 static void setPushStateEnabled(bool isEnabled) { isPushStateEnabled = isEnabled; } pushStateEnabled()101 static bool pushStateEnabled() { return isPushStateEnabled; } replaceStateEnabled()102 static bool replaceStateEnabled() { return isPushStateEnabled; } 103 104 #if ENABLE(TOUCH_EVENTS) touchEnabled()105 static bool touchEnabled() { return isTouchEnabled; } setTouchEnabled(bool isEnabled)106 static void setTouchEnabled(bool isEnabled) { isTouchEnabled = isEnabled; } ontouchstartEnabled()107 static bool ontouchstartEnabled() { return isTouchEnabled; } ontouchmoveEnabled()108 static bool ontouchmoveEnabled() { return isTouchEnabled; } ontouchendEnabled()109 static bool ontouchendEnabled() { return isTouchEnabled; } ontouchcancelEnabled()110 static bool ontouchcancelEnabled() { return isTouchEnabled; } createTouchEnabled()111 static bool createTouchEnabled() { return isTouchEnabled; } createTouchListEnabled()112 static bool createTouchListEnabled() { return isTouchEnabled; } 113 #endif 114 setDeviceMotionEnabled(bool isEnabled)115 static void setDeviceMotionEnabled(bool isEnabled) { isDeviceMotionEnabled = isEnabled; } deviceMotionEnabled()116 static bool deviceMotionEnabled() { return isDeviceMotionEnabled; } deviceMotionEventEnabled()117 static bool deviceMotionEventEnabled() { return isDeviceMotionEnabled; } ondevicemotionEnabled()118 static bool ondevicemotionEnabled() { return isDeviceMotionEnabled; } 119 setDeviceOrientationEnabled(bool isEnabled)120 static void setDeviceOrientationEnabled(bool isEnabled) { isDeviceOrientationEnabled = isEnabled; } deviceOrientationEnabled()121 static bool deviceOrientationEnabled() { return isDeviceOrientationEnabled; } deviceOrientationEventEnabled()122 static bool deviceOrientationEventEnabled() { return isDeviceOrientationEnabled; } ondeviceorientationEnabled()123 static bool ondeviceorientationEnabled() { return isDeviceOrientationEnabled; } 124 setSpeechInputEnabled(bool isEnabled)125 static void setSpeechInputEnabled(bool isEnabled) { isSpeechInputEnabled = isEnabled; } speechInputEnabled()126 static bool speechInputEnabled() { return isSpeechInputEnabled; } webkitSpeechEnabled()127 static bool webkitSpeechEnabled() { return isSpeechInputEnabled; } webkitGrammarEnabled()128 static bool webkitGrammarEnabled() { return isSpeechInputEnabled; } 129 130 #if ENABLE(XHR_RESPONSE_BLOB) xhrResponseBlobEnabled()131 static bool xhrResponseBlobEnabled() { return isXHRResponseBlobEnabled; } setXHRResponseBlobEnabled(bool isEnabled)132 static void setXHRResponseBlobEnabled(bool isEnabled) { isXHRResponseBlobEnabled = isEnabled; } responseBlobEnabled()133 static bool responseBlobEnabled() { return isXHRResponseBlobEnabled; } asBlobEnabled()134 static bool asBlobEnabled() { return isXHRResponseBlobEnabled; } 135 #endif 136 137 #if ENABLE(FILE_SYSTEM) 138 static bool fileSystemEnabled(); setFileSystemEnabled(bool isEnabled)139 static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; } 140 #endif 141 142 #if ENABLE(JAVASCRIPT_I18N_API) 143 static bool javaScriptI18NAPIEnabled(); setJavaScriptI18NAPIEnabled(bool isEnabled)144 static void setJavaScriptI18NAPIEnabled(bool isEnabled) { isJavaScriptI18NAPIEnabled = isEnabled; } 145 #endif 146 147 #if ENABLE(MEDIA_STREAM) mediaStreamEnabled()148 static bool mediaStreamEnabled() { return isMediaStreamEnabled; } setMediaStreamEnabled(bool isEnabled)149 static void setMediaStreamEnabled(bool isEnabled) { isMediaStreamEnabled = isEnabled; } webkitGetUserMediaEnabled()150 static bool webkitGetUserMediaEnabled() { return isMediaStreamEnabled; } 151 #endif 152 153 #if ENABLE(QUOTA) quotaEnabled()154 static bool quotaEnabled() { return isQuotaEnabled; } setQuotaEnabled(bool isEnabled)155 static void setQuotaEnabled(bool isEnabled) { isQuotaEnabled = isEnabled; } 156 #endif 157 158 private: 159 // Never instantiate. RuntimeEnabledFeatures()160 RuntimeEnabledFeatures() { } 161 162 static bool isLocalStorageEnabled; 163 static bool isSessionStorageEnabled; 164 static bool isWebkitNotificationsEnabled; 165 static bool isApplicationCacheEnabled; 166 static bool isDataTransferItemsEnabled; 167 static bool isGeolocationEnabled; 168 static bool isIndexedDBEnabled; 169 static bool isWebAudioEnabled; 170 static bool isPushStateEnabled; 171 static bool isTouchEnabled; 172 static bool isDeviceMotionEnabled; 173 static bool isDeviceOrientationEnabled; 174 static bool isSpeechInputEnabled; 175 #if ENABLE(XHR_RESPONSE_BLOB) 176 static bool isXHRResponseBlobEnabled; 177 #endif 178 179 #if ENABLE(FILE_SYSTEM) 180 static bool isFileSystemEnabled; 181 #endif 182 183 #if ENABLE(JAVASCRIPT_I18N_API) 184 static bool isJavaScriptI18NAPIEnabled; 185 #endif 186 187 #if ENABLE(MEDIA_STREAM) 188 static bool isMediaStreamEnabled; 189 #endif 190 191 #if ENABLE(QUOTA) 192 static bool isQuotaEnabled; 193 #endif 194 }; 195 196 } // namespace WebCore 197 198 #endif // RuntimeEnabledFeatures_h 199