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