2 * Copyright (C) 2009-2010 ProFUSION embedded systems
3 * Copyright (C) 2009-2013 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 Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 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 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include <Ecore_Evas.h>
27 #include <Ecore_IMF.h>
32 #if defined(HAVE_ECORE_X)
36 #include "public/ewk_log.h"
37 #include "public/ewk_view.h"
38 #include "private/webview_delegate_ewk.h"
39 #include "private/ewk_private.h"
40 #include "private/ewk_main_private.h"
42 // TODO: remove dependency
43 #include <../impl/command_line_efl.h>
44 #include <../impl/eweb_context.h>
45 #include <../impl/ewk_global_data.h>
47 static int _ewkInitCount = 0;
49 /////////////////////////////////////////////////////////////////////////////
50 //private function declaration here
51 static void _ewk_init_web_engine(void);
52 static void _ewk_shutdown_web_engine(void);
54 extern std::string g_homeDirectory;
58 * @brief the log domain identifier that is used with EINA's macros
60 int _ewk_log_dom = -1;
65 return ++_ewkInitCount;
70 _ewk_log_dom = eina_log_domain_register("ewebview-blink", EINA_COLOR_ORANGE);
71 if (_ewk_log_dom < 0) {
72 EINA_LOG_CRIT("could not register log domain 'ewebview-blink'");
73 goto error_log_domain;
77 CRITICAL("could not init evas.");
82 CRITICAL("could not init ecore.");
86 if (!ecore_evas_init()) {
87 CRITICAL("could not init ecore_evas.");
88 goto error_ecore_evas;
91 if (!ecore_imf_init()) {
92 CRITICAL("could not init ecore_imf.");
96 #if defined(HAVE_ECORE_X)
97 if (!ecore_x_init(0)) {
98 CRITICAL("could not init ecore_x.");
104 CRITICAL("Could not init edje.");
108 // FIXME: do we need glib integration like WebKit?
110 #if !GLIB_CHECK_VERSION(2, 35, 0)
114 if (!ecore_main_loop_glib_integrate()) {
115 WARN("Ecore was not compiled with GLib support, some plugins will not "
116 "work (ie: Adobe Flash)");
120 _ewk_init_web_engine();
121 return ++_ewkInitCount;
124 #if defined(HAVE_ECORE_X)
128 ecore_imf_shutdown();
130 ecore_evas_shutdown();
136 eina_log_domain_unregister(_ewk_log_dom);
144 int ewk_shutdown(void)
146 if (!_ewkInitCount || --_ewkInitCount)
147 return _ewkInitCount;
149 _ewk_shutdown_web_engine();
152 #if defined(HAVE_ECORE_X)
155 ecore_imf_shutdown();
156 ecore_evas_shutdown();
159 eina_log_domain_unregister(_ewk_log_dom);
166 void ewk_set_arguments(int argc, char** argv)
168 CommandLineEfl::Init(argc, argv);
171 void ewk_home_directory_set(const char* path)
174 g_homeDirectory.clear();
176 g_homeDirectory = path;
179 /////////////////////////////////////////////////////////////////////////////////////////////
180 //Private functions implementations for ewk_main module
182 //Initialize web engine
183 void _ewk_init_web_engine()
185 if(!WebViewDelegate::IsDelegateRegistered()) {
186 WebViewDelegate::RegisterDelegate(
187 const_cast<WebViewDelegateEwk*>(&WebViewDelegateEwk::GetInstance()));
191 void _ewk_shutdown_web_engine(void)
193 //TODO: any web engine destroy to be done here
194 CommandLineEfl::Shutdown();
195 ewk_context_delete(ewk_context_default_get());
196 EwkGlobalData::Delete();