ad6aa053f6b66eb66a8006c30702ea8a37b3dbc4
[platform/framework/web/web-provider.git] / src / Plugin / AppBoxPlugin / AppBoxRenderView.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.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://floralicense.org/license/
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    AppBoxRenderView.h
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #ifndef APP_BOX_RENDER_VIEW_H
21 #define APP_BOX_RENDER_VIEW_H
22
23 #include <string>
24 #include <memory>
25 #include <Eina.h>
26 #include <Ecore.h>
27 #include <Evas.h>
28 #include <ewk_context.h>
29 #include <i_runnable_widget_object.h>
30 #include <Core/View/IRenderView.h>
31 #include <Core/View/IPdHelper.h>
32
33 class AppBoxRenderBuffer;
34
35 class AppBoxRenderView: public IRenderView {
36     public:
37         typedef std::shared_ptr<Ewk_Context> EwkContextPtr;
38         static IRenderViewPtr create(
39                 std::string boxId, std::string instanceId, 
40                 Evas_Object* boxWin, EwkContextPtr ewkContext)
41         {
42             return IRenderViewPtr(
43                     new AppBoxRenderView(
44                         boxId, instanceId, boxWin, ewkContext));
45         };
46         virtual void showBox(RenderInfoPtr renderInfo);
47         virtual void hideBox();
48         virtual void pauseBox();
49         virtual void resumeBox();
50         virtual void showPd(Evas_Object* pdWin, RenderInfoPtr renderInfo);
51         virtual void hidePd();
52         Evas_Object* getBoxWebView();
53         Evas_Object* getPdWebView();
54         virtual ~AppBoxRenderView();
55
56     private:
57         // type definition
58         enum UrlType {
59             URL_TYPE_BOX,
60             URL_TYPE_PD
61         };
62         typedef std::shared_ptr<WRT::IRunnableWidgetObject> ViewPtr;
63         
64         bool createView();
65         bool destroyView();
66         std::string getAppId(std::string& boxId);
67         std::string getStartUrl(UrlType type, std::string& defaultParams);
68         Evas_Object* getCurrentSnapShot();
69         void clearSnapShot();
70         void addRenderTimer();
71         void deleteRenderTimer();
72
73         // timer and idler callback
74         static Eina_Bool fireRenderTimerCallback(void* data);
75         static Eina_Bool openPdIdlerCallback(void* data);
76
77         // ewk view callback
78         static void executeScriptCallback(
79                 Evas_Object* webview, const char* result, void* data);
80
81         // user Callbacks of RunnableWidgetObject
82         void startLoadCallback(Evas_Object* webview);
83         void finishLoadCallback(Evas_Object* webview);
84         void createWindowBeforeCallback(Evas** canvas, Evas_Object* parent);
85         void createWindowAfterCallback(Evas_Object* parent, Evas_Object* child);
86         void setBufferCallback(Evas_Object* webview);
87         void unsetBufferCallback(Evas_Object* webview);
88         void decideNavigationCallback(Evas_Object* webview, std::string& uri);
89
90         // constructor
91         explicit AppBoxRenderView(
92                 std::string boxId, std::string instanceId,
93                 Evas_Object* boxWin, EwkContextPtr ewkContext);
94
95         // members
96         std::string m_appId;
97         std::string m_boxId;
98         std::string m_instanceId;
99         Evas_Object* m_boxWin;
100         Evas_Object* m_baseWebView;
101         Evas_Object* m_snapshot;
102         RenderInfoPtr m_renderInfo;
103         ViewPtr m_view;
104         std::string m_startUrl;
105         Ecore_Timer* m_fireRenderTimer;
106         IPdHelperPtr m_pdHelper;
107         EwkContextPtr m_ewkContext;
108         AppBoxRenderBuffer* m_renderBuffer;
109
110         friend class AppBoxRenderBuffer;
111 };
112
113 #endif // APP_BOX_RENDER_VIEW_H