[Release] wrt_0.8.215
[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 #include <system_settings.h>
37
38 #include <EWebKit2.h>
39
40 class SchemeSupport;
41 namespace ViewModule {
42 class SecurityOriginSupport;
43 class CertificateSupport;
44 }
45
46 class ViewLogic : public ViewModule::IViewModule
47 {
48   public:
49     ViewLogic();
50     virtual ~ViewLogic();
51
52     // IViewModule Impl
53     bool createWebView(Ewk_Context* context,
54                        Evas_Object* window);
55     void destroyWebView();
56     void prepareView(WidgetModel* m, const std::string &startUrl);
57     void showWidget();
58     void hideWidget();
59     void suspendWidget();
60     void resumeWidget();
61     void resetWidget();
62     void backward();
63     void reloadStartPage();
64     Evas_Object* getCurrentWebview();
65     void fireJavascriptEvent(int event, void* data);
66     void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
67     void checkSyncMessageFromBundle(
68             const char* name,
69             const char* body,
70             char** returnData);
71     void downloadData(const char* url);
72     void activateVibration(bool on, uint64_t time);
73
74
75   private:
76     void initializeSupport();
77     void initializePluginLoading();
78     void initializeXwindowHandle();
79
80     // EwkView operations
81     void ewkClientInit(Evas_Object *wkView);
82     void ewkClientDeinit(Evas_Object *wkView);
83     bool createEwkView(Evas* canvas);
84     void prepareEwkView(Evas_Object *wkView);
85     void removeEwkView(Evas_Object *wkView);
86     void resumeEwkView(Evas_Object *wkView);
87     void suspendEwkView(Evas_Object *wkView);
88     void setEwkViewVisible(Evas_Object *wkView);
89     void setEwkViewInvisible(Evas_Object *wkView);
90     void resumeWebkit(Evas_Object *wkView);
91     void suspendWebkit(Evas_Object *wkView);
92
93     // WKPageLoaderClient
94     static void loadStartedCallback(
95         void* data,
96         Evas_Object* obj,
97         void* eventInfo);
98     static void loadFinishedCallback(
99         void* data,
100         Evas_Object* obj,
101         void* eventInfo);
102     static void titleChangedCallback(
103         void* data,
104         Evas_Object* obj,
105         void* eventInfo);
106     static void loadProgressStartedCallback(
107         void* data,
108         Evas_Object* obj,
109         void* eventInfo);
110     static void loadProgressCallback(
111         void* data,
112         Evas_Object* obj,
113         void* eventInfo);
114     static void loadProgressFinishedCallback(
115         void* data,
116         Evas_Object* obj,
117         void* eventInfo);
118     static void processCrashedCallback(
119         void* data,
120         Evas_Object* obj,
121         void* eventInfo);
122
123     // EWK Callback
124     static void createWindowCallback(
125         void* data,
126         Evas_Object* obj,
127         void* eventInfo);
128     static void closeWindowCallback(
129         void* data,
130         Evas_Object* obj,
131         void* eventInfo);
132
133     // EWK PolicyDecide Callback
134     static void policyNavigationDecideCallback(
135         void* data,
136         Evas_Object* obj,
137         void* eventInfo);
138     static void policyNewWindowDecideCallback(
139         void* data,
140         Evas_Object* obj,
141         void* eventInfo);
142     static void pageResponseDecideCallback(
143         void* data,
144         Evas_Object* obj,
145         void* eventInfo);
146
147     // EWK ContextMenu Callback
148     static void contextmenuCustomizeCallback(
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     static Eina_Bool exceededDatabaseQuotaCallback(Evas_Object* obj,
231                                                    Ewk_Security_Origin* origin,
232                                                    const char* databaseName,
233                                                    unsigned long long expectedQuota,
234                                                    void* data);
235     static Eina_Bool exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
236                                                           Ewk_Security_Origin* origin,
237                                                           long long expectedQuota,
238                                                           void* data);
239     static Eina_Bool exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
240                                                           Ewk_Security_Origin* origin,
241                                                           long long expectedQuota,
242                                                           void* data);
243     static void certificateConfirmRequestCallback(
244         void* data,
245         Evas_Object* obj,
246         void* eventInfo);
247     static void authenticationChallengeRequestCallback(
248         void* data,
249         Evas_Object* obj,
250         void* eventInfo);
251
252     static void viewFrameRenderedCallback(
253         void* data,
254         Evas_Object* obj,
255         void* eventInfo);
256
257     static void mediacontrolRotateHorizontal(void* data,
258                                              Evas_Object* obj,
259                                              void* eventInfo);
260     static void mediacontrolRotateVertical(void* data,
261                                            Evas_Object* obj,
262                                            void* eventInfo);
263     static void mediacontrolRotateExit(void* data,
264                                        Evas_Object* obj,
265                                        void* eventInfo);
266
267 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
268     static int appServiceCallerIsKilled(void *data);
269 #endif
270
271     void attachToCustomHandlersDao();
272     void detachFromCustomHandlersDao();
273
274     // JS execute callback
275     static void didRunJavaScriptCallback(
276         Evas_Object* obj,
277         const char* result,
278         void* userData);
279
280     // event callback
281     static void keyupCallback(void* data,
282                               Evas* e,
283                               Evas_Object* obj,
284                               void* eventInfo);
285
286     // idler callback
287     static Eina_Bool windowCloseIdlerCallback(void *data);
288
289     // security
290     void requestUrlBlocked(const std::string& blockedUrl);
291
292     // window
293     void windowClose(void);
294
295     // system settings
296     static void systemSettingsChangedCallback(system_settings_key_e key, void* data);
297
298     Ewk_Context* m_ewkContext;
299     bool m_attachedToCustomHandlerDao;
300     std::list<Evas_Object*> m_ewkViewList;
301     Evas_Object* m_currentEwkView;
302     Evas_Object* m_closedEwkView;
303     Evas_Object* m_window;
304     WidgetModel* m_model;
305     std::string m_blockedUri;
306     std::string m_currentTitle;
307     std::string m_theme;
308     std::string m_startUrl;
309     WRT::UserDelegatesPtr m_cbs;
310     size_t m_imeWidth;
311     size_t m_imeHeight;
312     bool m_isBackgroundReload;
313     bool m_isBackgroundSupport;
314     int m_rotateAngle;
315
316     std::unique_ptr<SchemeSupport> m_schemeSupport;
317     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
318     std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
319     std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
320     std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
321
322     static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
323 };
324
325 #endif //VIEW_LOGIC_H_