Analysing and removing cppcheck warnings in wrt repository
[platform/framework/web/wrt.git] / src / view / webkit / view_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    view_logic.h
18  * @author  Lukasz Wrzosek (l.wrzosek@samsung.com)
19  * @brief   Declaration file for view logic for Webkit2
20  */
21
22 #ifndef VIEW_LOGIC_H_
23 #define VIEW_LOGIC_H_
24
25 #include <i_view_module.h>
26 #include <memory>
27 #include <map>
28 #include <string>
29 #include <dpl/log/log.h>
30 #include <dpl/assert.h>
31
32 #include <widget_model.h>
33 #include <i_runnable_widget_object.h>
34 #include <common/view_logic_apps_support.h>
35 #include <common/view_logic_vibration_support.h>
36
37 #include <EWebKit2.h>
38
39 class SchemeSupport;
40 namespace ViewModule {
41 class SecurityOriginSupport;
42 }
43
44 class ViewLogic : public ViewModule::IViewModule
45 {
46   public:
47     ViewLogic();
48     virtual ~ViewLogic();
49
50     // IViewModule Impl
51     bool createWebView(Ewk_Context* context,
52                        Evas_Object* window);
53     void destroyWebView();
54     void prepareView(WidgetModel* m, const std::string &startUrl);
55     void showWidget();
56     void hideWidget();
57     void suspendWidget();
58     void resumeWidget();
59     void resetWidget();
60     void backward();
61     void reloadStartPage();
62     Evas_Object* getCurrentWebview();
63     void fireJavascriptEvent(int event, void* data);
64     void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
65     void checkSyncMessageFromBundle(
66             const char* name,
67             const char* body,
68             char** returnData);
69     void downloadData(const char* url);
70     void activateVibration(bool on, uint64_t time);
71
72
73   private:
74     void initializeSupport();
75     void initializePluginLoading();
76
77     // EwkView operations
78     void ewkClientInit(Evas_Object *wkView);
79     void ewkClientDeinit(Evas_Object *wkView);
80     bool createEwkView(Evas* canvas);
81     void setStartPage();
82     void prepareEwkView(Evas_Object *wkView);
83     void removeEwkView(Evas_Object *wkView);
84     void resumeEwkView(Evas_Object *wkView);
85     void suspendEwkView(Evas_Object *wkView);
86     void setEwkViewVisible(Evas_Object *wkView);
87     void setEwkViewInvisible(Evas_Object *wkView);
88     void resumeWebkit(Evas_Object *wkView);
89     void suspendWebkit(Evas_Object *wkView);
90
91     // WKPageLoaderClient
92     static void loadStartedCallback(
93         void* data,
94         Evas_Object* obj,
95         void* eventInfo);
96     static void loadFinishedCallback(
97         void* data,
98         Evas_Object* obj,
99         void* eventInfo);
100     static void titleChangedCallback(
101         void* data,
102         Evas_Object* obj,
103         void* eventInfo);
104     static void loadProgressCallback(
105         void* data,
106         Evas_Object* obj,
107         void* eventInfo);
108     static void loadProgressFinishedCallback(
109         void* data,
110         Evas_Object* obj,
111         void* eventInfo);
112     static void processCrashedCallback(
113         void* data,
114         Evas_Object* obj,
115         void* eventInfo);
116
117     // EWK Callback
118     static void createWindowCallback(
119         void* data,
120         Evas_Object* obj,
121         void* eventInfo);
122     static void closeWindowCallback(
123         void* data,
124         Evas_Object* obj,
125         void* eventInfo);
126
127     // EWK PolicyDecide Callback
128     static void policyNavigationDecideCallback(
129         void* data,
130         Evas_Object* obj,
131         void* eventInfo);
132     static void policyNewWindowDecideCallback(
133         void* data,
134         Evas_Object* obj,
135         void* eventInfo);
136     static void pageResponseDecideCallback(
137         void* data,
138         Evas_Object* obj,
139         void* eventInfo);
140
141     // EWK ContextMenu Callback
142     static void contextmenuCustomizeCallback(
143         void* data,
144         Evas_Object* obj,
145         void* eventInfo);
146
147     // EWK FormClient Callback
148     static void formSubmitCallback(
149         void *data,
150         Evas_Object *obj,
151         void *eventInfo);
152
153     // EWK Geolocation Callback
154     static void geolocationPermissionRequestCallback(
155         void* data,
156         Evas_Object* obj,
157         void* eventInfo);
158
159     // EWK Notification Callback
160     static void notificationShowCallback(
161         void* data,
162         Evas_Object* obj,
163         void* eventInfo);
164     static void notificationCancelCallback(
165         void* data,
166         Evas_Object* obj,
167         void* eventInfo);
168     static void notificationPermissionRequestCallback(
169         void* data,
170         Evas_Object* obj,
171         void* eventInfo);
172
173     // EWK Orientation Callback
174     static Eina_Bool orientationLockCallback(
175         Evas_Object* obj,
176         Eina_Bool needLock,
177         int orientation,
178         void* data);
179
180     // EWK Fullscreen API callbacks
181     static void enterFullscreenCallback(
182         void* data,
183         Evas_Object* obj,
184         void* eventInfo);
185     static void exitFullscreenCallback(
186         void* data,
187         Evas_Object* obj,
188         void* eventInfo);
189
190     // EWK IME Change/Show/Hide Callback
191     static void imeChangedCallback(
192         void* data,
193         Evas_Object* obj,
194         void* eventInfo);
195     static void imeOpenedCallback(
196         void* data,
197         Evas_Object* obj,
198         void* eventInfo);
199     static void imeClosedCallback(
200         void* data,
201         Evas_Object* obj,
202         void* eventInfo);
203
204     // EWK Usermedia Callback
205     static void usermediaPermissionRequestCallback(
206         void* data,
207         Evas_Object* obj,
208         void* eventInfo);
209
210     // custom content/scheme handlers
211     static void protocolHandlerRegistrationCallback(void* data,
212                                                     Evas_Object* obj,
213                                                     void* eventInfo);
214     static void protocolHandlerIsRegisteredCallback(void* data,
215                                                     Evas_Object* obj,
216                                                     void* eventInfo);
217     static void protocolHandlerUnregistrationCallback(void* data,
218                                                       Evas_Object* obj,
219                                                       void* eventInfo);
220
221     static void contentHandlerRegistrationCallback(void* data,
222                                                    Evas_Object* obj,
223                                                    void* eventInfo);
224     static void contentHandlerIsRegisteredCallback(void* data,
225                                                    Evas_Object* obj,
226                                                    void* eventInfo);
227     static void contentHandlerUnregistrationCallback(void* data,
228                                                      Evas_Object* obj,
229                                                      void* eventInfo);
230
231     // database usage permission request callback
232     static void databaseUsagePermissionRequestCallback(
233         void* data,
234         Evas_Object* obj,
235         void* eventInfo);
236     // file System Permission Request Callback
237     static void fileSystemPermissionRequestCallback(
238         void* data,
239         Evas_Object* obj,
240         void* eventInfo);
241     static void certificateConfirmRequestCallback(
242         void* data,
243         Evas_Object* obj,
244         void* eventInfo);
245     bool askUserForCertificateConfirm();
246
247     void attachToCustomHandlersDao();
248     void detachFromCustomHandlersDao();
249
250     // JS execute callback
251     static void didRunJavaScriptCallback(
252         Evas_Object* obj,
253         const char* result,
254         void* userData);
255
256     // idler callback
257     static Eina_Bool windowCloseIdlerCallback(void *data);
258
259     // security
260     std::string requestUrlBlocked(const std::string& blockedUrl);
261     std::string requestUrlChanged(const std::string& changedUrl);
262
263     // window
264     void windowClose(void);
265
266     Ewk_Context* m_ewkContext;
267     bool m_attachedToCustomHandlerDao;
268     std::list<Evas_Object*> m_ewkViewList;
269     Evas_Object* m_currentEwkView;
270     Evas_Object* m_closedEwkView;
271     Evas_Object* m_window;
272     WidgetModel* m_model;
273     std::string m_currentUri;
274     std::string m_blockedUri;
275     std::string m_theme;
276     std::string m_startUrl;
277     WRT::UserDelegatesPtr m_cbs;
278     size_t m_imeWidth;
279     size_t m_imeHeight;
280     bool m_isBackgroundReload;
281     bool m_isBackgroundSupport;
282
283     std::unique_ptr<SchemeSupport> m_schemeSupport;
284     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
285     std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
286     std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
287
288     static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
289 };
290
291 #endif //VIEW_LOGIC_H_