[WK2] Support multiple URLs for WebApp meta tag
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebProcess.h
1 /*
2  * Copyright (C) 2010 Apple 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
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef WebProcess_h
27 #define WebProcess_h
28
29 #include "CacheModel.h"
30 #include "ChildProcess.h"
31 #include "DrawingArea.h"
32 #include "EventDispatcher.h"
33 #include "PluginInfoStore.h"
34 #include "ResourceCachesToClear.h"
35 #include "SandboxExtension.h"
36 #include "SharedMemory.h"
37 #include "TextCheckerState.h"
38 #include "VisitedLinkTable.h"
39 #include "WebConnectionToUIProcess.h"
40 #include "WebGeolocationManager.h"
41 #include "WebIconDatabaseProxy.h"
42 #include "WebPageGroupProxy.h"
43 #include <WebCore/LinkHash.h>
44 #include <wtf/Forward.h>
45 #include <wtf/HashMap.h>
46 #include <wtf/HashSet.h>
47
48 #if USE(SOUP)
49 #include "WebSoupRequestManager.h"
50 #endif
51
52 #if PLATFORM(QT)
53 QT_BEGIN_NAMESPACE
54 class QNetworkAccessManager;
55 QT_END_NAMESPACE
56 #endif
57
58 #if PLATFORM(MAC)
59 #include <dispatch/dispatch.h>
60 #endif
61
62 #if ENABLE(BATTERY_STATUS)
63 #include "WebBatteryManager.h"
64 #endif
65
66 #if ENABLE(NETWORK_INFO)
67 #include "WebNetworkInfoManager.h"
68 #endif
69
70 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
71 #include "WebNotificationManager.h"
72 #endif
73
74 #if ENABLE(PLUGIN_PROCESS)
75 #include "PluginProcessConnectionManager.h"
76 #endif
77
78 namespace WebCore {
79     class IntSize;
80     class PageGroup;
81     class ResourceRequest;
82     class ResourceResponse;
83 }
84
85 namespace WebKit {
86
87 class InjectedBundle;
88 class WebFrame;
89 class WebPage;
90 struct WebPageCreationParameters;
91 struct WebPageGroupData;
92 struct WebPreferencesStore;
93 struct WebProcessCreationParameters;
94
95 #if USE(SECURITY_FRAMEWORK)
96 class SecItemResponseData;
97 class SecKeychainItemResponseData;
98 #endif
99
100 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
101 class PlatformSurfacePoolEfl;
102 #endif
103
104 class WebProcess : public ChildProcess, private CoreIPC::Connection::QueueClient {
105 public:
106     static WebProcess& shared();
107
108     void initialize(CoreIPC::Connection::Identifier, WebCore::RunLoop*);
109
110     CoreIPC::Connection* connection() const { return m_connection->connection(); }
111     WebCore::RunLoop* runLoop() const { return m_runLoop; }
112
113     WebConnectionToUIProcess* webConnectionToUIProcess() const { return m_connection.get(); }
114
115     WebPage* webPage(uint64_t pageID) const;
116     void createWebPage(uint64_t pageID, const WebPageCreationParameters&);
117     void removeWebPage(uint64_t pageID);
118     WebPage* focusedWebPage() const;
119     
120     InjectedBundle* injectedBundle() const { return m_injectedBundle.get(); }
121
122     bool isSeparateProcess() const;
123
124 #if PLATFORM(MAC)
125     void initializeShim();
126
127 #if USE(ACCELERATED_COMPOSITING)
128     mach_port_t compositingRenderServerPort() const { return m_compositingRenderServerPort; }
129 #endif
130 #endif
131     
132     void setShouldTrackVisitedLinks(bool);
133     void addVisitedLink(WebCore::LinkHash);
134     bool isLinkVisited(WebCore::LinkHash) const;
135
136     bool fullKeyboardAccessEnabled() const { return m_fullKeyboardAccessEnabled; }
137
138     WebFrame* webFrame(uint64_t) const;
139     void addWebFrame(uint64_t, WebFrame*);
140     void removeWebFrame(uint64_t);
141
142     WebPageGroupProxy* webPageGroup(uint64_t pageGroupID);
143     WebPageGroupProxy* webPageGroup(const WebPageGroupData&);
144 #if PLATFORM(MAC)
145     pid_t presenterApplicationPid() const { return m_presenterApplicationPid; }
146 #endif 
147     
148 #if PLATFORM(QT)
149     QNetworkAccessManager* networkAccessManager() { return m_networkAccessManager; }
150 #endif
151
152     bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&) const;
153
154     // Text Checking
155     const TextCheckerState& textCheckerState() const { return m_textCheckerState; }
156
157     // Geolocation
158     WebGeolocationManager& geolocationManager() { return m_geolocationManager; }
159
160 #if ENABLE(BATTERY_STATUS)
161     WebBatteryManager& batteryManager() { return m_batteryManager; }
162 #endif
163
164 #if ENABLE(NETWORK_INFO)
165     WebNetworkInfoManager& networkInfoManager() { return m_networkInfoManager; }
166 #endif
167     
168 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
169     WebNotificationManager& notificationManager() { return m_notificationManager; }
170 #endif
171
172     void clearResourceCaches(ResourceCachesToClear = AllResourceCaches);
173 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
174     void dumpResourceCaches();
175     void platformDumpResourceCaches();
176 #endif
177     
178     const String& localStorageDirectory() const { return m_localStorageDirectory; }
179
180 #if ENABLE(PLUGIN_PROCESS)
181     PluginProcessConnectionManager& pluginProcessConnectionManager() { return m_pluginProcessConnectionManager; }
182     bool disablePluginProcessMessageTimeout() const { return m_disablePluginProcessMessageTimeout; }
183 #endif
184
185     EventDispatcher& eventDispatcher() { return m_eventDispatcher; }
186
187 #if USE(SOUP)
188     WebSoupRequestManager& soupRequestManager() { return m_soupRequestManager; }
189 #endif
190
191 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
192     WorkQueue* paintThreadWorkQueue() const { return m_paintThreadWorkQueue; }
193 #endif
194
195 #if ENABLE(TIZEN_WEBKIT2_PROXY)
196     void setProxy(const String& proxyAddress);
197 #endif
198 #if ENABLE(TIZEN_SESSION_REQUEST_CANCEL)
199     void abortSession();
200 #endif
201
202 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
203     void setCertificateFile(const String&);
204 #endif
205
206 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
207     PlatformSurfacePoolEfl* platformSurfacePool() { return m_platformSurfacePool.get(); }
208     void removePlatformSurfaceFromPool(int platformSurfaceId);
209 #endif
210
211 #if ENABLE(TIZEN_INDEXED_DATABASE)
212     const String& indexedDatabaseDirectory() const { return m_indexedDatabaseDirectory; }
213 #endif
214
215 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
216     class WaitForJavaScriptPopupFinished {
217     public:
218         WaitForJavaScriptPopupFinished(); 
219         ~WaitForJavaScriptPopupFinished(); 
220     };
221     bool isWaitingForJavaScriptPopupFinished();
222 #endif
223
224 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
225     void setMemorySavingMode(bool);
226     bool memorySavingModeEnabled() { return m_memorySavingModeEnabled; }
227 #endif
228
229 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
230     void setXWindow(unsigned);
231 #endif
232
233 #if ENABLE(TIZEN_EXTENSIBLE_API)
234     void setTizenExtensibleAPI(int extensibleAPI, bool enable);
235 #endif
236
237 #if ENABLE(TIZEN_RESET_PATH)
238     void resetStoragePath();
239 #endif
240
241 private:
242     WebProcess();
243
244     void initializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*);
245     void platformInitializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*);
246     void platformTerminate();
247     void registerURLSchemeAsEmptyDocument(const String&);
248     void registerURLSchemeAsSecure(const String&) const;
249     void setDomainRelaxationForbiddenForURLScheme(const String&) const;
250     void setDefaultRequestTimeoutInterval(double);
251     void setAlwaysUsesComplexTextCodePath(bool);
252     void setShouldUseFontSmoothing(bool);
253     void userPreferredLanguagesChanged(const Vector<String>&) const;
254     void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
255 #if PLATFORM(WIN)
256     void setShouldPaintNativeControls(bool);
257 #endif
258
259     void setVisitedLinkTable(const SharedMemory::Handle&);
260     void visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes);
261     void allVisitedLinkStateChanged();
262
263     void setCacheModel(uint32_t);
264     void platformSetCacheModel(CacheModel);
265 #if ENABLE(TIZEN_CACHE_CONTROL)
266     void setCacheDisabled(bool);
267     void platformSetCacheDisabled(bool);
268 #endif
269     static void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
270         unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
271         unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity);
272     void platformClearResourceCaches(ResourceCachesToClear);
273     void clearApplicationCache();
274
275     void setEnhancedAccessibility(bool);
276     
277 #if !ENABLE(PLUGIN_PROCESS)
278     void getSitesWithPluginData(const Vector<String>& pluginPaths, uint64_t callbackID);
279     void clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
280 #endif
281     
282 #if ENABLE(PLUGIN_PROCESS)
283     void pluginProcessCrashed(CoreIPC::Connection*, const String& pluginPath);
284 #endif
285
286     void startMemorySampler(const SandboxExtension::Handle&, const String&, const double);
287     void stopMemorySampler();
288
289     void downloadRequest(uint64_t downloadID, uint64_t initiatingPageID, const WebCore::ResourceRequest&);
290     void cancelDownload(uint64_t downloadID);
291 #if PLATFORM(QT)
292     void startTransfer(uint64_t downloadID, const String& destination);
293 #endif
294
295     void setTextCheckerState(const TextCheckerState&);
296     
297     void getWebCoreStatistics(uint64_t callbackID);
298     void garbageCollectJavaScriptObjects();
299     void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
300
301 #if USE(SECURITY_FRAMEWORK)
302     void secItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecItemResponseData&);
303     void secKeychainItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecKeychainItemResponseData&);
304 #endif
305
306     // ChildProcess
307     virtual bool shouldTerminate();
308     virtual void terminate();
309
310     // CoreIPC::Connection::Client
311     friend class WebConnectionToUIProcess;
312     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
313     virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
314     virtual void didClose(CoreIPC::Connection*);
315     virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
316     virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
317 #if PLATFORM(WIN)
318     virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply();
319 #endif
320
321     // CoreIPC::Connection::QueueClient
322     virtual void didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage) OVERRIDE;
323
324     // Implemented in generated WebProcessMessageReceiver.cpp
325     void didReceiveWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
326     void didReceiveWebProcessMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage);
327
328     void didGetPlugins(CoreIPC::Connection*, uint64_t requestID, const Vector<WebCore::PluginInfo>&);
329
330     RefPtr<WebConnectionToUIProcess> m_connection;
331
332     HashMap<uint64_t, RefPtr<WebPage> > m_pageMap;
333     HashMap<uint64_t, RefPtr<WebPageGroupProxy> > m_pageGroupMap;
334     RefPtr<InjectedBundle> m_injectedBundle;
335
336     EventDispatcher m_eventDispatcher;
337
338     bool m_inDidClose;
339
340     WebCore::RunLoop* m_runLoop;
341
342     // FIXME: The visited link table should not be per process.
343     VisitedLinkTable m_visitedLinkTable;
344     bool m_shouldTrackVisitedLinks;
345
346     bool m_hasSetCacheModel;
347     CacheModel m_cacheModel;
348
349 #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
350     mach_port_t m_compositingRenderServerPort;
351 #endif
352 #if PLATFORM(MAC)
353     pid_t m_presenterApplicationPid;
354     dispatch_group_t m_clearResourceCachesDispatchGroup;
355 #endif
356
357     bool m_fullKeyboardAccessEnabled;
358
359 #if PLATFORM(QT)
360     QNetworkAccessManager* m_networkAccessManager;
361 #endif
362
363 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
364     WorkQueue* m_paintThreadWorkQueue;
365 #endif
366     HashMap<uint64_t, WebFrame*> m_frameMap;
367
368     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
369
370     TextCheckerState m_textCheckerState;
371     WebGeolocationManager m_geolocationManager;
372 #if ENABLE(BATTERY_STATUS)
373     WebBatteryManager m_batteryManager;
374 #endif
375 #if ENABLE(NETWORK_INFO)
376     WebNetworkInfoManager m_networkInfoManager;
377 #endif
378 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
379     WebNotificationManager m_notificationManager;
380 #endif
381     WebIconDatabaseProxy m_iconDatabaseProxy;
382     
383     String m_localStorageDirectory;
384
385     RefPtr<SandboxExtension> m_applicationCachePathExtension;
386
387 #if ENABLE(PLUGIN_PROCESS)
388     PluginProcessConnectionManager m_pluginProcessConnectionManager;
389     bool m_disablePluginProcessMessageTimeout;
390 #endif
391 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
392     OwnPtr<PlatformSurfacePoolEfl> m_platformSurfacePool;
393 #endif
394
395 #if ENABLE(TIZEN_INDEXED_DATABASE)
396     String m_indexedDatabaseDirectory;
397 #endif
398
399 #if USE(SOUP)
400     WebSoupRequestManager m_soupRequestManager;
401 #endif
402
403 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
404     int m_isWaitingForJavaScriptPopupCount;
405 #endif
406
407 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
408     bool m_memorySavingModeEnabled;
409 #endif
410 };
411
412 } // namespace WebKit
413
414 #endif // WebProcess_h