Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / plugin-loading / plugin_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  * @file    plugin_iframe_support.h
18  * @version 1.0
19  * @brief
20  */
21
22 #ifndef _WRTENGINE_SRC_PLUGINSERVICE_IFRAME_SUPPORT_H_
23 #define _WRTENGINE_SRC_PLUGINSERVICE_IFRAME_SUPPORT_H_
24
25 #include<list>
26 #include<set>
27 #include <Commons/JSObjectDeclaration.h>
28 #include <Commons/JSObject.h>
29 #include "javascript_interface.h"
30
31 class IframesSupport
32 {
33   public:
34     typedef std::list<JSObjectDeclarationPtr> DeclarationsList;
35
36   public:
37     void registerDeclaration(const JSObjectDeclarationPtr& declaration);
38
39     void registerIframe(const JSObjectPtr& iframe);
40
41     void unregisterIframe(const JSObjectPtr& iframe);
42
43     DeclarationsList getIframeObjects() const;
44
45     bool hasIframes() const;
46
47     void clean();
48
49   private:
50     std::list<JSObjectDeclarationPtr> m_iframesObjects;
51     std::set<JSObjectPtr> m_loadedIframes;
52
53     // used to find matching object from m_loadedIframes
54     struct EqualToJSObjectPtr
55     {
56         typedef JSObjectPtr     first_argument_type;
57         typedef JSObjectPtr     second_argument_type;
58         typedef bool            result_type;
59
60         result_type operator()(const first_argument_type &s1,
61                 const second_argument_type &s2) const
62         {
63             return (s1->getObject() == s2->getObject());
64         }
65     };
66 };
67
68 #endif