Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / plugin-loading / js_page_session.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        js_page_session.h
18  * @author      Grzegorz Krawczyk (g.krawczyk@samsung.com)
19  * @version     1.0
20  */
21 #ifndef WRT_PLUGIN_JS_PAGE_SESSION_H_
22 #define WRT_PLUGIN_JS_PAGE_SESSION_H_
23
24 #include <memory>
25 #include <vector>
26 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
27 #include <js_overlay_types.h>
28 #include "js_types.h"
29
30 using namespace WrtPlugins::W3C;
31
32 class JSPageSession
33 {
34   public:
35     // Widget session
36     void startSession(int widgetHandle,
37                       JSGlobalContextRef view,
38                       double scaleFactor,
39                       const char* encodedBundle,
40                       const char* theme);
41
42     void stopSession();
43
44     //TODO im not sure if it is needed. I think it should be hidden
45     void performLibrariesUnload();
46     bool loadPluginOnDemand(const WrtDB::DbPluginHandle &pluginHandle,
47                             JavaScriptObject& parentObject,
48                             JSGlobalContextRef context);
49
50     void loadFrame(JSGlobalContextRef context);
51     void unloadFrame(JSGlobalContextRef context);
52
53     // reset custom window properties. (Tizen requirements)
54     void setCustomProperties(double scaleFactor,
55                              const char* encodedBundle,
56                              const char* theme);
57
58     void dispatchJavaScriptEvent(CustomEventType eventType, void* data);
59
60     JSPageSession(const PluginContainerSupportPtr& containerSupport);
61
62     virtual ~JSPageSession();
63
64   private:
65     class Impl;
66     std::unique_ptr<Impl> m_impl;
67 };
68
69 typedef std::shared_ptr<JSPageSession> JSPageSessionPtr;
70
71 #endif // PLUGIN_LOGIC_H