2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file plugin_initializer.cpp
19 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
24 #include <dpl/log/log.h>
26 #include <Commons/plugin_initializer_def.h>
27 #include <Commons/WrtAccess/WrtAccess.h>
28 #include <js-overlay/js_overlay_addEventListener.h>
29 #include <js-overlay/js_iframe_support.h>
32 #include "JSPreferences.h"
34 #include "plugin_config.h"
36 #define OBJECT_WIDGET "widget"
37 #define INTERFACE_WIDGET_NAME "Widget"
38 #define OBJECT_PREFERENCES "preferences"
40 using namespace WrtPlugins::W3C;
41 using namespace WrtDeviceApis;
42 using namespace WrtDeviceApis::Commons;
46 class_definition_options_t WidgetOptions =
51 USE_OVERLAYED, //ignored
52 IFrameSupport::RegisterWidget,
57 class_definition_options_t WidgetInterfaceOptions =
62 USE_OVERLAYED, //ignored
63 JSWidget::acquireGlobalContext,
70 void on_widget_init_callback(feature_mapping_interface_t *mapping)
72 LogDebug("[W3C\\widget] on_widget_init_callback");
74 WrtPlugins::W3C::WidgetDeclarations::getMappingInterface(mapping);
77 void on_widget_start_callback(int widgetId)
79 LogDebug("[W3C\\widget] on_widget_start_callback (" << widgetId << ")");
83 WrtAccessSingleton::Instance().initialize(widgetId);
85 Catch (Commons::Exception)
87 LogError("Wrt wrapper registration failed");
92 void on_widget_stop_callback(int widgetId)
94 LogDebug("[W3C\\widget] on_widget_stop_callback (" << widgetId << ")");
97 WrtAccessSingleton::Instance().deinitialize(widgetId);
99 Catch (Commons::Exception)
101 LogError("Wrt wrapper registration failed");
107 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
108 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
109 PLUGIN_ON_WIDGET_INIT(on_widget_init_callback)
111 PLUGIN_CLASS_MAP_BEGIN
112 PLUGIN_CLASS_MAP_ADD_INTERFACE(
113 WRT_JS_EXTENSION_OBJECT_GLOBAL,
114 INTERFACE_WIDGET_NAME,
115 (js_class_template_getter)WrtPlugins::W3C::JSWidget::getClassRef,
116 reinterpret_cast<js_class_constructor_cb_t>(WrtPlugins::W3C::JSWidget::callAsConstructor),
117 &Options::WidgetInterfaceOptions)
118 PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(
119 WRT_JS_EXTENSION_OBJECT_GLOBAL,
121 INTERFACE_WIDGET_NAME,
122 &Options::WidgetOptions)
127 #undef OBJECT_PREFERENCES