tizen 2.3.1 release
[framework/web/mobile/wrt.git] / src / view / webkit / injected-bundle / injected_bundle_plugin_interface.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file    injected_bundle_plugin_interface.cpp
18  * @author  Lukasz Marek (l.marek@samgsung.com)
19  * @author  Yunchan Cho (yunchan.cho@samgsung.com)
20  * @version
21  * @brief
22  */
23
24 #include "injected_bundle_plugin_interface.h"
25
26 #include <dpl/log/wrt_log.h>
27 #include <dpl/string.h>
28 #include <dpl/assert.h>
29 #include <plugin_logic.h>
30 #include <js_overlay_types.h>
31
32 namespace InjectedBundlePluginInterface {
33 void init(int widgetHandle)
34 {
35     WrtLogD("called");
36     PluginLogicSingleton::Instance().initSession(widgetHandle);
37 }
38
39 void start(int widgetHandle,
40            JSGlobalContextRef context,
41            double scale,
42            const char *encodedBundle,
43            const char *theme)
44 {
45     PluginLogicSingleton::Instance().startSession(widgetHandle,
46                                                   context,
47                                                   scale,
48                                                   encodedBundle,
49                                                   theme);
50 }
51
52 void shutdown()
53 {
54     WrtLogD("called");
55     PluginLogicSingleton::Instance().performLibrariesUnload();
56 }
57
58 void stop(JSGlobalContextRef context)
59 {
60     WrtLogD("called");
61     PluginLogicSingleton::Instance().stopSession(context);
62 }
63
64 void setCustomProperties(JSGlobalContextRef context,
65                          double scale,
66                          const char* encodedBundle,
67                          const char* theme)
68 {
69     WrtLogD("called");
70     PluginLogicSingleton::Instance().setCustomProperties(context,
71                                                          scale,
72                                                          encodedBundle,
73                                                          theme);
74 }
75
76 void dispatchJavaScriptEvent(JSGlobalContextRef context,
77                              WrtPlugins::W3C::CustomEventType eventType,
78                              void* data)
79 {
80     WrtLogD("called");
81     PluginLogicSingleton::Instance().dispatchJavaScriptEvent(context,
82                                                              eventType,
83                                                              data);
84 }
85
86 void loadFrame(JSGlobalContextRef context)
87 {
88     WrtLogD("load frame into web page");
89     PluginLogicSingleton::Instance().loadFrame(context);
90 }
91
92 void unloadFrame(JSGlobalContextRef context)
93 {
94     WrtLogD("unload frame from web page");
95     PluginLogicSingleton::Instance().unloadFrame(context);
96 }
97 } // namespace InjectedBundlePluginInterface