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