Update wrt-plugins-common_0.3.53
[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 <Commons/Deprecated.h>
38
39 using namespace WrtPlugins::W3C;
40
41
42 class PluginLogic : DPL::Noncopyable
43 {
44   public:
45     // Widget session
46     void startSession(int widgetHandle,
47                       JSGlobalContextRef view,
48                       double scaleFactor,
49                       const char* encodedBundle,
50                       const char* theme);
51
52     void stopSession(JSGlobalContextRef context);
53
54     //TODO im not sure if it is needed. I think it should be hidden
55     void performLibrariesUnload();
56     bool loadPluginOnDemand(const WrtDB::DbPluginHandle &pluginHandle,
57                             JavaScriptObject& parentObject,
58                             JSGlobalContextRef context);
59
60     WRT_PLUGINS_DEPRECATED void loadPluginsIntoIframes(
61         JSGlobalContextRef context);
62
63     void loadFrame(JSGlobalContextRef context);
64     void unloadFrame(JSGlobalContextRef context);
65
66     // reset custom window properties. (Tizen requirements)
67     WRT_PLUGINS_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     WRT_PLUGINS_DEPRECATED void dispatchJavaScriptEvent(CustomEventType eventType);
77
78     void dispatchJavaScriptEvent(JSGlobalContextRef ctx,
79                                 CustomEventType eventType);
80
81   private:
82     PluginLogic();
83     ~PluginLogic();
84
85     class Impl;
86     std::unique_ptr<Impl> m_impl;
87
88     friend class DPL::Singleton<PluginLogic>;
89 };
90
91 typedef DPL::Singleton<PluginLogic> PluginLogicSingleton;
92
93 #endif // PLUGIN_LOGIC_H