|
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 "AbstractDatabase.h" |
|
35 #include "RuntimeEnabledFeatures.h" |
|
36 #include "WebMediaPlayerClientImpl.h" |
|
37 #include "WebSocket.h" |
|
38 |
|
39 using namespace WebCore; |
|
40 |
|
41 namespace WebKit { |
|
42 |
|
43 void WebRuntimeFeatures::enableDatabase(bool enable) |
|
44 { |
|
45 #if ENABLE(DATABASE) |
|
46 AbstractDatabase::setIsAvailable(enable); |
|
47 #endif |
|
48 } |
|
49 |
|
50 bool WebRuntimeFeatures::isDatabaseEnabled() |
|
51 { |
|
52 #if ENABLE(DATABASE) |
|
53 return AbstractDatabase::isAvailable(); |
|
54 #else |
|
55 return false; |
|
56 #endif |
|
57 } |
|
58 |
|
59 void WebRuntimeFeatures::enableLocalStorage(bool enable) |
|
60 { |
|
61 #if ENABLE(DOM_STORAGE) |
|
62 RuntimeEnabledFeatures::setLocalStorageEnabled(enable); |
|
63 #endif |
|
64 } |
|
65 |
|
66 bool WebRuntimeFeatures::isLocalStorageEnabled() |
|
67 { |
|
68 #if ENABLE(DOM_STORAGE) |
|
69 return RuntimeEnabledFeatures::localStorageEnabled(); |
|
70 #else |
|
71 return false; |
|
72 #endif |
|
73 } |
|
74 |
|
75 void WebRuntimeFeatures::enableSessionStorage(bool enable) |
|
76 { |
|
77 #if ENABLE(DOM_STORAGE) |
|
78 RuntimeEnabledFeatures::setSessionStorageEnabled(enable); |
|
79 #endif |
|
80 } |
|
81 |
|
82 bool WebRuntimeFeatures::isSessionStorageEnabled() |
|
83 { |
|
84 #if ENABLE(DOM_STORAGE) |
|
85 return RuntimeEnabledFeatures::sessionStorageEnabled(); |
|
86 #else |
|
87 return false; |
|
88 #endif |
|
89 } |
|
90 |
|
91 void WebRuntimeFeatures::enableMediaPlayer(bool enable) |
|
92 { |
|
93 #if ENABLE(VIDEO) |
|
94 WebMediaPlayerClientImpl::setIsEnabled(enable); |
|
95 #endif |
|
96 } |
|
97 |
|
98 bool WebRuntimeFeatures::isMediaPlayerEnabled() |
|
99 { |
|
100 #if ENABLE(VIDEO) |
|
101 return WebMediaPlayerClientImpl::isEnabled(); |
|
102 #else |
|
103 return false; |
|
104 #endif |
|
105 } |
|
106 |
|
107 void WebRuntimeFeatures::enableSockets(bool enable) |
|
108 { |
|
109 #if ENABLE(WEB_SOCKETS) |
|
110 WebSocket::setIsAvailable(enable); |
|
111 #endif |
|
112 } |
|
113 |
|
114 bool WebRuntimeFeatures::isSocketsEnabled() |
|
115 { |
|
116 #if ENABLE(WEB_SOCKETS) |
|
117 return WebSocket::isAvailable(); |
|
118 #else |
|
119 return false; |
|
120 #endif |
|
121 } |
|
122 |
|
123 void WebRuntimeFeatures::enableNotifications(bool enable) |
|
124 { |
|
125 #if ENABLE(NOTIFICATIONS) |
|
126 RuntimeEnabledFeatures::setWebkitNotificationsEnabled(enable); |
|
127 #endif |
|
128 } |
|
129 |
|
130 bool WebRuntimeFeatures::isNotificationsEnabled() |
|
131 { |
|
132 #if ENABLE(NOTIFICATIONS) |
|
133 return RuntimeEnabledFeatures::webkitNotificationsEnabled(); |
|
134 #else |
|
135 return false; |
|
136 #endif |
|
137 } |
|
138 |
|
139 void WebRuntimeFeatures::enableApplicationCache(bool enable) |
|
140 { |
|
141 #if ENABLE(OFFLINE_WEB_APPLICATIONS) |
|
142 RuntimeEnabledFeatures::setApplicationCacheEnabled(enable); |
|
143 #endif |
|
144 } |
|
145 |
|
146 bool WebRuntimeFeatures::isApplicationCacheEnabled() |
|
147 { |
|
148 #if ENABLE(OFFLINE_WEB_APPLICATIONS) |
|
149 return RuntimeEnabledFeatures::applicationCacheEnabled(); |
|
150 #else |
|
151 return false; |
|
152 #endif |
|
153 } |
|
154 |
|
155 void WebRuntimeFeatures::enableGeolocation(bool enable) |
|
156 { |
|
157 #if ENABLE(GEOLOCATION) |
|
158 RuntimeEnabledFeatures::setGeolocationEnabled(enable); |
|
159 #endif |
|
160 } |
|
161 |
|
162 bool WebRuntimeFeatures::isGeolocationEnabled() |
|
163 { |
|
164 #if ENABLE(GEOLOCATION) |
|
165 return RuntimeEnabledFeatures::geolocationEnabled(); |
|
166 #else |
|
167 return false; |
|
168 #endif |
|
169 } |
|
170 |
|
171 void WebRuntimeFeatures::enableIndexedDatabase(bool enable) |
|
172 { |
|
173 #if ENABLE(INDEXED_DATABASE) |
|
174 RuntimeEnabledFeatures::setIndexedDBEnabled(enable); |
|
175 #endif |
|
176 } |
|
177 |
|
178 bool WebRuntimeFeatures::isIndexedDatabaseEnabled() |
|
179 { |
|
180 #if ENABLE(INDEXED_DATABASE) |
|
181 return RuntimeEnabledFeatures::indexedDBEnabled(); |
|
182 #else |
|
183 return false; |
|
184 #endif |
|
185 } |
|
186 |
|
187 void WebRuntimeFeatures::enableWebGL(bool enable) |
|
188 { |
|
189 #if ENABLE(3D_CANVAS) |
|
190 RuntimeEnabledFeatures::setWebGLEnabled(enable); |
|
191 #endif |
|
192 } |
|
193 |
|
194 bool WebRuntimeFeatures::isWebGLEnabled() |
|
195 { |
|
196 #if ENABLE(3D_CANVAS) |
|
197 return RuntimeEnabledFeatures::webGLRenderingContextEnabled(); |
|
198 #else |
|
199 return false; |
|
200 #endif |
|
201 } |
|
202 |
|
203 void WebRuntimeFeatures::enablePushState(bool enable) |
|
204 { |
|
205 RuntimeEnabledFeatures::setPushStateEnabled(enable); |
|
206 } |
|
207 |
|
208 bool WebRuntimeFeatures::isPushStateEnabled(bool enable) |
|
209 { |
|
210 return RuntimeEnabledFeatures::pushStateEnabled(); |
|
211 } |
|
212 |
|
213 void WebRuntimeFeatures::enableTouch(bool enable) |
|
214 { |
|
215 #if ENABLE(TOUCH_EVENTS) |
|
216 RuntimeEnabledFeatures::setTouchEnabled(enable); |
|
217 #endif |
|
218 } |
|
219 |
|
220 bool WebRuntimeFeatures::isTouchEnabled() |
|
221 { |
|
222 #if ENABLE(TOUCH_EVENTS) |
|
223 return RuntimeEnabledFeatures::touchEnabled(); |
|
224 #else |
|
225 return false; |
|
226 #endif |
|
227 } |
|
228 |
|
229 void WebRuntimeFeatures::enableDeviceOrientation(bool enable) |
|
230 { |
|
231 RuntimeEnabledFeatures::setDeviceOrientationEnabled(enable); |
|
232 } |
|
233 |
|
234 bool WebRuntimeFeatures::isDeviceOrientationEnabled() |
|
235 { |
|
236 return RuntimeEnabledFeatures::deviceOrientationEnabled(); |
|
237 } |
|
238 |
|
239 } // namespace WebKit |