[WTF] Rename String::format to String::deprecatedFormat
[WebKit-https.git] / Source / WebKit / UIProcess / gtk / WebProcessPoolGtk.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
4  * Copyright (C) 2012 Samsung Electronics Ltd. All Rights Reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS AS IS''
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
19  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25  * THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #include "config.h"
29 #include "WebProcessPool.h"
30
31 #include "APIProcessPoolConfiguration.h"
32 #include "Logging.h"
33 #include "WebCookieManagerProxy.h"
34 #include "WebProcessCreationParameters.h"
35 #include "WebProcessMessages.h"
36 #include <JavaScriptCore/RemoteInspectorServer.h>
37 #include <WebCore/FileSystem.h>
38 #include <WebCore/GStreamerCommon.h>
39 #include <WebCore/NotImplemented.h>
40 #include <WebCore/SchemeRegistry.h>
41 #include <wtf/glib/GUniquePtr.h>
42 #include <wtf/text/CString.h>
43
44 namespace WebKit {
45
46 #if ENABLE(REMOTE_INSPECTOR)
47 static bool initializeRemoteInspectorServer(const char* address)
48 {
49     if (Inspector::RemoteInspectorServer::singleton().isRunning())
50         return true;
51
52     if (!address[0])
53         return false;
54
55     GUniquePtr<char> inspectorAddress(g_strdup(address));
56     char* portPtr = g_strrstr(inspectorAddress.get(), ":");
57     if (!portPtr)
58         return false;
59
60     *portPtr = '\0';
61     portPtr++;
62     guint64 port = g_ascii_strtoull(portPtr, nullptr, 10);
63     if (!port)
64         return false;
65
66     return Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
67 }
68 #endif
69
70 void WebProcessPool::platformInitialize()
71 {
72 #if ENABLE(REMOTE_INSPECTOR)
73     if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER")) {
74         if (!initializeRemoteInspectorServer(address))
75             g_unsetenv("WEBKIT_INSPECTOR_SERVER");
76     }
77 #endif
78 }
79
80 WTF::String WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory()
81 {
82     return API::WebsiteDataStore::defaultApplicationCacheDirectory();
83 }
84
85 WTF::String WebProcessPool::legacyPlatformDefaultMediaCacheDirectory()
86 {
87     return API::WebsiteDataStore::defaultMediaCacheDirectory();
88 }
89
90 void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
91 {
92     parameters.memoryCacheDisabled = m_memoryCacheDisabled || cacheModel() == CacheModelDocumentViewer;
93     parameters.proxySettings = m_networkProxySettings;
94
95     parameters.shouldAlwaysUseComplexTextCodePath = true;
96     const char* forceComplexText = getenv("WEBKIT_FORCE_COMPLEX_TEXT");
97     if (forceComplexText && !strcmp(forceComplexText, "0"))
98         parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
99
100     const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR");
101     if (disableMemoryPressureMonitor && !strcmp(disableMemoryPressureMonitor, "1"))
102         parameters.shouldSuppressMemoryPressureHandler = true;
103
104 #if USE(GSTREAMER)
105     parameters.gstreamerOptions = WebCore::extractGStreamerOptionsFromCommandLine();
106 #endif
107 }
108
109 void WebProcessPool::platformInvalidateContext()
110 {
111 }
112
113 String WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory()
114 {
115     return API::WebsiteDataStore::defaultWebSQLDatabaseDirectory();
116 }
117
118 String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
119 {
120     return API::WebsiteDataStore::defaultIndexedDBDatabaseDirectory();
121 }
122
123 String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
124 {
125     return API::WebsiteDataStore::defaultLocalStorageDirectory();
126 }
127
128 String WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory()
129 {
130     return API::WebsiteDataStore::defaultMediaKeysStorageDirectory();
131 }
132
133 String WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory()
134 {
135     return API::WebsiteDataStore::defaultNetworkCacheDirectory();
136 }
137
138 String WebProcessPool::legacyPlatformDefaultJavaScriptConfigurationDirectory()
139 {
140     GUniquePtr<gchar> javaScriptCoreConfigDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "JavaScriptCoreDebug", nullptr));
141     return WebCore::FileSystem::stringFromFileSystemRepresentation(javaScriptCoreConfigDirectory.get());
142 }
143
144 void WebProcessPool::platformResolvePathsForSandboxExtensions()
145 {
146 }
147
148 } // namespace WebKit