[Release] wrt_0.8.193
[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 class CertificateSupport;
43 }
44
45 class ViewLogic : public ViewModule::IViewModule
46 {
47   public:
48     ViewLogic();
49     virtual ~ViewLogic();
50
51     // IViewModule Impl
52     bool createWebView(Ewk_Context* context,
53                        Evas_Object* window);
54     void destroyWebView();
55     void prepareView(WidgetModel* m, const std::string &startUrl);
56     void showWidget();
57     void hideWidget();
58     void suspendWidget();
59     void resumeWidget();
60     void resetWidget();
61     void backward();
62     void reloadStartPage();
63     Evas_Object* getCurrentWebview();
64     void fireJavascriptEvent(int event, void* data);
65     void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
66     void checkSyncMessageFromBundle(
67             const char* name,
68             const char* body,
69             char** returnData);
70     void downloadData(const char* url);
71     void activateVibration(bool on, uint64_t time);
72
73
74   private:
75     void initializeSupport();
76     void initializePluginLoading();
77
78     // EwkView operations
79     void ewkClientInit(Evas_Object *wkView);
80     void ewkClientDeinit(Evas_Object *wkView);
81     bool createEwkView(Evas* canvas);
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 Geolocation Callback
148     static void geolocationPermissionRequestCallback(
149         void* data,
150         Evas_Object* obj,
151         void* eventInfo);
152
153     // EWK Notification Callback
154     static void notificationShowCallback(
155         void* data,
156         Evas_Object* obj,
157         void* eventInfo);
158     static void notificationCancelCallback(
159         void* data,
160         Evas_Object* obj,
161         void* eventInfo);
162     static void notificationPermissionRequestCallback(
163         void* data,
164         Evas_Object* obj,
165         void* eventInfo);
166
167     // EWK Orientation Callback
168     static Eina_Bool orientationLockCallback(
169         Evas_Object* obj,
170         Eina_Bool needLock,
171         int orientation,
172         void* data);
173
174     // EWK Fullscreen API callbacks
175     static void enterFullscreenCallback(
176         void* data,
177         Evas_Object* obj,
178         void* eventInfo);
179     static void exitFullscreenCallback(
180         void* data,
181         Evas_Object* obj,
182         void* eventInfo);
183
184     // EWK IME Change/Show/Hide Callback
185     static void imeChangedCallback(
186         void* data,
187         Evas_Object* obj,
188         void* eventInfo);
189     static void imeOpenedCallback(
190         void* data,
191         Evas_Object* obj,
192         void* eventInfo);
193     static void imeClosedCallback(
194         void* data,
195         Evas_Object* obj,
196         void* eventInfo);
197
198     // EWK Usermedia Callback
199     static void usermediaPermissionRequestCallback(
200         void* data,
201         Evas_Object* obj,
202         void* eventInfo);
203
204     // custom content/scheme handlers
205     static void protocolHandlerRegistrationCallback(void* data,
206                                                     Evas_Object* obj,
207                                                     void* eventInfo);
208     static void protocolHandlerIsRegisteredCallback(void* data,
209                                                     Evas_Object* obj,
210                                                     void* eventInfo);
211     static void protocolHandlerUnregistrationCallback(void* data,
212                                                       Evas_Object* obj,
213                                                       void* eventInfo);
214
215     static void contentHandlerRegistrationCallback(void* data,
216                                                    Evas_Object* obj,
217                                                    void* eventInfo);
218     static void contentHandlerIsRegisteredCallback(void* data,
219                                                    Evas_Object* obj,
220                                                    void* eventInfo);
221     static void contentHandlerUnregistrationCallback(void* data,
222                                                      Evas_Object* obj,
223                                                      void* eventInfo);
224     static Eina_Bool exceededDatabaseQuotaCallback(Evas_Object* obj,
225                                                    Ewk_Security_Origin* origin,
226                                                    const char* databaseName,
227                                                    unsigned long long expectedQuota,
228                                                    void* data);
229     static Eina_Bool exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
230                                                           Ewk_Security_Origin* origin,
231                                                           long long expectedQuota,
232                                                           void* data);
233     static Eina_Bool exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
234                                                           Ewk_Security_Origin* origin,
235                                                           long long expectedQuota,
236                                                           void* data);
237     static void certificateConfirmRequestCallback(
238         void* data,
239         Evas_Object* obj,
240         void* eventInfo);
241     static void authenticationChallengeRequestCallback(
242         void* data,
243         Evas_Object* obj,
244         void* eventInfo);
245
246     static void viewFrameRenderedCallback(
247         void* data,
248         Evas_Object* obj,
249         void* eventInfo);
250
251 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
252     static int appServiceCallerIsKilled(void *data);
253 #endif
254
255     void attachToCustomHandlersDao();
256     void detachFromCustomHandlersDao();
257
258     // JS execute callback
259     static void didRunJavaScriptCallback(
260         Evas_Object* obj,
261         const char* result,
262         void* userData);
263
264     // idler callback
265     static Eina_Bool windowCloseIdlerCallback(void *data);
266
267     // security
268     void requestUrlBlocked(const std::string& blockedUrl);
269
270     // window
271     void windowClose(void);
272
273     Ewk_Context* m_ewkContext;
274     bool m_attachedToCustomHandlerDao;
275     std::list<Evas_Object*> m_ewkViewList;
276     Evas_Object* m_currentEwkView;
277     Evas_Object* m_closedEwkView;
278     Evas_Object* m_window;
279     WidgetModel* m_model;
280     std::string m_blockedUri;
281     std::string m_currentTitle;
282     std::string m_theme;
283     std::string m_startUrl;
284     WRT::UserDelegatesPtr m_cbs;
285     size_t m_imeWidth;
286     size_t m_imeHeight;
287     bool m_isBackgroundReload;
288     bool m_isBackgroundSupport;
289
290     std::unique_ptr<SchemeSupport> m_schemeSupport;
291     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
292     std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
293     std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
294     std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
295
296     static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
297 };
298
299 #endif //VIEW_LOGIC_H_