[Release] wrt_0.8.235
[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 checkAsyncMessageFromBundle(
72             const char* name,
73             const char* body);
74     void downloadData(const char* url);
75     void activateVibration(bool on, uint64_t time);
76
77
78   private:
79     void initializeSupport();
80     void initializePluginLoading();
81     void initializeXwindowHandle();
82
83     // EwkView operations
84     void ewkClientInit(Evas_Object *wkView);
85     void ewkClientDeinit(Evas_Object *wkView);
86     bool createEwkView(Evas* canvas);
87     void prepareEwkView(Evas_Object *wkView);
88     void removeEwkView(Evas_Object *wkView);
89     void resumeEwkView(Evas_Object *wkView);
90     void suspendEwkView(Evas_Object *wkView);
91     void setEwkViewVisible(Evas_Object *wkView);
92     void setEwkViewInvisible(Evas_Object *wkView);
93     void resumeWebkit(Evas_Object *wkView);
94     void suspendWebkit(Evas_Object *wkView);
95
96     // WKPageLoaderClient
97     static void loadStartedCallback(
98         void* data,
99         Evas_Object* obj,
100         void* eventInfo);
101     static void loadFinishedCallback(
102         void* data,
103         Evas_Object* obj,
104         void* eventInfo);
105     static void titleChangedCallback(
106         void* data,
107         Evas_Object* obj,
108         void* eventInfo);
109     static void loadProgressStartedCallback(
110         void* data,
111         Evas_Object* obj,
112         void* eventInfo);
113     static void loadProgressCallback(
114         void* data,
115         Evas_Object* obj,
116         void* eventInfo);
117     static void loadProgressFinishedCallback(
118         void* data,
119         Evas_Object* obj,
120         void* eventInfo);
121     static void processCrashedCallback(
122         void* data,
123         Evas_Object* obj,
124         void* eventInfo);
125
126     // EWK Callback
127     static void createWindowCallback(
128         void* data,
129         Evas_Object* obj,
130         void* eventInfo);
131     static void closeWindowCallback(
132         void* data,
133         Evas_Object* obj,
134         void* eventInfo);
135
136     // EWK PolicyDecide Callback
137     static void policyNavigationDecideCallback(
138         void* data,
139         Evas_Object* obj,
140         void* eventInfo);
141     static void policyNewWindowDecideCallback(
142         void* data,
143         Evas_Object* obj,
144         void* eventInfo);
145     static void pageResponseDecideCallback(
146         void* data,
147         Evas_Object* obj,
148         void* eventInfo);
149
150     // EWK ContextMenu Callback
151     static void contextmenuCustomizeCallback(
152         void* data,
153         Evas_Object* obj,
154         void* eventInfo);
155
156     // EWK Geolocation Callback
157     static void geolocationPermissionRequestCallback(
158         void* data,
159         Evas_Object* obj,
160         void* eventInfo);
161
162     // EWK Notification Callback
163     static void notificationShowCallback(
164         void* data,
165         Evas_Object* obj,
166         void* eventInfo);
167     static void notificationCancelCallback(
168         void* data,
169         Evas_Object* obj,
170         void* eventInfo);
171     static void notificationPermissionRequestCallback(
172         void* data,
173         Evas_Object* obj,
174         void* eventInfo);
175
176     // EWK Orientation Callback
177     static Eina_Bool orientationLockCallback(
178         Evas_Object* obj,
179         Eina_Bool needLock,
180         int orientation,
181         void* data);
182
183     // EWK Fullscreen API callbacks
184     static void enterFullscreenCallback(
185         void* data,
186         Evas_Object* obj,
187         void* eventInfo);
188     static void exitFullscreenCallback(
189         void* data,
190         Evas_Object* obj,
191         void* eventInfo);
192
193     // EWK IME Change/Show/Hide Callback
194     static void imeChangedCallback(
195         void* data,
196         Evas_Object* obj,
197         void* eventInfo);
198     static void imeOpenedCallback(
199         void* data,
200         Evas_Object* obj,
201         void* eventInfo);
202     static void imeClosedCallback(
203         void* data,
204         Evas_Object* obj,
205         void* eventInfo);
206
207     // EWK Usermedia Callback
208     static void usermediaPermissionRequestCallback(
209         void* data,
210         Evas_Object* obj,
211         void* eventInfo);
212
213     // custom content/scheme handlers
214     static void protocolHandlerRegistrationCallback(void* data,
215                                                     Evas_Object* obj,
216                                                     void* eventInfo);
217     static void protocolHandlerIsRegisteredCallback(void* data,
218                                                     Evas_Object* obj,
219                                                     void* eventInfo);
220     static void protocolHandlerUnregistrationCallback(void* data,
221                                                       Evas_Object* obj,
222                                                       void* eventInfo);
223
224     static void contentHandlerRegistrationCallback(void* data,
225                                                    Evas_Object* obj,
226                                                    void* eventInfo);
227     static void contentHandlerIsRegisteredCallback(void* data,
228                                                    Evas_Object* obj,
229                                                    void* eventInfo);
230     static void contentHandlerUnregistrationCallback(void* data,
231                                                      Evas_Object* obj,
232                                                      void* eventInfo);
233     static Eina_Bool exceededDatabaseQuotaCallback(Evas_Object* obj,
234                                                    Ewk_Security_Origin* origin,
235                                                    const char* databaseName,
236                                                    unsigned long long expectedQuota,
237                                                    void* data);
238     static Eina_Bool exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
239                                                           Ewk_Security_Origin* origin,
240                                                           long long expectedQuota,
241                                                           void* data);
242     static Eina_Bool exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
243                                                           Ewk_Security_Origin* origin,
244                                                           long long expectedQuota,
245                                                           void* data);
246     static void certificateConfirmRequestCallback(
247         void* data,
248         Evas_Object* obj,
249         void* eventInfo);
250     static void authenticationChallengeRequestCallback(
251         void* data,
252         Evas_Object* obj,
253         void* eventInfo);
254
255     static void viewFrameRenderedCallback(
256         void* data,
257         Evas_Object* obj,
258         void* eventInfo);
259
260     static void mediacontrolRotateHorizontal(void* data,
261                                              Evas_Object* obj,
262                                              void* eventInfo);
263     static void mediacontrolRotateVertical(void* data,
264                                            Evas_Object* obj,
265                                            void* eventInfo);
266     static void mediacontrolRotateExit(void* data,
267                                        Evas_Object* obj,
268                                        void* eventInfo);
269     static void popupReplyWaitStart(void* data,
270                                     Evas_Object* obj,
271                                     void* eventInfo);
272     static void popupReplyWaitFinish(void* data,
273                                      Evas_Object* obj,
274                                      void* eventInfo);
275
276 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
277     static int appServiceCallerIsKilled(void *data);
278 #endif
279
280     void attachToCustomHandlersDao();
281     void detachFromCustomHandlersDao();
282
283     // JS execute callback
284     static void didRunJavaScriptCallback(
285         Evas_Object* obj,
286         const char* result,
287         void* userData);
288
289     // event callback
290     static void eaKeyCallback(void* data,
291                               Evas_Object* obj,
292                               void* eventInfo);
293
294     // idler callback
295     static Eina_Bool windowCloseIdlerCallback(void *data);
296
297     // timer callback
298     static Eina_Bool orientationThresholdTimerCallback(void* data);
299
300     // security
301     void requestUrlBlocked(const std::string& blockedUrl);
302
303     // window
304     void windowClose(void);
305
306     // system settings
307     static void systemSettingsChangedCallback(system_settings_key_e key, void* data);
308
309     Ewk_Context* m_ewkContext;
310     bool m_attachedToCustomHandlerDao;
311     std::list<Evas_Object*> m_ewkViewList;
312     Evas_Object* m_currentEwkView;
313     Evas_Object* m_closedEwkView;
314     Evas_Object* m_window;
315     WidgetModel* m_model;
316     std::string m_blockedUri;
317     std::string m_currentTitle;
318     std::string m_theme;
319     std::string m_startUrl;
320     WRT::UserDelegatesPtr m_cbs;
321     size_t m_imeWidth;
322     size_t m_imeHeight;
323     bool m_isBackgroundReload;
324     bool m_isBackgroundSupport;
325     int m_rotateAngle;
326     int m_deferredRotateAngle;
327     Ecore_Timer* m_orientationThresholdTimer;
328     bool m_isPopupReplyWait;
329
330     std::unique_ptr<SchemeSupport> m_schemeSupport;
331     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
332     std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
333     std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
334     std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
335
336     static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
337 };
338
339 #endif //VIEW_LOGIC_H_