Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / js-overlay / js_iframe_support.h
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  *
18  * @file       IFrameSupport.h
19  * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
20  * @version    0.1
21  * @brief
22  */
23
24 #ifndef _WRT_PLUGINS_SRC_W3C_WIDGET_IFRAME_SUPPORT_H_
25 #define _WRT_PLUGINS_SRC_W3C_WIDGET_IFRAME_SUPPORT_H_
26
27 #include <map>
28 #include <memory>
29 #include <JavaScriptCore/JavaScript.h>
30 #include <wrt_plugin_export.h>
31
32 namespace WrtPlugins {
33 namespace W3C {
34
35 struct IFrameData
36 {
37     IFrameData() : widget(0), addEventListener(0){}
38
39     JSObjectRef widget;
40     JSObjectRef addEventListener;
41 };
42 typedef std::shared_ptr<IFrameData> IFrameDataPtr;
43
44
45 class IFrameSupport
46 {
47   public:
48     static void RegisterWidget(java_script_context_t global_context,
49                                js_object_instance_t iframe,
50                                js_object_instance_t object);
51
52     static void RegisterAddEventListener(java_script_context_t global_context,
53                                          js_object_instance_t iframe,
54                                          js_object_instance_t object);
55
56     static JSObjectRef getIFrameObjectForWidget(JSObjectRef widgetObject);
57
58   private:
59     //map iframe:objects
60     typedef std::map<JSObjectRef, IFrameDataPtr> IFramesContainer;
61
62     static IFramesContainer m_iframesObject;
63
64   private:
65     static IFrameDataPtr getIFrameData(JSObjectRef iframe);
66 };
67
68 }
69 }
70
71 #endif