4ec09297d2a72c091158884c58514dcf30a1d7be
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / efl / WebContextEfl.cpp
1 /*
2  * Copyright (C) 2011 Samsung Electronics
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 #include "config.h"
27 #include "WebContext.h"
28
29 #include "FileSystem.h"
30 #include "MessageID.h"
31 #include "WebProcessMessages.h"
32 #include "WebProcessCreationParameters.h"
33 #include <WebCore/ApplicationCacheStorage.h>
34 #include <WebCore/NotImplemented.h>
35
36 namespace WebKit {
37
38 String WebContext::applicationCacheDirectory()
39 {
40 #if ENABLE(TIZEN_APPLICATION_CACHE)
41     String applicationCacheDirectory = WebCore::cacheStorage().cacheDirectory();
42     if(applicationCacheDirectory.isEmpty()) {
43         applicationCacheDirectory = platformDefaultApplicationCacheDirectory();
44     }
45     return applicationCacheDirectory;
46 #else
47     return WebCore::cacheStorage().cacheDirectory();
48 #endif
49 }
50
51 #if ENABLE(TIZEN_APPLICATION_CACHE)
52 void WebContext::setApplicationCacheDirectory(const String& directory)
53 {
54     WebCore::cacheStorage().setCacheDirectory(directory);
55 }
56 #endif
57
58 void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
59 {
60 #if ENABLE(TIZEN_WEBKIT2_PROXY)
61     parameters.proxyAddress = m_proxyAddress;
62 #endif
63
64 #if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
65     parameters.soupDataDirectory = soupDataDirectory();
66 #endif
67
68 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
69     parameters.certificateFile = m_certificateFile;
70 #endif
71
72     notImplemented();
73 }
74
75 void WebContext::platformInvalidateContext()
76 {
77     notImplemented();
78 }
79
80 #if ENABLE(TIZEN_APPLICATION_CACHE)
81 String WebContext::platformDefaultApplicationCacheDirectory() const
82 {
83     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/appcache");
84 }
85 #endif
86
87 String WebContext::platformDefaultDatabaseDirectory() const
88 {
89     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/databases");
90 }
91
92 String WebContext::platformDefaultIconDatabasePath() const
93 {
94 #if ENABLE(TIZEN_ICON_DATABASE)
95     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/iconDatabase/WebpageIcons.db");
96 #else
97     return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/IconDatabase";
98 #endif
99 }
100
101 #if ENABLE(TIZEN_FILE_SYSTEM)
102 String WebContext::platformDefaultLocalFileSystemDirectory() const
103 {
104     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localFileSystem");
105 }
106 #endif
107
108 String WebContext::platformDefaultLocalStorageDirectory() const
109 {
110     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localStorage");
111 }
112
113 #if ENABLE(TIZEN_INDEXED_DATABASE)
114 String WebContext::platformDefaultIndexedDatabaseDirectory() const
115 {
116     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/indexedDatabases");
117 }
118 #endif
119
120 #if ENABLE(TIZEN_WEBKIT2_PROXY)
121 void WebContext::setProxy(const String& proxyAddress)
122 {
123     m_proxyAddress = proxyAddress;
124     sendToAllProcesses(Messages::WebProcess::SetProxy(proxyAddress));
125 }
126 #endif
127
128 #if ENABLE(TIZEN_SESSION_REQUEST_CANCEL)
129 void WebContext::abortSession()
130 {
131     process()->send(Messages::WebProcess::AbortSession(), 0);
132 }
133 #endif
134
135 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
136 void WebContext::setCertificateFile(const String& certificateFile)
137 {
138     m_certificateFile = certificateFile;
139     if(process())
140         process()->send(Messages::WebProcess::SetCertificateFile(certificateFile), 0);
141 }
142 #endif
143
144 void WebContext::notifyLowMemory()
145 {
146 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
147     m_process->platformSurfaceTexturePool()->removeUnusedPlatformSurfaceTextures(m_process.get());
148 #else
149 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
150     m_process->releaseBackingStoreMemory();
151 #endif
152 #endif
153 }
154
155 #if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
156 String WebContext::soupDataDirectory()
157 {
158     if (!m_soupDataDirectory.isEmpty())
159         return m_soupDataDirectory;
160
161     return platformDefaultSoupDataDirectory();
162 }
163 String WebContext::platformDefaultSoupDataDirectory()
164 {
165     return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/soupData");
166 }
167 #endif
168
169 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
170 void WebContext::setMemorySavingMode(bool memorySavingMode)
171 {
172     //UI Process
173     m_process->setMemorySavingMode(memorySavingMode);
174     //Web Process
175     sendToAllProcesses(Messages::WebProcess::SetMemorySavingMode(memorySavingMode));
176 }
177 #endif
178
179 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
180 void WebContext::setXWindow(unsigned xWindow)
181 {
182     sendToAllProcesses(Messages::WebProcess::SetXWindow(xWindow));
183 }
184 #endif
185
186 #if ENABLE(TIZEN_EXTENSIBLE_API)
187 void WebContext::setTizenExtensibleAPI(WebCore::ExtensibleAPI extensibleAPI, bool enable)
188 {
189     sendToAllProcesses(Messages::WebProcess::SetTizenExtensibleAPI(static_cast<uint32_t>(extensibleAPI), enable));
190 }
191 #endif
192
193 #if ENABLE(TIZEN_RESET_PATH)
194 void WebContext::resetStoragePath()
195 {
196     sendToAllProcesses(Messages::WebProcess::ResetStoragePath());
197 }
198 #endif
199
200 #if ENABLE(TIZEN_INDEXED_DATABASE)
201 void WebContext::deleteIndexedDatabaseAll()
202 {
203     sendToAllProcesses(Messages::WebProcess::DeleteIndexedDatabaseAll());
204 }
205 #endif
206
207 } // namespace WebKit