Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src / plugin-loading / plugin_logic.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_logic.h
18  * @author      Piotr Fatyga (p.fatyga@samsung.com)
19  * @author      Grzegorz Krawczyk (g.krawczyk@samsung.com)
20  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
21  * @version     1.0
22  * @brief       This file is the implementation file of plugin and feature
23  *              loading routines
24  * @brief       This code is intended to work behind view controller
25  */
26 #ifndef PLUGIN_LOGIC_H
27 #define PLUGIN_LOGIC_H
28
29 #include <memory>
30 #include <vector>
31 #include <set>
32 #include <dpl/singleton.h>
33 #include <dpl/noncopyable.h>
34 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
35 #include <js_overlay_types.h>
36 #include <js_types.h>
37 #include <dpl/availability.h>
38 #include <dpl/wrt-dao-ro/wrt_db_types.h>
39
40 using namespace WrtPlugins::W3C;
41
42 class PluginLogic : DPL::Noncopyable
43 {
44   public:
45     // Widget session
46     void initSession(WidgetHandle widgetHandle);
47     void startSession(WidgetHandle widgetHandle,
48                       JSGlobalContextRef view,
49                       double scaleFactor,
50                       const char* encodedBundle,
51                       const char* theme);
52
53     void stopSession(JSGlobalContextRef context);
54
55     //TODO im not sure if it is needed. I think it should be hidden
56     void performLibrariesUnload();
57     bool loadPluginOnDemand(const WrtDB::DbPluginHandle &pluginHandle,
58                             JavaScriptObject& parentObject,
59                             JSGlobalContextRef context);
60
61     DPL_DEPRECATED void loadPluginsIntoIframes(JSGlobalContextRef context);
62
63     void loadFrame(JSGlobalContextRef context);
64     void unloadFrame(JSGlobalContextRef context);
65
66     // reset custom window properties. (Tizen requirements)
67     DPL_DEPRECATED void setCustomProperties(double scaleFactor,
68                                                     const char* encodedBundle,
69                                                     const char* theme);
70
71     void setCustomProperties(JSGlobalContextRef ctx,
72                              double scaleFactor,
73                              const char* encodedBundle,
74                              const char* theme);
75
76     DPL_DEPRECATED void dispatchJavaScriptEvent(CustomEventType eventType);
77
78     void dispatchJavaScriptEvent(JSGlobalContextRef ctx,
79                                  CustomEventType eventType,
80                                  void* data);
81
82     unsigned int windowHandle() const;
83     void setWindowHandle(unsigned int handle);
84
85   private:
86     PluginLogic();
87     ~PluginLogic();
88
89     class Impl;
90     std::unique_ptr<Impl> m_impl;
91
92     friend class DPL::Singleton<PluginLogic>;
93 };
94
95 typedef DPL::Singleton<PluginLogic> PluginLogicSingleton;
96
97 #endif // PLUGIN_LOGIC_H