Revert "Validate smack label of forked/executed WebProcess and PluginProcess"
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / efl / WebProcessMainEfl.cpp
1 /*
2  * Copyright (C) 2011 Samsung Electronics. All rights reserved.
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 "WebProcessMainEfl.h"
28
29 #include "ProxyResolverSoup.h"
30 #include "WKBase.h"
31 #include <Ecore.h>
32 #include <Ecore_File.h>
33 #include <WebCore/ResourceHandle.h>
34 #include <WebCore/RunLoop.h>
35 #include <WebKit2/WebProcess.h>
36 #include <runtime/InitializeThreading.h>
37 #include <unistd.h>
38 #include <wtf/MainThread.h>
39
40 #ifdef HAVE_ECORE_X
41 #include <Ecore_X.h>
42 #endif
43
44 #if USE(ACCELERATED_COMPOSITING)
45 #include "WebGraphicsLayer.h"
46 #endif
47
48 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
49 #include "WebPage.h"
50 #endif
51
52 #if ENABLE(TIZEN_USE_STACKPOINTER_AT_WEBPROCESS_STARTUP)
53 #include "wtf/WTFThreadData.h"
54 #endif
55
56 using namespace WebCore;
57
58 namespace WebKit {
59
60 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
61 void webkit_memory_dump_cb(void* data, Ecore_File_Monitor* monitor, Ecore_File_Event event, const char* path)
62 {
63     if (event == ECORE_FILE_EVENT_MODIFIED)
64         dumpMemorySnapshot();
65 }
66 #endif
67
68 WK_EXPORT int WebProcessMainEfl(int argc, char* argv[])
69 {
70     // WebProcess should be launched with an option.
71     if (argc != 2)
72         return 1;
73
74     if (!eina_init())
75         return 1;
76
77     if (!ecore_init()) {
78         // Could not init ecore.
79         eina_shutdown();
80         return 1;
81     }
82
83     if (!ecore_x_init(0)) {
84         // Could not init ecore_x.
85         // PlatformScreenEfl and systemBeep() functions
86         // depend on ecore_x functionality.
87         ecore_shutdown();
88         eina_shutdown();
89         return 1;
90     }
91
92     if (!ecore_file_init()) {
93         ecore_x_shutdown();
94         ecore_shutdown();
95         eina_shutdown();
96         return 1;
97     }
98
99 #if ENABLE(TIZEN_USE_STACKPOINTER_AT_WEBPROCESS_STARTUP)
100     void* dummy;
101     wtfThreadData().setJsStackOrigin(&dummy);
102 #endif
103
104 #if ENABLE(GLIB_SUPPORT)
105     g_type_init();
106
107     if (!ecore_main_loop_glib_integrate())
108         return 1;
109 #endif
110
111     JSC::initializeThreading();
112     WTF::initializeMainThread();
113
114     RunLoop::initializeMainRunLoop();
115
116     SoupSession* session = WebCore::ResourceHandle::defaultSession();
117     const char* httpProxy = getenv("http_proxy");
118     if (httpProxy) {
119         const char* noProxy = getenv("no_proxy");
120         SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(httpProxy, noProxy);
121         soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl));
122         g_object_unref(resolverEfl);
123     }
124
125 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
126     const char* isMemorySnapshot = getenv("TIZEN_MEMORY_SNAPSHOT");
127     if (isMemorySnapshot && isMemorySnapshot[0] != '0')
128         ecore_file_monitor_add("/tmp/webkit_memory_dump", webkit_memory_dump_cb, NULL);
129 #endif
130
131 #if USE(ACCELERATED_COMPOSITING)
132     WebCore::WebGraphicsLayer::initFactory();
133 #endif
134
135     int socket = atoi(argv[1]);
136     WebProcess::shared().initialize(socket, RunLoop::main());
137     RunLoop::run();
138
139     ecore_file_shutdown();
140     ecore_x_shutdown();
141     ecore_shutdown();
142     eina_shutdown();
143
144     return 0;
145
146 }
147
148 } // namespace WebKit