|
1 /* |
|
2 * Copyright (C) 2010 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 WebKitClient_h |
|
32 #define WebKitClient_h |
|
33 |
|
34 #include "WebCommon.h" |
|
35 #include "WebData.h" |
|
36 #include "WebLocalizedString.h" |
|
37 #include "WebString.h" |
|
38 #include "WebURL.h" |
|
39 |
|
40 #include <time.h> |
|
41 |
|
42 #ifdef WIN32 |
|
43 typedef void *HANDLE; |
|
44 #endif |
|
45 |
|
46 namespace WebKit { |
|
47 |
|
48 class WebApplicationCacheHost; |
|
49 class WebApplicationCacheHostClient; |
|
50 class WebClipboard; |
|
51 class WebCookieJar; |
|
52 class WebFileSystem; |
|
53 class WebGLES2Context; |
|
54 class WebGraphicsContext3D; |
|
55 class WebIndexedDatabase; |
|
56 class WebMessagePortChannel; |
|
57 class WebMimeRegistry; |
|
58 class WebPluginListBuilder; |
|
59 class WebSandboxSupport; |
|
60 class WebSharedWorkerRepository; |
|
61 class WebSocketStreamHandle; |
|
62 class WebStorageNamespace; |
|
63 class WebThemeEngine; |
|
64 class WebURLLoader; |
|
65 |
|
66 class WebKitClient { |
|
67 public: |
|
68 // Must return non-null. |
|
69 virtual WebClipboard* clipboard() { return 0; } |
|
70 |
|
71 // Must return non-null. |
|
72 virtual WebMimeRegistry* mimeRegistry() { return 0; } |
|
73 |
|
74 // Must return non-null. |
|
75 virtual WebFileSystem* fileSystem() { return 0; } |
|
76 |
|
77 // May return null if sandbox support is not necessary |
|
78 virtual WebSandboxSupport* sandboxSupport() { return 0; } |
|
79 |
|
80 // May return null on some platforms. |
|
81 virtual WebThemeEngine* themeEngine() { return 0; } |
|
82 |
|
83 // May return null. |
|
84 virtual WebCookieJar* cookieJar() { return 0; } |
|
85 |
|
86 // DOM Storage -------------------------------------------------- |
|
87 |
|
88 // Return a LocalStorage namespace that corresponds to the following path. |
|
89 virtual WebStorageNamespace* createLocalStorageNamespace(const WebString& path, unsigned quota) { return 0; } |
|
90 |
|
91 // Called when storage events fire. |
|
92 virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue, |
|
93 const WebString& newValue, const WebString& origin, |
|
94 const WebURL& url, bool isLocalStorage) { } |
|
95 |
|
96 |
|
97 // History ------------------------------------------------------------- |
|
98 |
|
99 // Returns the hash for the given canonicalized URL for use in visited |
|
100 // link coloring. |
|
101 virtual unsigned long long visitedLinkHash( |
|
102 const char* canonicalURL, size_t length) { return 0; } |
|
103 |
|
104 // Returns whether the given link hash is in the user's history. The |
|
105 // hash must have been generated by calling VisitedLinkHash(). |
|
106 virtual bool isLinkVisited(unsigned long long linkHash) { return false; } |
|
107 |
|
108 |
|
109 // HTML5 Database ------------------------------------------------------ |
|
110 |
|
111 #ifdef WIN32 |
|
112 typedef HANDLE FileHandle; |
|
113 #else |
|
114 typedef int FileHandle; |
|
115 #endif |
|
116 |
|
117 // Opens a database file; dirHandle should be 0 if the caller does not need |
|
118 // a handle to the directory containing this file |
|
119 virtual FileHandle databaseOpenFile( |
|
120 const WebString& vfsFileName, int desiredFlags) { return FileHandle(); } |
|
121 |
|
122 // Deletes a database file and returns the error code |
|
123 virtual int databaseDeleteFile(const WebString& vfsFileName, bool syncDir) { return 0; } |
|
124 |
|
125 // Returns the attributes of the given database file |
|
126 virtual long databaseGetFileAttributes(const WebString& vfsFileName) { return 0; } |
|
127 |
|
128 // Returns the size of the given database file |
|
129 virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; } |
|
130 |
|
131 |
|
132 // Indexed Database ---------------------------------------------------- |
|
133 |
|
134 virtual WebIndexedDatabase* indexedDatabase() { return 0; } |
|
135 |
|
136 |
|
137 // Keygen -------------------------------------------------------------- |
|
138 |
|
139 // Handle the <keygen> tag for generating client certificates |
|
140 // Returns a base64 encoded signed copy of a public key from a newly |
|
141 // generated key pair and the supplied challenge string. keySizeindex |
|
142 // specifies the strength of the key. |
|
143 virtual WebString signedPublicKeyAndChallengeString(unsigned keySizeIndex, |
|
144 const WebKit::WebString& challenge, |
|
145 const WebKit::WebURL& url) { return WebString(); } |
|
146 |
|
147 |
|
148 |
|
149 // Memory -------------------------------------------------------------- |
|
150 |
|
151 // Returns the current space allocated for the pagefile, in MB. |
|
152 // That is committed size for Windows and virtual memory size for POSIX |
|
153 virtual size_t memoryUsageMB() { return 0; } |
|
154 |
|
155 |
|
156 // Message Ports ------------------------------------------------------- |
|
157 |
|
158 // Creates a Message Port Channel. This can be called on any thread. |
|
159 // The returned object should only be used on the thread it was created on. |
|
160 virtual WebMessagePortChannel* createMessagePortChannel() { return 0; } |
|
161 |
|
162 |
|
163 // Network ------------------------------------------------------------- |
|
164 |
|
165 // A suggestion to prefetch IP information for the given hostname. |
|
166 virtual void prefetchHostName(const WebString&) { } |
|
167 |
|
168 // Returns a new WebURLLoader instance. |
|
169 virtual WebURLLoader* createURLLoader() { return 0; } |
|
170 |
|
171 // Returns a new WebSocketStreamHandle instance. |
|
172 virtual WebSocketStreamHandle* createSocketStreamHandle() { return 0; } |
|
173 |
|
174 // Returns the User-Agent string that should be used for the given URL. |
|
175 virtual WebString userAgent(const WebURL&) { return WebString(); } |
|
176 |
|
177 // A suggestion to cache this metadata in association with this URL. |
|
178 virtual void cacheMetadata(const WebURL&, double responseTime, const char* data, size_t dataSize) { } |
|
179 |
|
180 |
|
181 // Plugins ------------------------------------------------------------- |
|
182 |
|
183 // If refresh is true, then cached information should not be used to |
|
184 // satisfy this call. |
|
185 virtual void getPluginList(bool refresh, WebPluginListBuilder*) { } |
|
186 |
|
187 |
|
188 // Profiling ----------------------------------------------------------- |
|
189 |
|
190 virtual void decrementStatsCounter(const char* name) { } |
|
191 virtual void incrementStatsCounter(const char* name) { } |
|
192 |
|
193 // An event is identified by the pair (name, id). The extra parameter |
|
194 // specifies additional data to log with the event. |
|
195 virtual void traceEventBegin(const char* name, void* id, const char* extra) { } |
|
196 virtual void traceEventEnd(const char* name, void* id, const char* extra) { } |
|
197 |
|
198 // Generic callback for reporting histogram data. Range is identified by the min, max pair. |
|
199 // By default, histogram is exponential, so that min=1, max=1000000, bucketCount=50 would do. Setting |
|
200 // linear to true would require bucket count to cover whole min-max range. |
|
201 virtual void histogramCounts(const WebString& name, int sample, int min, int max, int bucketCount, bool linear) { } |
|
202 |
|
203 |
|
204 // Resources ----------------------------------------------------------- |
|
205 |
|
206 // Returns a blob of data corresponding to the named resource. |
|
207 virtual WebData loadResource(const char* name) { return WebData(); } |
|
208 |
|
209 // Returns a localized string resource (with an optional numeric |
|
210 // parameter value). |
|
211 virtual WebString queryLocalizedString(WebLocalizedString::Name) { return WebString(); } |
|
212 virtual WebString queryLocalizedString(WebLocalizedString::Name, int numericValue) { return WebString(); } |
|
213 |
|
214 |
|
215 // Sandbox ------------------------------------------------------------ |
|
216 |
|
217 // In some browsers, a "sandbox" restricts what operations a program |
|
218 // is allowed to preform. Such operations are typically abstracted out |
|
219 // via this API, but sometimes (like in HTML 5 database opening) WebKit |
|
220 // needs to behave differently based on whether it's restricted or not. |
|
221 // In these cases (and these cases only) you can call this function. |
|
222 // It's OK for this value to be conservitive (i.e. true even if the |
|
223 // sandbox isn't active). |
|
224 virtual bool sandboxEnabled() { return false; } |
|
225 |
|
226 |
|
227 // Shared Workers ------------------------------------------------------ |
|
228 |
|
229 virtual WebSharedWorkerRepository* sharedWorkerRepository() { return 0; } |
|
230 |
|
231 // Sudden Termination -------------------------------------------------- |
|
232 |
|
233 // Disable/Enable sudden termination. |
|
234 virtual void suddenTerminationChanged(bool enabled) { } |
|
235 |
|
236 |
|
237 // System -------------------------------------------------------------- |
|
238 |
|
239 // Returns a value such as "en-US". |
|
240 virtual WebString defaultLocale() { return WebString(); } |
|
241 |
|
242 // Wall clock time in seconds since the epoch. |
|
243 virtual double currentTime() { return 0; } |
|
244 |
|
245 // Delayed work is driven by a shared timer. |
|
246 virtual void setSharedTimerFiredFunction(void (*func)()) { } |
|
247 virtual void setSharedTimerFireTime(double fireTime) { } |
|
248 virtual void stopSharedTimer() { } |
|
249 |
|
250 // Callable from a background WebKit thread. |
|
251 virtual void callOnMainThread(void (*func)(void*), void* context) { } |
|
252 |
|
253 // WebGL -------------------------------------------------------------- |
|
254 |
|
255 // May return null if WebGL is not supported. |
|
256 // Returns newly allocated WebGraphicsContext3D instance. |
|
257 virtual WebGraphicsContext3D* createGraphicsContext3D() { return 0; } |
|
258 |
|
259 // GLES2 -------------------------------------------------------------- |
|
260 |
|
261 // Returns newly allocated WebGLES2Context instance. |
|
262 // May return null if it fails to create the context. |
|
263 virtual WebGLES2Context* createGLES2Context() { return 0; } |
|
264 |
|
265 protected: |
|
266 ~WebKitClient() { } |
|
267 }; |
|
268 |
|
269 } // namespace WebKit |
|
270 |
|
271 #endif |