Home | History | Annotate | Download | only in generic
      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:
     42     static void setLocalStorageEnabled(bool isEnabled) { isLocalStorageEnabled = isEnabled; }
     43     static bool localStorageEnabled() { return isLocalStorageEnabled; }
     44 
     45     static void setSessionStorageEnabled(bool isEnabled) { isSessionStorageEnabled = isEnabled; }
     46     static bool sessionStorageEnabled() { return isSessionStorageEnabled; }
     47 
     48     static void setWebkitNotificationsEnabled(bool isEnabled) { isWebkitNotificationsEnabled = isEnabled; }
     49     static bool webkitNotificationsEnabled() { return isWebkitNotificationsEnabled; }
     50 
     51     static void setApplicationCacheEnabled(bool isEnabled) { isApplicationCacheEnabled = isEnabled; }
     52     static bool applicationCacheEnabled() { return isApplicationCacheEnabled; }
     53 
     54     static void setDataTransferItemsEnabled(bool isEnabled) { isDataTransferItemsEnabled = isEnabled; }
     55     static bool dataTransferItemsEnabled() { return isDataTransferItemsEnabled; }
     56 
     57     static void setGeolocationEnabled(bool isEnabled) { isGeolocationEnabled = isEnabled; }
     58     static bool geolocationEnabled() { return isGeolocationEnabled; }
     59 
     60     static void setWebkitIndexedDBEnabled(bool isEnabled) { isIndexedDBEnabled = isEnabled; }
     61     static bool webkitIndexedDBEnabled() { return isIndexedDBEnabled; }
     62     static bool webkitIDBCursorEnabled() { return isIndexedDBEnabled; }
     63     static bool webkitIDBDatabaseEnabled() { return isIndexedDBEnabled; }
     64     static bool webkitIDBDatabaseErrorEnabled() { return isIndexedDBEnabled; }
     65     static bool webkitIDBDatabaseExceptionEnabled() { return isIndexedDBEnabled; }
     66     static bool webkitIDBFactoryEnabled() { return isIndexedDBEnabled; }
     67     static bool webkitIDBIndexEnabled() { return isIndexedDBEnabled; }
     68     static bool webkitIDBKeyRangeEnabled() { return isIndexedDBEnabled; }
     69     static bool webkitIDBObjectStoreEnabled() { return isIndexedDBEnabled; }
     70     static bool webkitIDBRequestEnabled() { return isIndexedDBEnabled; }
     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)
     96     static void setWebkitAudioContextEnabled(bool isEnabled) { isWebAudioEnabled = isEnabled; }
     97     static bool webkitAudioContextEnabled() { return isWebAudioEnabled; }
     98 #endif
     99 
    100     static void setPushStateEnabled(bool isEnabled) { isPushStateEnabled = isEnabled; }
    101     static bool pushStateEnabled() { return isPushStateEnabled; }
    102     static bool replaceStateEnabled() { return isPushStateEnabled; }
    103 
    104 #if ENABLE(TOUCH_EVENTS)
    105     static bool touchEnabled() { return isTouchEnabled; }
    106     static void setTouchEnabled(bool isEnabled) { isTouchEnabled = isEnabled; }
    107     static bool ontouchstartEnabled() { return isTouchEnabled; }
    108     static bool ontouchmoveEnabled() { return isTouchEnabled; }
    109     static bool ontouchendEnabled() { return isTouchEnabled; }
    110     static bool ontouchcancelEnabled() { return isTouchEnabled; }
    111     static bool createTouchEnabled() { return isTouchEnabled; }
    112     static bool createTouchListEnabled() { return isTouchEnabled; }
    113 #endif
    114 
    115     static void setDeviceMotionEnabled(bool isEnabled) { isDeviceMotionEnabled = isEnabled; }
    116     static bool deviceMotionEnabled() { return isDeviceMotionEnabled; }
    117     static bool deviceMotionEventEnabled() { return isDeviceMotionEnabled; }
    118     static bool ondevicemotionEnabled() { return isDeviceMotionEnabled; }
    119 
    120     static void setDeviceOrientationEnabled(bool isEnabled) { isDeviceOrientationEnabled = isEnabled; }
    121     static bool deviceOrientationEnabled() { return isDeviceOrientationEnabled; }
    122     static bool deviceOrientationEventEnabled() { return isDeviceOrientationEnabled; }
    123     static bool ondeviceorientationEnabled() { return isDeviceOrientationEnabled; }
    124 
    125     static void setSpeechInputEnabled(bool isEnabled) { isSpeechInputEnabled = isEnabled; }
    126     static bool speechInputEnabled() { return isSpeechInputEnabled; }
    127     static bool webkitSpeechEnabled() { return isSpeechInputEnabled; }
    128     static bool webkitGrammarEnabled() { return isSpeechInputEnabled; }
    129 
    130 #if ENABLE(XHR_RESPONSE_BLOB)
    131     static bool xhrResponseBlobEnabled() { return isXHRResponseBlobEnabled; }
    132     static void setXHRResponseBlobEnabled(bool isEnabled) { isXHRResponseBlobEnabled = isEnabled; }
    133     static bool responseBlobEnabled() { return isXHRResponseBlobEnabled; }
    134     static bool asBlobEnabled()  { return isXHRResponseBlobEnabled; }
    135 #endif
    136 
    137 #if ENABLE(FILE_SYSTEM)
    138     static bool fileSystemEnabled();
    139     static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; }
    140 #endif
    141 
    142 #if ENABLE(JAVASCRIPT_I18N_API)
    143     static bool javaScriptI18NAPIEnabled();
    144     static void setJavaScriptI18NAPIEnabled(bool isEnabled) { isJavaScriptI18NAPIEnabled = isEnabled; }
    145 #endif
    146 
    147 #if ENABLE(MEDIA_STREAM)
    148     static bool mediaStreamEnabled() { return isMediaStreamEnabled; }
    149     static void setMediaStreamEnabled(bool isEnabled) { isMediaStreamEnabled = isEnabled; }
    150     static bool webkitGetUserMediaEnabled() { return isMediaStreamEnabled; }
    151 #endif
    152 
    153 #if ENABLE(QUOTA)
    154     static bool quotaEnabled() { return isQuotaEnabled; }
    155     static void setQuotaEnabled(bool isEnabled) { isQuotaEnabled = isEnabled; }
    156 #endif
    157 
    158 private:
    159     // Never instantiate.
    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