Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / plugin-loading / explorer.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    explorer.h
18  * @author  Grzegorz Krawczyk (g.krawczyk@samgsung.com)
19  * @version
20  * @brief
21  */
22
23 #ifndef WRT_SRC_PLUGIN_SERVICE_EXPLORER_H_
24 #define WRT_SRC_PLUGIN_SERVICE_EXPLORER_H_
25
26 #include <string>
27
28 #include <dpl/noncopyable.h>
29 #include <dpl/exception.h>
30 #include <dpl/shared_ptr.h>
31
32 #include <Commons/JSObject.h>
33 #include <Commons/JSObjectDeclaration.h>
34 //JSGlobalContextRef
35 #include "javascript_interface.h"
36 #include "plugin_iframe_support.h"
37 #include "plugin_property_support.h"
38
39 //JS overlay
40 #include <js_overlay_types.h>
41
42 using namespace PluginModule;
43 using namespace WrtPlugins::W3C;
44
45 class Explorer : private DPL::Noncopyable
46 {
47   public:
48     explicit Explorer(JSGlobalContextRef context);
49     ~Explorer();
50
51     //register to global frame
52     bool registerObject(const JSObjectDeclarationPtr& declaration,
53                         JSGlobalContextRef context);
54
55     bool registerObject (const JSObjectDeclarationPtr& declaration,
56                          const std::string& parentObjectName,
57                          JSObjectPtr parentObject,
58                          JSGlobalContextRef context);
59
60     void deregisterObject(const JSObjectDeclarationPtr& declaration);
61
62     // new load/unload frame API
63     void loadFrame(JSGlobalContextRef context);
64     void unloadFrame(JSGlobalContextRef context);
65
66     void removePluginsFromIframes();
67     void cleanIframesData();
68     void callEventListeners(CustomEventType eventType, void* data);
69
70     WindowPropertySupport* getWindowPropertySupport();
71
72   private:
73
74     IframesSupport m_iframeSupport;
75
76     //globalContext
77     JSGlobalContextRef m_context;
78
79     //global object of main frame
80     JSObjectPtr m_globalObject;
81
82     std::unique_ptr<WindowPropertySupport> m_propertySupport;
83
84   private:
85     void registerObjectIntoIframe(const JSObjectDeclarationPtr& declaration,
86                                   JSObjectPtr parentObject,
87                                   JSGlobalContextRef context);
88
89     bool register_(const JSObjectDeclarationPtr& declaration,
90                    JSObjectPtr parent,
91                    JSGlobalContextRef context);
92
93     JSObjectPtr getJSObjectProperty(const std::string& propertyName,
94                                     JSObjectPtr object);
95
96     JSObjectPtr getProperty(
97         const std::string& requestedProperty,
98         JSObjectPtr providedObject);
99 };
100
101 typedef DPL::SharedPtr<Explorer> ExplorerPtr;
102 #endif