2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "WebContext.h"
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>
38 String WebContext::applicationCacheDirectory()
40 #if ENABLE(TIZEN_APPLICATION_CACHE)
41 String applicationCacheDirectory = WebCore::cacheStorage().cacheDirectory();
42 if(applicationCacheDirectory.isEmpty()) {
43 applicationCacheDirectory = platformDefaultApplicationCacheDirectory();
45 return applicationCacheDirectory;
47 return WebCore::cacheStorage().cacheDirectory();
51 #if ENABLE(TIZEN_APPLICATION_CACHE)
52 void WebContext::setApplicationCacheDirectory(const String& directory)
54 WebCore::cacheStorage().setCacheDirectory(directory);
58 void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
60 #if ENABLE(TIZEN_WEBKIT2_PROXY)
61 parameters.proxyAddress = m_proxyAddress;
64 #if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
65 parameters.soupDataDirectory = soupDataDirectory();
68 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
69 parameters.certificateFile = m_certificateFile;
75 void WebContext::platformInvalidateContext()
80 #if ENABLE(TIZEN_APPLICATION_CACHE)
81 String WebContext::platformDefaultApplicationCacheDirectory() const
83 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/appcache");
87 String WebContext::platformDefaultDatabaseDirectory() const
89 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/databases");
92 String WebContext::platformDefaultIconDatabasePath() const
94 #if ENABLE(TIZEN_ICON_DATABASE)
95 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/iconDatabase/WebpageIcons.db");
97 return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/IconDatabase";
101 #if ENABLE(TIZEN_FILE_SYSTEM)
102 String WebContext::platformDefaultLocalFileSystemDirectory() const
104 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localFileSystem");
108 String WebContext::platformDefaultLocalStorageDirectory() const
110 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localStorage");
113 #if ENABLE(TIZEN_INDEXED_DATABASE)
114 String WebContext::platformDefaultIndexedDatabaseDirectory() const
116 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/indexedDatabases");
120 #if ENABLE(TIZEN_WEBKIT2_PROXY)
121 void WebContext::setProxy(const String& proxyAddress)
123 m_proxyAddress = proxyAddress;
124 sendToAllProcesses(Messages::WebProcess::SetProxy(proxyAddress));
128 #if ENABLE(TIZEN_SESSION_REQUEST_CANCEL)
129 void WebContext::abortSession()
131 process()->send(Messages::WebProcess::AbortSession(), 0);
135 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
136 void WebContext::setCertificateFile(const String& certificateFile)
138 m_certificateFile = certificateFile;
140 process()->send(Messages::WebProcess::SetCertificateFile(certificateFile), 0);
144 void WebContext::notifyLowMemory()
146 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
147 m_process->platformSurfaceTexturePool()->removeUnusedPlatformSurfaceTextures(m_process.get());
149 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
150 m_process->releaseBackingStoreMemory();
155 #if ENABLE(TIZEN_SOUP_COOKIE_CACHE_FOR_WEBKIT2)
156 String WebContext::soupDataDirectory()
158 if (!m_soupDataDirectory.isEmpty())
159 return m_soupDataDirectory;
161 return platformDefaultSoupDataDirectory();
163 String WebContext::platformDefaultSoupDataDirectory()
165 return WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/soupData");
169 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
170 void WebContext::setMemorySavingMode(bool memorySavingMode)
173 m_process->setMemorySavingMode(memorySavingMode);
175 sendToAllProcesses(Messages::WebProcess::SetMemorySavingMode(memorySavingMode));
179 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
180 void WebContext::setXWindow(unsigned xWindow)
182 sendToAllProcesses(Messages::WebProcess::SetXWindow(xWindow));
186 #if ENABLE(TIZEN_EXTENSIBLE_API)
187 void WebContext::setTizenExtensibleAPI(WebCore::ExtensibleAPI extensibleAPI, bool enable)
189 sendToAllProcesses(Messages::WebProcess::SetTizenExtensibleAPI(static_cast<uint32_t>(extensibleAPI), enable));
193 #if ENABLE(TIZEN_RESET_PATH)
194 void WebContext::resetStoragePath()
196 sendToAllProcesses(Messages::WebProcess::ResetStoragePath());
200 #if ENABLE(TIZEN_INDEXED_DATABASE)
201 void WebContext::deleteIndexedDatabaseAll()
203 sendToAllProcesses(Messages::WebProcess::DeleteIndexedDatabaseAll());
207 } // namespace WebKit