[EFL] Fix a crash on MiniBrowser when running on debug mode
[WebKit-https.git] / Source / WebKit2 / UIProcess / efl / WebProcessPoolEfl.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 "WebProcessPool.h"
28
29 #include "APIProcessPoolConfiguration.h"
30 #include "Logging.h"
31 #include "WebCookieManagerProxy.h"
32 #include "WebInspectorServer.h"
33 #include "WebProcessCreationParameters.h"
34 #include "WebProcessMessages.h"
35 #include "WebSoupCustomProtocolRequestManager.h"
36 #include <Efreet.h>
37 #include <WebCore/ApplicationCacheStorage.h>
38 #include <WebCore/IconDatabase.h>
39 #include <WebCore/NotImplemented.h>
40
41 namespace WebKit {
42
43 static void initializeInspectorServer()
44 {
45 #if ENABLE(INSPECTOR_SERVER)
46     static bool initialized = false;
47     if (initialized)
48         return;
49
50     // It should be set to true always.
51     // Because it is to ensure initializeInspectorServer() is executed only once,
52     // even if the server fails to run.
53     initialized = true;
54
55     String serverAddress(getenv("WEBKIT_INSPECTOR_SERVER"));
56     if (!serverAddress.isNull()) {
57         String bindAddress = ASCIILiteral("127.0.0.1");
58         unsigned short port = 2999;
59
60         Vector<String> result;
61         serverAddress.split(':', result);
62
63         if (result.size() == 2) {
64             bindAddress = result[0];
65             bool ok = false;
66             port = result[1].toUInt(&ok);
67             if (!ok) {
68                 port = 2999;
69                 LOG_ERROR("Couldn't parse the port. Using 2999 instead.");
70             }
71         } else
72             LOG_ERROR("Couldn't parse %s, wrong format? Using 127.0.0.1:2999 instead.", serverAddress.utf8().data());
73
74         if (!WebInspectorServer::singleton().listen(bindAddress, port))
75             LOG_ERROR("Couldn't start listening on: IP address=%s, port=%d.", bindAddress.utf8().data(), port);
76
77         return;
78     }
79
80     LOG(InspectorServer, "To start inspector server set WEBKIT_INSPECTOR_SERVER to 127.0.0.1:2999 for example.");
81 #endif
82 }
83
84 String WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory()
85 {
86     return String::fromUTF8(efreet_cache_home_get()) + "/WebKitEfl/Applications";
87 }
88
89 void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
90 {
91     initializeInspectorServer();
92
93     parameters.urlSchemesRegisteredForCustomProtocols = supplement<WebSoupCustomProtocolRequestManager>()->registeredSchemesForCustomProtocols();
94     supplement<WebCookieManagerProxy>()->getCookiePersistentStorage(parameters.cookiePersistentStoragePath, parameters.cookiePersistentStorageType);
95     parameters.cookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
96     parameters.ignoreTLSErrors = m_ignoreTLSErrors;
97     parameters.diskCacheDirectory = m_configuration->diskCacheDirectory();
98 }
99
100 void WebProcessPool::platformInvalidateContext()
101 {
102     notImplemented();
103 }
104
105 String WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory()
106 {
107     return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/Databases";
108 }
109
110 String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
111 {
112     notImplemented();
113     return String();
114 }
115
116 String WebProcessPool::platformDefaultIconDatabasePath() const
117 {
118     return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/IconDatabase/" + WebCore::IconDatabase::defaultDatabaseFilename();
119 }
120
121 String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
122 {
123     return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/LocalStorage";
124 }
125
126 String WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory()
127 {
128     return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/MediaKeys";
129 }
130
131 String WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory()
132 {
133 #if ENABLE(NETWORK_CACHE)
134     static const char networkCacheSubdirectory[] = "WebKitCache";
135 #else
136     static const char networkCacheSubdirectory[] = "webkit";
137 #endif
138
139     StringBuilder diskCacheDirectory;
140     diskCacheDirectory.append(efreet_cache_home_get());
141     diskCacheDirectory.appendLiteral("/");
142     diskCacheDirectory.append(networkCacheSubdirectory);
143
144     return diskCacheDirectory.toString();
145 }
146
147 void WebProcessPool::setIgnoreTLSErrors(bool ignoreTLSErrors)
148 {
149     m_ignoreTLSErrors = ignoreTLSErrors;
150     sendToAllProcesses(Messages::WebProcess::SetIgnoreTLSErrors(m_ignoreTLSErrors));
151 }
152
153 } // namespace WebKit