2 * Copyright (C) 2009-2010 ProFUSION embedded systems
3 * Copyright (C) 2009-2016 Samsung Electronics. All rights reserved.
4 * Copyright (C) 2012 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "ewk_main_internal.h"
24 #include <Ecore_Evas.h>
25 #include <Ecore_IMF.h>
30 #include "command_line_efl.h"
31 #include "eweb_context.h"
32 #include "ewk_global_data.h"
33 #include "ewk_log_internal.h"
35 #include "private/webview_delegate_ewk.h"
36 #include "private/ewk_context_private.h"
37 #include "private/ewk_private.h"
38 #include "private/ewk_main_private.h"
40 #include "ecore_x_wayland_wrapper.h"
42 static int _ewkInitCount = 0;
44 /////////////////////////////////////////////////////////////////////////////
45 //private function declaration here
46 static void _ewk_init_web_engine(void);
47 static void _ewk_shutdown_web_engine(void);
48 static void _ewk_force_acceleration() __attribute__((constructor));
50 extern std::string g_homeDirectory;
54 * @brief the log domain identifier that is used with EINA's macros
56 int _ewk_log_dom = -1;
57 #if defined(USE_WAYLAND) && TIZEN_VERSION_AT_LEAST(5, 0, 0)
58 Ecore_Wl2_Display* _ecore_wl2_display = NULL;
64 return ++_ewkInitCount;
67 ERR("could not init eina.");
71 _ewk_log_dom = eina_log_domain_register("ewebview-blink", EINA_COLOR_ORANGE);
72 if (_ewk_log_dom < 0) {
73 EINA_LOG_ERR("could not register log domain 'ewebview-blink'");
74 goto error_log_domain;
78 ERR("could not init evas.");
83 ERR("could not init ecore.");
87 if (!ecore_evas_init()) {
88 ERR("could not init ecore_evas.");
89 goto error_ecore_evas;
92 if (!ecore_imf_init()) {
93 ERR("could not init ecore_imf.");
97 #if defined(USE_WAYLAND)
98 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
99 if (!ecore_wl2_init()) {
101 if (!ecore_wl_init(0)) {
102 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
103 ERR("could not init ecore_wl.");
106 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
107 if (!_ecore_wl2_display)
108 _ecore_wl2_display = ecore_wl2_display_connect(NULL);
109 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
111 if (!ecore_x_init(0)) {
112 ERR("could not init ecore_x.");
118 ERR("Could not init edje.");
122 _ewk_init_web_engine();
123 return ++_ewkInitCount;
126 #if defined(USE_WAYLAND)
127 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
128 if (_ecore_wl2_display) {
129 ecore_wl2_display_disconnect(_ecore_wl2_display);
130 _ecore_wl2_display = NULL;
131 ecore_wl2_shutdown();
135 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
141 ecore_imf_shutdown();
143 ecore_evas_shutdown();
149 eina_log_domain_unregister(_ewk_log_dom);
157 int ewk_shutdown(void)
159 if (!_ewkInitCount || --_ewkInitCount)
160 return _ewkInitCount;
162 _ewk_shutdown_web_engine();
165 #if defined(USE_WAYLAND)
166 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
167 if (_ecore_wl2_display) {
168 ecore_wl2_display_disconnect(_ecore_wl2_display);
169 _ecore_wl2_display = NULL;
170 ecore_wl2_shutdown();
174 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
178 ecore_imf_shutdown();
179 ecore_evas_shutdown();
182 eina_log_domain_unregister(_ewk_log_dom);
189 void ewk_set_arguments(int argc, char** argv)
191 CommandLineEfl::Init(argc, argv);
194 void ewk_process_model_set(Ewk_Process_Model process_model)
196 LOG_EWK_API_MOCKUP();
199 void ewk_memory_optimization_mode_enable(void)
201 LOG_EWK_API_MOCKUP();
204 void ewk_home_directory_set(const char* path)
207 g_homeDirectory.clear();
209 g_homeDirectory = path;
212 /////////////////////////////////////////////////////////////////////////////////////////////
213 //Private functions implementations for ewk_main module
215 //Initialize web engine
216 void _ewk_init_web_engine()
220 void _ewk_shutdown_web_engine(void)
222 //TODO: any web engine destroy to be done here
223 CommandLineEfl::Shutdown();
224 Ewk_Context::DefaultContextRelease();
225 EwkGlobalData::Delete();
228 void _ewk_force_acceleration()
230 // Chromium-efl port does not support s/w mode. So we need to set h/w mode
231 // before creating elm_window. To do this, make constructor function which is
232 // called at library loading time and set "ELM_ACCEL=hw" here. If not, native
233 // app which does not call elm_config_accel_preference_set() function will
235 setenv("ELM_ACCEL", "hw", 1);