• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "config.h"
32 #include "WebRuntimeFeatures.h"
33 
34 #include "Database.h"
35 #include "RuntimeEnabledFeatures.h"
36 #include "WebMediaPlayerClientImpl.h"
37 #include "WebSocket.h"
38 
39 using namespace WebCore;
40 
41 namespace WebKit {
42 
enableDatabase(bool enable)43 void WebRuntimeFeatures::enableDatabase(bool enable)
44 {
45 #if ENABLE(DATABASE)
46     Database::setIsAvailable(enable);
47 #endif
48 }
49 
isDatabaseEnabled()50 bool WebRuntimeFeatures::isDatabaseEnabled()
51 {
52 #if ENABLE(DATABASE)
53     return Database::isAvailable();
54 #else
55     return false;
56 #endif
57 }
58 
enableLocalStorage(bool enable)59 void WebRuntimeFeatures::enableLocalStorage(bool enable)
60 {
61 #if ENABLE(DOM_STORAGE)
62     RuntimeEnabledFeatures::setLocalStorageEnabled(enable);
63 #endif
64 }
65 
isLocalStorageEnabled()66 bool WebRuntimeFeatures::isLocalStorageEnabled()
67 {
68 #if ENABLE(DOM_STORAGE)
69     return RuntimeEnabledFeatures::localStorageEnabled();
70 #else
71     return false;
72 #endif
73 }
74 
enableSessionStorage(bool enable)75 void WebRuntimeFeatures::enableSessionStorage(bool enable)
76 {
77 #if ENABLE(DOM_STORAGE)
78     RuntimeEnabledFeatures::setSessionStorageEnabled(enable);
79 #endif
80 }
81 
isSessionStorageEnabled()82 bool WebRuntimeFeatures::isSessionStorageEnabled()
83 {
84 #if ENABLE(DOM_STORAGE)
85     return RuntimeEnabledFeatures::sessionStorageEnabled();
86 #else
87     return false;
88 #endif
89 }
90 
enableMediaPlayer(bool enable)91 void WebRuntimeFeatures::enableMediaPlayer(bool enable)
92 {
93 #if ENABLE(VIDEO)
94     WebMediaPlayerClientImpl::setIsEnabled(enable);
95 #endif
96 }
97 
isMediaPlayerEnabled()98 bool WebRuntimeFeatures::isMediaPlayerEnabled()
99 {
100 #if ENABLE(VIDEO)
101     return WebMediaPlayerClientImpl::isEnabled();
102 #else
103     return false;
104 #endif
105 }
106 
enableSockets(bool enable)107 void WebRuntimeFeatures::enableSockets(bool enable)
108 {
109 #if ENABLE(WEB_SOCKETS)
110     WebSocket::setIsAvailable(enable);
111 #endif
112 }
113 
isSocketsEnabled()114 bool WebRuntimeFeatures::isSocketsEnabled()
115 {
116 #if ENABLE(WEB_SOCKETS)
117     return WebSocket::isAvailable();
118 #else
119     return false;
120 #endif
121 }
122 
enableNotifications(bool enable)123 void WebRuntimeFeatures::enableNotifications(bool enable)
124 {
125 #if ENABLE(NOTIFICATIONS)
126     RuntimeEnabledFeatures::setWebkitNotificationsEnabled(enable);
127 #endif
128 }
129 
isNotificationsEnabled()130 bool WebRuntimeFeatures::isNotificationsEnabled()
131 {
132 #if ENABLE(NOTIFICATIONS)
133     return RuntimeEnabledFeatures::webkitNotificationsEnabled();
134 #else
135     return false;
136 #endif
137 }
138 
enableApplicationCache(bool enable)139 void WebRuntimeFeatures::enableApplicationCache(bool enable)
140 {
141 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
142     RuntimeEnabledFeatures::setApplicationCacheEnabled(enable);
143 #endif
144 }
145 
isApplicationCacheEnabled()146 bool WebRuntimeFeatures::isApplicationCacheEnabled()
147 {
148 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
149     return RuntimeEnabledFeatures::applicationCacheEnabled();
150 #else
151     return false;
152 #endif
153 }
154 
enableGeolocation(bool enable)155 void WebRuntimeFeatures::enableGeolocation(bool enable)
156 {
157 #if ENABLE(GEOLOCATION)
158     RuntimeEnabledFeatures::setGeolocationEnabled(enable);
159 #endif
160 }
161 
isGeolocationEnabled()162 bool WebRuntimeFeatures::isGeolocationEnabled()
163 {
164 #if ENABLE(GEOLOCATION)
165     return RuntimeEnabledFeatures::geolocationEnabled();
166 #else
167     return false;
168 #endif
169 }
170 
enableIndexedDatabase(bool enable)171 void WebRuntimeFeatures::enableIndexedDatabase(bool enable)
172 {
173 #if ENABLE(INDEXED_DATABASE)
174     RuntimeEnabledFeatures::setIndexedDBEnabled(enable);
175 #endif
176 }
177 
isIndexedDatabaseEnabled()178 bool WebRuntimeFeatures::isIndexedDatabaseEnabled()
179 {
180 #if ENABLE(INDEXED_DATABASE)
181     return RuntimeEnabledFeatures::indexedDBEnabled();
182 #else
183     return false;
184 #endif
185 }
186 
187 } // namespace WebKit
188