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 "private/webview_delegate_ewk.h"
38 #include "private/ewk_private.h"
39 #include "private/ewk_main_private.h"
41 // TODO: remove dependency
42 #include <../impl/command_line_efl.h>
43 #include <../impl/eweb_context.h>
44 #include <../impl/ewk_global_data.h>
46 static int _ewkInitCount = 0;
48 /////////////////////////////////////////////////////////////////////////////
49 //private function declaration here
50 static void _ewk_init_web_engine(void);
51 static void _ewk_shutdown_web_engine(void);
53 extern std::string g_homeDirectory;
57 * @brief the log domain identifier that is used with EINA's macros
59 int _ewk_log_dom = -1;
64 return ++_ewkInitCount;
69 _ewk_log_dom = eina_log_domain_register("ewebview-blink", EINA_COLOR_ORANGE);
70 if (_ewk_log_dom < 0) {
71 EINA_LOG_CRIT("could not register log domain 'ewebview-blink'");
72 goto error_log_domain;
76 CRITICAL("could not init evas.");
81 CRITICAL("could not init ecore.");
85 if (!ecore_evas_init()) {
86 CRITICAL("could not init ecore_evas.");
87 goto error_ecore_evas;
90 if (!ecore_imf_init()) {
91 CRITICAL("could not init ecore_imf.");
95 #if defined(HAVE_ECORE_X)
96 if (!ecore_x_init(0)) {
97 CRITICAL("could not init ecore_x.");
103 CRITICAL("Could not init edje.");
107 // FIXME: do we need glib integration like WebKit?
109 #if !GLIB_CHECK_VERSION(2, 35, 0)
113 if (!ecore_main_loop_glib_integrate()) {
114 WARN("Ecore was not compiled with GLib support, some plugins will not "
115 "work (ie: Adobe Flash)");
119 _ewk_init_web_engine();
120 return ++_ewkInitCount;
123 #if defined(HAVE_ECORE_X)
127 ecore_imf_shutdown();
129 ecore_evas_shutdown();
135 eina_log_domain_unregister(_ewk_log_dom);
143 int ewk_shutdown(void)
145 if (!_ewkInitCount || --_ewkInitCount)
146 return _ewkInitCount;
148 _ewk_shutdown_web_engine();
151 #if defined(HAVE_ECORE_X)
154 ecore_imf_shutdown();
155 ecore_evas_shutdown();
158 eina_log_domain_unregister(_ewk_log_dom);
165 void ewk_set_arguments(int argc, char** argv)
167 CommandLineEfl::Init(argc, argv);
170 void ewk_home_directory_set(const char* path)
173 g_homeDirectory.clear();
175 g_homeDirectory = path;
178 /////////////////////////////////////////////////////////////////////////////////////////////
179 //Private functions implementations for ewk_main module
181 //Initialize web engine
182 void _ewk_init_web_engine()
184 if(!WebViewDelegate::IsDelegateRegistered()) {
185 WebViewDelegate::RegisterDelegate(
186 const_cast<WebViewDelegateEwk*>(&WebViewDelegateEwk::GetInstance()));
190 void _ewk_shutdown_web_engine(void)
192 //TODO: any web engine destroy to be done here
193 CommandLineEfl::Shutdown();
194 EwkGlobalData::Delete();