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