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>
30 #include "JSPreferences.h"
33 #include "IFrameSupport.h"
34 #include "AddEventListenerSupport.h"
36 #define OBJECT_WIDGET "widget"
37 #define OBJECT_PREFERENCES "preferences"
38 #define OBJECT_TEST "__test"
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,
56 class_definition_options_t AddEventListenerOptions =
61 OVERLAYED_BEFORE_ORIGINAL,
62 IFrameSupport::RegisterAddEventListener,
68 void on_widget_start_callback(int widgetId)
70 LogDebug("[W3C\\widget] on_widget_start_callback (" << widgetId << ")");
74 WrtAccessSingleton::Instance().initialize(widgetId);
76 Catch (Commons::Exception)
78 LogError("Wrt wrapper registration failed");
83 void on_widget_stop_callback(int widgetId)
85 LogDebug("[W3C\\widget] on_widget_stop_callback (" << widgetId << ")");
88 WrtAccessSingleton::Instance().deinitialize(widgetId);
90 Catch (Commons::Exception)
92 LogError("Wrt wrapper registration failed");
98 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
99 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
101 PLUGIN_CLASS_MAP_BEGIN
102 PLUGIN_CLASS_MAP_ADD_CLASS (WRT_JS_EXTENSION_OBJECT_GLOBAL,
104 WrtPlugins::W3C::JSWidget::getClassRef(),
105 &Options::WidgetOptions)
106 //PLUGIN_CLASS_MAP_ADD_CLASS(OBJECT_WIDGET,
107 // OBJECT_PREFERENCES,
108 // WrtPlugins::W3C::JSPreferences::getClassRef(),
110 //Function::AddEventListener
111 PLUGIN_CLASS_MAP_ADD_CLASS (WRT_JS_EXTENSION_OBJECT_GLOBAL,
114 AddEventListenerSupport::AddEventListener,
115 &Options::AddEventListenerOptions)
117 PLUGIN_CLASS_MAP_ADD_CLASS(OBJECT_WIDGET,
119 WrtPlugins::W3C::JSTest::getClassRef(),
125 #undef OBJECT_PREFERENCES