Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / js-overlay / deprecated / 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 struct IFrameData
35 {
36     IFrameData() : widget(0), addEventListener(0){}
37
38     JSObjectRef widget;
39     JSObjectRef addEventListener;
40 };
41 typedef std::shared_ptr<IFrameData> IFrameDataPtr;
42
43 class IFrameSupport
44 {
45   public:
46     static void RegisterWidget(java_script_context_t global_context,
47                                js_object_instance_t iframe,
48                                js_object_instance_t object);
49
50     static void RegisterAddEventListener(java_script_context_t global_context,
51                                          js_object_instance_t iframe,
52                                          js_object_instance_t object);
53
54     static JSObjectRef getIFrameObjectForWidget(JSObjectRef widgetObject);
55
56   private:
57     //map iframe:objects
58     typedef std::map<JSObjectRef, IFrameDataPtr> IFramesContainer;
59
60     static IFramesContainer m_iframesObject;
61
62   private:
63     static IFrameDataPtr getIFrameData(JSObjectRef iframe);
64 };
65 }
66 }
67
68 #endif