36b13453d86cd3d82a9426a4509e7b58717c20cf
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / eweb_view_callbacks.h
1 /*
2  * Copyright (C) 2014 Samsung Electronics. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  *
19  */
20
21 #ifndef EWEB_VIEW_CALLBACKS
22 #define EWEB_VIEW_CALLBACKS
23
24 #include <Evas.h>
25 #include <Eina.h>
26
27 #include "eweb_view.h"
28 #include "private/ewk_auth_challenge_private.h"
29 #include "private/ewk_certificate_info_private.h"
30 #include "private/ewk_certificate_private.h"
31 #include "private/ewk_console_message_private.h"
32 #include "private/ewk_context_menu_private.h"
33 #include "private/ewk_error_private.h"
34 #include "private/ewk_geolocation_private.h"
35 #include "private/ewk_policy_decision_private.h"
36 #include "private/ewk_user_media_private.h"
37
38 typedef struct EwkObject Ewk_Auth_Request;
39 typedef struct EwkObject Ewk_Download_Job;
40 typedef struct EwkObject Ewk_File_Chooser_Request;
41 typedef struct EwkObject Ewk_Form_Submission_Request;
42 typedef struct EwkObject Ewk_Navigation_Policy_Decision;
43 typedef struct _Ewk_User_Media_Permission_Request
44   Ewk_User_Media_Permission_Request;
45
46 class Ewk_Wrt_Message_Data;
47
48 namespace EWebViewCallbacks {
49
50 enum CallbackType {
51   AuthenticationRequest,
52   BackForwardListChange,
53   CancelVibration,
54   CreateNewWindow,
55   ContentsSizeChanged,
56   DownloadJobCancelled,
57   DownloadJobFailed,
58   DownloadJobFinished,
59   DownloadJobRequested,
60   FileChooserRequest,
61   NewFormSubmissionRequest,
62   FaviconChanged,
63   LoadError,
64   LoadStarted,
65   LoadFinished,
66   LoadProgress,
67   MenuBarVisible,
68   PopupBlocked,
69   ProvisionalLoadFailed,
70   ProvisionalLoadRedirect,
71   ProvisionalLoadStarted,
72   LoadCommitted,
73   StatusBarVisible,
74   NavigationPolicyDecision,
75   NewWindowPolicyDecision,
76   TextFound,
77   TitleChange,
78   ToolbarVisible,
79   TooltipTextUnset,
80   TooltipTextSet,
81   URLChanged,
82   Vibrate,
83   WebProcessCrashed,
84   WindowClosed,
85   WindowResizable,
86   EnterFullscreen,
87   ExitFullscreen,
88   UserMediaPermission,
89   IMEInputPanelShow,
90   IMEInputPanelHide,
91   IMECandidatePanelShow,
92   IMECandidatePanelHide,
93   IMEInputMethodChanged,
94   GeoLocationPermissionRequest,
95   GeoLocationValid,
96   RequestCertificateConfirm,
97   SSLCertificateChanged,
98   PolicyResponseDecide,
99   ContextMenuCustomize,
100   ContextMenuItemSelected,
101   LoadNonEmptyLayoutFinished,
102   PopupReplyWaitStart,
103   PopupReplyWaitFinish,
104   FrameRendered,
105   CreateNewBackgroundWindow,
106   EdgeLeft,
107   EdgeRight,
108   EdgeTop,
109   EdgeBottom,
110   OverscrolledLeft,
111   OverscrolledRight,
112   OverscrolledTop,
113   OverscrolledBottom,
114   TextSelectionMode,
115   SaveSessionData,
116   MagnifierShow,
117   MagnifierHide,
118   ClipboardOpened,
119   ConsoleMessage,
120   WrtPluginsMessage,
121   IconReceived,
122   FormSubmit,
123   OverflowScrollOff,
124   OverflowScrollOn,
125   TouchmoveHandled,
126   HWBackUnhandled,
127   WebloginCheckboxClicked,
128   WebloginCheckboxResume,
129   WebloginReady,
130   ZoomStarted,
131   ZoomFinished,
132 #if BUILDFLAG(IS_TIZEN)
133   NewWindowNavigationPolicyDecision,
134 #endif  // IS_TIZEN
135   URIChanged,
136   DidNotAllowScript,
137   NotificationPermissionReply,
138   FocusIn,
139   FocusOut
140 };
141
142 template <CallbackType>
143 struct CallBackInfo;
144
145 class EvasObjectHolder {
146 protected:
147   explicit EvasObjectHolder(Evas_Object* object)
148       : m_object(object)
149   {
150   }
151
152   Evas_Object* m_object;
153 };
154
155 template <CallbackType callbackType, typename ArgType = typename CallBackInfo<callbackType>::Type>
156 struct CallBack: public EvasObjectHolder {
157   explicit CallBack(Evas_Object* view) : EvasObjectHolder(view) { }
158
159   void call(ArgType argument) {
160     evas_object_smart_callback_call(m_object, CallBackInfo<callbackType>::name(), static_cast<void*>(argument));
161   }
162 };
163
164 template <CallbackType callbackType>
165 struct CallBack <callbackType, void> : public EvasObjectHolder {
166   explicit CallBack(Evas_Object* view) : EvasObjectHolder(view) { }
167
168   void call() {
169     evas_object_smart_callback_call(m_object, CallBackInfo<callbackType>::name(), 0);
170   }
171 };
172
173 template <CallbackType callbackType>
174 struct CallBack <callbackType, const char*> : public EvasObjectHolder {
175   explicit CallBack(Evas_Object* view) : EvasObjectHolder(view) { }
176
177   void call(const char* arg) {
178     evas_object_smart_callback_call(m_object, CallBackInfo<callbackType>::name(), const_cast<char*>(arg));
179   }
180 };
181
182 #define DECLARE_EWK_VIEW_CALLBACK(callbackType, string, type) \
183 template <>                                                   \
184 struct CallBackInfo<callbackType> {                           \
185   typedef type Type;                                          \
186   static inline const char* name() { return string; }         \
187 }
188
189 // Copied from WebKit as is. TODO: implement each and delete this section.
190 /*
191 DECLARE_EWK_VIEW_CALLBACK(AuthenticationRequest, "authentication,request", Ewk_Auth_Request*);
192 DECLARE_EWK_VIEW_CALLBACK(CancelVibration, "cancel,vibration", void);
193 DECLARE_EWK_VIEW_CALLBACK(DownloadJobCancelled, "download,cancelled", Ewk_Download_Job*);
194 DECLARE_EWK_VIEW_CALLBACK(DownloadJobFailed, "download,failed", Ewk_Download_Job_Error*);
195 DECLARE_EWK_VIEW_CALLBACK(DownloadJobFinished, "download,finished", Ewk_Download_Job*);
196 DECLARE_EWK_VIEW_CALLBACK(DownloadJobRequested, "download,request", Ewk_Download_Job*);
197 DECLARE_EWK_VIEW_CALLBACK(NewFormSubmissionRequest, "form,submission,request", Ewk_Form_Submission_Request*);
198 DECLARE_EWK_VIEW_CALLBACK(FaviconChanged, "favicon,changed", void);
199 DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadFailed, "load,provisional,failed", Ewk_Error*);
200 DECLARE_EWK_VIEW_CALLBACK(NavigationPolicyDecision, "policy,decision,navigation", Ewk_Navigation_Policy_Decision*);
201 DECLARE_EWK_VIEW_CALLBACK(TextFound, "text,found", unsigned*);
202 DECLARE_EWK_VIEW_CALLBACK(TooltipTextUnset, "tooltip,text,unset", void);
203 DECLARE_EWK_VIEW_CALLBACK(Vibrate, "vibrate", uint32_t*);
204 */
205
206 // Note: type 'void' means that no arguments are expected.
207
208 DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request*);
209 DECLARE_EWK_VIEW_CALLBACK(FormSubmit, "form,submit", const char*);
210 DECLARE_EWK_VIEW_CALLBACK(LoadFinished, "load,finished", void);
211 DECLARE_EWK_VIEW_CALLBACK(LoadStarted, "load,started", void);
212 DECLARE_EWK_VIEW_CALLBACK(LoadError, "load,error", _Ewk_Error*);
213 DECLARE_EWK_VIEW_CALLBACK(TitleChange, "title,changed", const char*);
214 DECLARE_EWK_VIEW_CALLBACK(URLChanged, "url,changed", const char*);
215 DECLARE_EWK_VIEW_CALLBACK(URIChanged, "uri,changed", const char*);
216 DECLARE_EWK_VIEW_CALLBACK(LoadProgress, "load,progress", double*);
217 DECLARE_EWK_VIEW_CALLBACK(TooltipTextSet, "tooltip,text,set", const char*);
218 DECLARE_EWK_VIEW_CALLBACK(EnterFullscreen, "fullscreen,enterfullscreen", void);
219 DECLARE_EWK_VIEW_CALLBACK(ExitFullscreen, "fullscreen,exitfullscreen", void);
220 DECLARE_EWK_VIEW_CALLBACK(UserMediaPermission, "usermedia,permission,request", _Ewk_User_Media_Permission_Request*);
221 DECLARE_EWK_VIEW_CALLBACK(IMEInputPanelShow, "editorclient,ime,opened", void);
222 DECLARE_EWK_VIEW_CALLBACK(IMEInputPanelHide, "editorclient,ime,closed", void);
223 DECLARE_EWK_VIEW_CALLBACK(IMECandidatePanelShow, "editorclient,candidate,opened", void);
224 DECLARE_EWK_VIEW_CALLBACK(IMECandidatePanelHide, "editorclient,candidate,closed", void);
225 DECLARE_EWK_VIEW_CALLBACK(CreateNewWindow, "create,window", Evas_Object**);
226 DECLARE_EWK_VIEW_CALLBACK(WindowClosed, "close,window", void);
227 DECLARE_EWK_VIEW_CALLBACK(IMEInputMethodChanged, "inputmethod,changed", Eina_Rectangle*);
228 DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadStarted, "load,provisional,started", void);
229 DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadRedirect, "load,provisional,redirect", void);
230 DECLARE_EWK_VIEW_CALLBACK(LoadCommitted, "load,committed", void);
231 DECLARE_EWK_VIEW_CALLBACK(GeoLocationPermissionRequest, "geolocation,permission,request", _Ewk_Geolocation_Permission_Request*);
232 DECLARE_EWK_VIEW_CALLBACK(GeoLocationValid, "geolocation,valid", Eina_Bool*);
233 DECLARE_EWK_VIEW_CALLBACK(RequestCertificateConfirm, "request,certificate,confirm", _Ewk_Certificate_Policy_Decision*);
234 DECLARE_EWK_VIEW_CALLBACK(SSLCertificateChanged, "ssl,certificate,changed", _Ewk_Certificate_Info*);
235 DECLARE_EWK_VIEW_CALLBACK(PolicyResponseDecide, "policy,response,decide", _Ewk_Policy_Decision*);
236 DECLARE_EWK_VIEW_CALLBACK(ContextMenuCustomize, "contextmenu,customize", _Ewk_Context_Menu*);
237 DECLARE_EWK_VIEW_CALLBACK(ContextMenuItemSelected, "contextmenu,selected", _Ewk_Context_Menu_Item*);
238 DECLARE_EWK_VIEW_CALLBACK(NavigationPolicyDecision, "policy,navigation,decide", _Ewk_Policy_Decision*);
239 DECLARE_EWK_VIEW_CALLBACK(TextFound, "text,found", unsigned int*);
240 DECLARE_EWK_VIEW_CALLBACK(TextSelectionMode, "textselection,mode", bool*);
241 DECLARE_EWK_VIEW_CALLBACK(NewWindowPolicyDecision, "policy,newwindow,decide", _Ewk_Policy_Decision*);
242 DECLARE_EWK_VIEW_CALLBACK(LoadNonEmptyLayoutFinished, "load,nonemptylayout,finished", void);
243 DECLARE_EWK_VIEW_CALLBACK(PopupBlocked, "popup,blocked", Eina_Stringshare*);
244 DECLARE_EWK_VIEW_CALLBACK(PopupReplyWaitStart, "popup,reply,wait,start", void*);
245 DECLARE_EWK_VIEW_CALLBACK(PopupReplyWaitFinish, "popup,reply,wait,finish", void*);
246 DECLARE_EWK_VIEW_CALLBACK(FrameRendered, "frame,rendered", void*);
247 DECLARE_EWK_VIEW_CALLBACK(CreateNewBackgroundWindow,
248                           "create,window,background",
249                           Evas_Object**);
250 DECLARE_EWK_VIEW_CALLBACK(EdgeLeft, "edge,left", void);
251 DECLARE_EWK_VIEW_CALLBACK(EdgeTop, "edge,top", void);
252 DECLARE_EWK_VIEW_CALLBACK(EdgeBottom, "edge,bottom", void);
253 DECLARE_EWK_VIEW_CALLBACK(EdgeRight, "edge,right", void);
254 DECLARE_EWK_VIEW_CALLBACK(OverscrolledLeft, "overscrolled,left", void);
255 DECLARE_EWK_VIEW_CALLBACK(OverscrolledRight, "overscrolled,right", void);
256 DECLARE_EWK_VIEW_CALLBACK(OverscrolledTop, "overscrolled,top", void);
257 DECLARE_EWK_VIEW_CALLBACK(OverscrolledBottom, "overscrolled,bottom", void);
258 DECLARE_EWK_VIEW_CALLBACK(SaveSessionData, "save,session,data", void);
259 DECLARE_EWK_VIEW_CALLBACK(MagnifierShow, "magnifier,show", void);
260 DECLARE_EWK_VIEW_CALLBACK(MagnifierHide, "magnifier,hide", void);
261 DECLARE_EWK_VIEW_CALLBACK(ClipboardOpened, "clipboard,opened", void*);
262 DECLARE_EWK_VIEW_CALLBACK(BackForwardListChange, "back,forward,list,changed", void);
263 DECLARE_EWK_VIEW_CALLBACK(WebProcessCrashed, "webprocess,crashed", bool*);
264 DECLARE_EWK_VIEW_CALLBACK(ConsoleMessage, "console,message", _Ewk_Console_Message*);
265 DECLARE_EWK_VIEW_CALLBACK(WrtPluginsMessage, "wrt,message", Ewk_Wrt_Message_Data*);
266 DECLARE_EWK_VIEW_CALLBACK(IconReceived, "icon,received", void);
267 DECLARE_EWK_VIEW_CALLBACK(OverflowScrollOff, "overflow,scroll,off", void);
268 DECLARE_EWK_VIEW_CALLBACK(OverflowScrollOn, "overflow,scroll,on", void);
269 DECLARE_EWK_VIEW_CALLBACK(TouchmoveHandled, "touchmove,handled", bool);
270 DECLARE_EWK_VIEW_CALLBACK(HWBackUnhandled, "hwback,unhandled", void);
271 DECLARE_EWK_VIEW_CALLBACK(WebloginCheckboxClicked, "weblogin,checkbox,clicked", void);
272 DECLARE_EWK_VIEW_CALLBACK(WebloginCheckboxResume, "weblogin,checkbox,resume", void);
273 DECLARE_EWK_VIEW_CALLBACK(WebloginReady, "weblogin,ready" , void);
274 DECLARE_EWK_VIEW_CALLBACK(ZoomStarted, "zoom,started", void);
275 DECLARE_EWK_VIEW_CALLBACK(ZoomFinished, "zoom,finished", void);
276 #if BUILDFLAG(IS_TIZEN)
277 DECLARE_EWK_VIEW_CALLBACK(NewWindowNavigationPolicyDecision, "policy,decision,new,window", Ewk_Navigation_Policy_Decision*);
278 #endif  // IS_TIZEN
279
280 DECLARE_EWK_VIEW_CALLBACK(ContentsSizeChanged, "contents,size,changed", void);
281 DECLARE_EWK_VIEW_CALLBACK(MenuBarVisible, "menubar,visible", bool*);
282 DECLARE_EWK_VIEW_CALLBACK(StatusBarVisible, "statusbar,visible", bool*);
283 DECLARE_EWK_VIEW_CALLBACK(ToolbarVisible, "toolbar,visible", bool*);
284 DECLARE_EWK_VIEW_CALLBACK(WindowResizable, "window,resizable", bool*);
285 DECLARE_EWK_VIEW_CALLBACK(DidNotAllowScript, "did,not,allow,script", void);
286 DECLARE_EWK_VIEW_CALLBACK(NotificationPermissionReply,
287                           "notification,permission,reply",
288                           Ewk_Notification_Permission*);
289 DECLARE_EWK_VIEW_CALLBACK(FocusOut, "webview,focus,out", void);
290 DECLARE_EWK_VIEW_CALLBACK(FocusIn, "webview,focus,in", void);
291 }
292
293 #endif