Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / 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 class PluginLogic : DPL::Noncopyable
42 {
43   public:
44     // Widget session
45     void initSession(int widgetHandle);
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(
77         CustomEventType eventType);
78
79     void dispatchJavaScriptEvent(JSGlobalContextRef ctx,
80                                  CustomEventType eventType,
81                                  void* data);
82
83     unsigned int windowHandle() const;
84     void setWindowHandle(unsigned int handle);
85
86   private:
87     PluginLogic();
88     ~PluginLogic();
89
90     class Impl;
91     std::unique_ptr<Impl> m_impl;
92
93     friend class DPL::Singleton<PluginLogic>;
94 };
95
96 typedef DPL::Singleton<PluginLogic> PluginLogicSingleton;
97
98 #endif // PLUGIN_LOGIC_H