Fix for remember password feature
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / ewk_view.cpp
1 /*
2    Copyright (C) 2011 Samsung Electronics
3    Copyright (C) 2012 Intel Corporation. All rights reserved.
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #include "config.h"
22 #include "ewk_view.h"
23
24 #include "EwkViewImpl.h"
25 #include "FindClientEfl.h"
26 #include "FormClientEfl.h"
27 #include "LayerTreeCoordinatorProxy.h"
28 #include "InputMethodContextEfl.h"
29 #include "NativeWebKeyboardEvent.h"
30 #include "NativeWebMouseEvent.h"
31 #include "NativeWebWheelEvent.h"
32 #include "PageClientImpl.h"
33 #include "PageLoadClientEfl.h"
34 #include "PagePolicyClientEfl.h"
35 #include "PageUIClientEfl.h"
36 #include "ResourceLoadClientEfl.h"
37 #include "WKAPICast.h"
38 #include "WKEinaSharedString.h"
39 #include "WKFindOptions.h"
40 #include "WKRetainPtr.h"
41 #include "WKString.h"
42 #include "WebContext.h"
43 #include "WebData.h"
44 #include "WebPageGroup.h"
45 #include "WebPopupItem.h"
46 #include "WebPopupMenuProxyEfl.h"
47 #include "WebPreferences.h"
48 #include "ewk_back_forward_list_private.h"
49 #include "ewk_context.h"
50 #include "ewk_context_private.h"
51 #include "ewk_favicon_database_private.h"
52 #include "ewk_intent_private.h"
53 #include "ewk_popup_menu_item_private.h"
54 #include "ewk_private.h"
55 #include "ewk_settings_private.h"
56 #include "ewk_view_private.h"
57 #include <Ecore_Evas.h>
58 #include <Ecore_X.h>
59 #include <WebKit2/WKPageGroup.h>
60 #include <wtf/text/CString.h>
61
62 #if ENABLE(FULLSCREEN_API)
63 #include "WebFullScreenManagerProxy.h"
64 #endif
65
66 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
67 namespace EGL {
68 #include <EGL/egl.h>
69 }
70 #endif
71
72 #if OS(TIZEN)
73 #include "DrawingAreaProxyImpl.h"
74 #include "WKArray.h"
75 #include "WKData.h"
76 #include "WKDownload.h"
77 #include "WKError.h"
78 #include "WKGeolocationPermissionRequest.h"
79 #include "WKImageCairo.h"
80 #include "WKOpenPanelParameters.h"
81 #include "WKOpenPanelResultListener.h"
82 #include "WKPage.h"
83 #include "WKPageGroup.h"
84 #include "WKView.h"
85 #include "WKPageTizen.h"
86 #include "WKPreferences.h"
87 #include "WKSerializedScriptValue.h"
88 #include "WKString.h"
89 #include "WKURLRequest.h"
90 #include "ewk_context_menu_private.h"
91 #include "ewk_error.h"
92 #include "ewk_error_private.h"
93 #include "ewk_history_private.h"
94 #include "ewk_popup_menu_item.h"
95 #include "ewk_popup_menu_item_private.h"
96 #include "ewk_view_context_menu_client.h"
97 #include "ewk_view_icondatabase_client.h"
98 #include "ewk_view_tizen_client.h"
99 #include <Ecore.h>
100 #include <Elementary.h>
101 #include <WebCore/EflScreenUtilities.h>
102 #include <WebCore/NotImplemented.h>
103 #include <cairo.h>
104
105 #if ENABLE(TIZEN_ICON_DATABASE)
106 #include "WKContextPrivate.h"
107 #endif
108
109 #if ENABLE(TIZEN_GEOLOCATION)
110 #include "ewk_geolocation_private.h"
111 #include "ewk_security_origin.h"
112 #include "ewk_view_geolocation_provider.h"
113 #endif
114
115 #if ENABLE(TOUCH_EVENTS)
116 #include "NativeWebTouchEvent.h"
117 #include "WebEvent.h"
118 #endif
119
120 #if ENABLE(TIZEN_ISF_PORT)
121 #include <Ecore_IMF.h>
122 #endif
123
124 #if ENABLE(TIZEN_NOTIFICATIONS)
125 #include "WKArray.h"
126 #include "WKNotificationManager.h"
127 #include "WKNumber.h"
128 #include "ewk_notification_private.h"
129 #include "ewk_view_notification_provider.h"
130 #endif
131
132 #if ENABLE(TIZEN_MEDIA_STREAM)
133 #include "WKUserMediaPermissionRequest.h"
134 #include "ewk_user_media_private.h"
135 #endif
136
137 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
138 #include "WebPageGroup.h"
139 #include "WebPreferences.h"
140 #endif
141
142 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
143 #include "ewk_hit_test_private.h"
144 #endif
145
146 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
147 #include "ewk_text_style.h"
148 #endif
149
150 #if ENABLE(TIZEN_SCREEN_READER)
151 #include "ScreenReaderProxy.h"
152 #endif
153
154 #if ENABLE(TIZEN_CSP)
155 #include <WebCore/ContentSecurityPolicy.h>
156 #endif
157
158 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
159 #include "WKDictionary.h"
160 #include "ewk_web_application_icon_data_private.h"
161 #endif
162 #endif // #if OS(TIZEN)
163
164 using namespace WebKit;
165 using namespace WebCore;
166
167 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
168
169 #define EWK_VIEW_TYPE_CHECK(ewkView, result)                                   \
170     bool result = true;                                                        \
171     do {                                                                       \
172         if (!ewkView) {                                                        \
173             EINA_LOG_CRIT("null is not a ewk_view");                           \
174             result = false;                                                    \
175             break;                                                             \
176         }                                                                      \
177         const char* _tmp_otype = evas_object_type_get(ewkView);                \
178         const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView);       \
179         if (EINA_UNLIKELY(!_tmp_s)) {                                          \
180             EINA_LOG_CRIT                                                      \
181                 ("%p (%s) is not a smart object!",                             \
182                  ewkView, _tmp_otype ? _tmp_otype : "(null)");                 \
183             result = false;                                                    \
184             break;                                                             \
185         }                                                                      \
186         const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s);        \
187         if (EINA_UNLIKELY(!_tmp_sc)) {                                         \
188             EINA_LOG_CRIT                                                      \
189                 ("%p (%s) is not a smart object!",                             \
190                  ewkView, _tmp_otype ? _tmp_otype : "(null)");                 \
191             result = false;                                                    \
192             break;                                                             \
193         }                                                                      \
194         else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) {               \
195             EINA_LOG_CRIT                                                      \
196                 ("%p (%s) is not of an ewk_view (need %p, got %p)!",           \
197                  ewkView, _tmp_otype ? _tmp_otype : "(null)",                  \
198                  EWK_VIEW_TYPE_STR, _tmp_sc->data);                            \
199             result = false;                                                    \
200         }                                                                      \
201     } while (0)
202
203 #define EWK_VIEW_SD_GET(ewkView, smartData)                                    \
204     EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result);                                 \
205     Ewk_View_Smart_Data* smartData = 0;                                        \
206     if (_tmp_result)                                                           \
207         smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView)
208
209 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...)                     \
210     EWK_VIEW_SD_GET(ewkView, smartData);                                       \
211     do {                                                                       \
212         if (!smartData) {                                                      \
213             EINA_LOG_CRIT("no smart data for object %p (%s)",                  \
214                      ewkView, evas_object_type_get(ewkView));                  \
215             return __VA_ARGS__;                                                \
216         }                                                                      \
217     } while (0)
218
219 #if OS(TIZEN)
220 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
221 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
222 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
223 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
224 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
225 #endif
226 static Eina_Bool _ewk_view_default_open_panel(Evas_Object*, Eina_Bool allow_multiple_files, Eina_List *accepted_mime_types, const char* capture, void* userData);
227
228 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
229 Eina_Bool _ewk_view_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items, int selectedIndex);
230 #if ENABLE(TIZEN_MULTIPLE_SELECT)
231 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
232 #endif
233 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
234 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
235 #endif
236 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
237 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
238 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
239 #endif
240
241 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
242 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
243 #endif
244
245 #if ENABLE(TIZEN_DATALIST_ELEMENT)
246 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
247 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
248 #endif
249
250 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
251 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
252 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
253 #endif
254 #endif // #if OS(TIZEN)
255
256 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
257 {
258     if (smartData->changed.any)
259         return;
260     smartData->changed.any = true;
261     evas_object_smart_changed(smartData->self);
262 }
263
264 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
265 {
266     Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
267     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
268     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
269
270     const char* viewURL = ewk_view_url_get(ewkView);
271     if (!viewURL || strcasecmp(viewURL, pageURL))
272         return;
273
274     impl->informIconChange();
275 }
276
277 // Default Event Handling.
278 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
279 {
280     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
281     TIZEN_LOGI("");
282
283 #if OS(TIZEN)
284     impl->pageClient->setViewFocused(true);
285 #endif // #if OS(TIZEN)
286     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
287 #if ENABLE(TIZEN_ISF_PORT)
288     if (impl->inputMethodContext())
289         impl->inputMethodContext()->onFocusIn();
290 #endif
291     return true;
292 }
293
294 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
295 {
296     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
297     TIZEN_LOGI("");
298
299 #if OS(TIZEN)
300 #if ENABLE(TIZEN_ISF_PORT)
301     // Keypad should be hidden rapidly when moving focus on elementary
302     // because Ecore-ime doesn't support it.
303     if (impl->inputMethodContext())
304         impl->inputMethodContext()->onFocusOut();
305 #endif
306
307 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
308     if (impl->pageClient->isTextSelectionMode())
309         impl->pageClient->setIsTextSelectionMode(false);
310 #endif
311
312 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
313     if (impl->pageClient->isContextMenuVisible())
314         impl->pageProxy->hideContextMenu();
315 #endif
316
317 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
318     if (impl->pageClient->isClipboardWindowOpened())
319         impl->pageClient->closeClipboardWindow();
320 #endif
321
322 #if ENABLE(TIZEN_DRAG_SUPPORT)
323     if (impl->pageClient->isDragMode())
324         impl->pageClient->setDragMode(false);
325 #endif
326
327 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
328     if (smartData->api->formdata_candidate_is_showing(smartData))
329         smartData->api->formdata_candidate_hide(smartData);
330 #endif
331
332     impl->pageClient->setViewFocused(false);
333 #endif // #if OS(TIZEN)
334     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
335     return true;
336 }
337
338 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
339 {
340     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
341
342     impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
343     return true;
344 }
345
346 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
347 {
348     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
349
350     impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
351     return true;
352 }
353
354 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
355 {
356     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
357
358     impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
359
360     InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
361     if (inputMethodContext)
362         inputMethodContext->handleMouseUpEvent(upEvent);
363
364     return true;
365 }
366
367 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
368 {
369     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
370
371     // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
372     impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
373     return true;
374 }
375
376 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
377 {
378     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
379
380     bool isFiltered = false;
381     InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
382     if (inputMethodContext)
383         inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
384
385     impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
386     return true;
387 }
388
389 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
390 {
391     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
392
393     impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
394     return true;
395 }
396
397 #if OS(TIZEN)
398 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
399 {
400 #if ENABLE(TIZEN_GESTURE)
401     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
402
403 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
404     if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
405         return true;
406 #endif
407
408 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
409     if (impl->focusRing) {
410         if (event->type == EWK_GESTURE_TAP && event->count == 1) {
411             impl->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
412         } else if (event->type == EWK_GESTURE_PAN) {
413             if (impl->exceedTouchMoveThreshold)
414                 impl->focusRing->hide();
415         } else {
416             if (event->type != EWK_GESTURE_LONG_PRESS) {
417 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
418                 if (!impl->pageClient->isContextMenuVisible())
419 #endif
420                     impl->focusRing->hide();
421             }
422         }
423     }
424 #endif
425
426 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
427     if (smartData->api->formdata_candidate_is_showing(smartData))
428         smartData->api->formdata_candidate_hide(smartData);
429 #endif
430
431     switch (event->type) {
432     case EWK_GESTURE_TAP:
433         impl->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
434         break;
435     case EWK_GESTURE_LONG_PRESS: {
436 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
437 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
438         if (ewk_settings_text_selection_enabled_get(impl->settings()))
439             impl->pageClient->setIsTextSelectionMode(false);
440 #endif
441         IntPoint scenePoint(event->position.x, event->position.y);
442         IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
443         WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(contentsPoint);
444 #if ENABLE(TIZEN_DRAG_SUPPORT)
445         // 1. Check to start dragging.
446         if (hitTestResultData.isDragSupport) {
447             impl->pageClient->setDragPoint(scenePoint);
448 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
449             if (impl->focusRing)
450                 impl->focusRing->show(IntRect(), true);
451 #endif
452             impl->gestureClient->showContextMenu(scenePoint);
453             break;
454         }
455 #endif
456         // 2. Check to show context menu.
457         if (!hitTestResultData.absoluteImageURL.isEmpty()
458             || !hitTestResultData.absoluteLinkURL.isEmpty()
459             || !hitTestResultData.absoluteMediaURL.isEmpty()) {
460 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
461             if (impl->focusRing)
462                 impl->focusRing->show(IntRect(), true);
463 #endif
464             impl->gestureClient->showContextMenu(scenePoint);
465             break;
466         }
467 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
468         // 3. Check for text selection.
469         if (ewk_settings_text_selection_enabled_get(impl->settings())) {
470             // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
471             if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
472                 if (smartData->api && smartData->api->gesture_end) {
473                     Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
474                     smartData->api->gesture_end(smartData, &tapEvent);
475                 }
476             }
477
478             if (impl->pageClient->textSelectionDown(scenePoint)) {
479                 impl->gestureClient->setGestureEnabled(false);
480                 impl->feedTouchEventsByType(EWK_TOUCH_CANCEL);
481             }
482         }
483 #endif
484         break;
485 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
486     }
487     case EWK_GESTURE_PAN:
488         impl->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
489         break;
490     case EWK_GESTURE_FLICK:
491         impl->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
492         break;
493     case EWK_GESTURE_PINCH:
494         if (impl->pageClient->viewportConstraints().userScalable)
495             impl->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
496         break;
497     default:
498         ASSERT_NOT_REACHED();
499         break;
500     }
501
502     return true;
503 #else
504     return false;
505 #endif // #if ENABLE(TIZEN_GESTURE)
506 }
507
508 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
509 {
510 #if ENABLE(TIZEN_GESTURE)
511     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
512
513 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
514     if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
515         return true;
516 #endif
517
518 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
519     if (impl->focusRing) {
520 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
521         if (!impl->pageClient->isContextMenuVisible())
522 #endif
523             impl->focusRing->hide();
524     }
525 #endif
526
527     switch (event->type) {
528     case EWK_GESTURE_TAP:
529         if (event->count == 1) {
530 #if ENABLE(TIZEN_DRAG_SUPPORT)
531         if (impl->pageClient->isDragMode())
532             impl->pageClient->setDragMode(false);
533 #endif
534 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
535             if (impl->pageClient->isTextSelectionMode())
536                 impl->pageClient->setIsTextSelectionMode(false);
537 #endif
538             impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
539 #if ENABLE(TIZEN_ISF_PORT)
540             evas_object_focus_set(smartData->self, true);
541 #endif
542         } else if (event->count == 2)
543             impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
544         break;
545     case EWK_GESTURE_LONG_PRESS:
546 #if ENABLE(TIZEN_DRAG_SUPPORT)
547         if (impl->pageClient->isDragMode())
548             impl->pageClient->setDragMode(false);
549 #endif
550         // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
551         impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
552         break;
553     case EWK_GESTURE_PAN:
554         impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
555         break;
556     case EWK_GESTURE_FLICK:
557         impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
558         break;
559     case EWK_GESTURE_PINCH:
560         impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
561         break;
562     default:
563         ASSERT_NOT_REACHED();
564         break;
565     }
566
567     return true;
568 #else
569     return false;
570 #endif // #if ENABLE(TIZEN_GESTURE)
571 }
572
573 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
574 {
575 #if ENABLE(TIZEN_GESTURE)
576     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
577
578 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
579     if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
580         return true;
581 #endif
582
583 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
584     if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold))
585         impl->focusRing->hide();
586 #endif
587
588     switch (event->type) {
589     case EWK_GESTURE_PAN:
590         impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
591         break;
592     case EWK_GESTURE_TAP:
593     case EWK_GESTURE_LONG_PRESS:
594     case EWK_GESTURE_FLICK:
595         break;
596     case EWK_GESTURE_PINCH:
597         if (impl->pageClient->viewportConstraints().userScalable)
598             impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
599         break;
600     default:
601         ASSERT_NOT_REACHED();
602         break;
603     }
604
605     return true;
606 #else
607     return false;
608 #endif // #if ENABLE(TIZEN_GESTURE)
609 }
610 #endif //#if OS(TIZEN)
611
612 // Event Handling.
613 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
614 {
615     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
616     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
617     EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
618     smartData->api->focus_in(smartData);
619 }
620
621 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
622 {
623     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
624     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
625     EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
626     smartData->api->focus_out(smartData);
627 }
628
629 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
630 {
631     Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
632     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
633     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
634     EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
635     smartData->api->mouse_wheel(smartData, wheelEvent);
636 }
637
638 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
639 {
640     Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
641     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
642     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
643     EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
644     smartData->api->key_down(smartData, downEvent);
645 }
646
647 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
648 {
649     Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
650     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
651     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
652     EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
653     smartData->api->key_up(smartData, upEvent);
654 }
655
656 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
657 {
658     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
659     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
660     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
661 }
662
663 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
664 {
665     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
666     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
667
668     // This call may look wrong, but we really need to pass ViewIsVisible here.
669     // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
670     // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
671     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
672 }
673
674 #if OS(TIZEN)
675 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
676 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
677 {
678     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
679
680     return impl->pageClient->textSelectionDown(IntPoint(x, y), true);
681 }
682
683 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
684 {
685     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
686
687     IntPoint point(x, y);
688     impl->pageClient->textSelectionMove(point, true);
689
690     return true;
691 }
692
693 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
694 {
695     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
696
697     IntPoint point(x, y);
698     impl->pageClient->textSelectionUp(point, true);
699
700     return true;
701 }
702 #endif
703
704 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
705 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
706 {
707     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
708
709     impl->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
710
711     return true;
712 }
713
714 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
715 {
716     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
717
718     impl->pageClient->hideFormDataCandidate();
719
720     return true;
721 }
722
723 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
724 {
725     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
726
727     Vector<String> formData;
728     Eina_List* list;
729     void* data;
730     EINA_LIST_FOREACH(dataList, list, data)
731         formData.append(String::fromUTF8(static_cast<char*>(data)));
732
733     impl->pageClient->updateFormDataCandidate(formData);
734
735     return true;
736 }
737
738 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
739 {
740     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
741
742     return impl->pageClient->isShowingFormDataCandidate();
743 }
744 #endif
745
746 #if ENABLE(TIZEN_SCREEN_READER)
747 Eina_Bool _ewk_view_screen_reader_command_execute(Ewk_View_Smart_Data* smartData, unsigned int command, int data1, int data2)
748 {
749     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
750
751     return ScreenReaderProxy::screenReader().executeCommand(impl, command, data1, data2);
752 }
753 #endif
754 #endif // #if OS(TIZEN)
755
756 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
757
758 static void _ewk_view_impl_del(EwkViewImpl* impl)
759 {
760     /* Unregister icon change callback */
761     Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
762     iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
763
764     delete impl;
765 }
766
767 static void _ewk_view_smart_add(Evas_Object* ewkView)
768 {
769     const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
770     const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
771     const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
772     EWK_VIEW_SD_GET(ewkView, smartData);
773
774     if (!smartData) {
775         smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
776         if (!smartData) {
777             EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
778             return;
779         }
780         evas_object_smart_data_set(ewkView, smartData);
781     }
782
783     smartData->self = ewkView;
784     smartData->api = api;
785
786     g_parentSmartClass.add(ewkView);
787
788     smartData->priv = new EwkViewImpl(ewkView);
789     if (!smartData->priv) {
790         EINA_LOG_CRIT("could not allocate EwkViewImpl");
791         evas_object_smart_data_set(ewkView, 0);
792         free(smartData);
793         return;
794     }
795
796     // Create evas_object_image to draw web contents.
797     smartData->image = evas_object_image_add(smartData->base.evas);
798     evas_object_image_alpha_set(smartData->image, false);
799     evas_object_image_filled_set(smartData->image, true);
800     evas_object_smart_member_add(smartData->image, ewkView);
801
802 #if OS(TIZEN)
803 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
804     Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
805     const char *engine = ecore_evas_engine_name_get(ee);
806     if (engine && !strcmp(engine, "opengl_x11"))
807         evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
808 #endif
809     ewk_view_mouse_events_enabled_set(ewkView, false);
810     ewk_view_touch_events_enabled_set(ewkView, true);
811
812     // FIXME: This code should be removed if side effect occur.
813     // WebView does not have focus after url loading.
814     // If focus is set as true to webview,
815     // elementary steal webview's focus during mouse up event
816     // So, added code that events are not propagated to smart parent according to guide from EFL
817     evas_object_propagate_events_set(ewkView, false);
818
819 #if ENABLE(TIZEN_SCREEN_READER)
820     ScreenReaderProxy::screenReader().addView(smartData->priv);
821 #endif
822 #endif // #if OS(TIZEN)
823
824 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
825     CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
826     CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
827     CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
828     CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
829     CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
830     CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
831     CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
832 #undef CONNECT
833 }
834
835 static void _ewk_view_smart_del(Evas_Object* ewkView)
836 {
837     EwkViewImpl::removeFromPageViewMap(ewkView);
838     EWK_VIEW_SD_GET(ewkView, smartData);
839 #if ENABLE(TIZEN_SCREEN_READER)
840     ScreenReaderProxy::screenReader().removeView(smartData->priv);
841 #endif
842     if (smartData && smartData->priv)
843         _ewk_view_impl_del(smartData->priv);
844
845     g_parentSmartClass.del(ewkView);
846 }
847
848 static Eina_Bool _ewk_view_composite(void* data);
849
850 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
851 {
852     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
853
854     evas_object_resize(smartData->image, width, height);
855     evas_object_image_size_set(smartData->image, width, height);
856     evas_object_image_fill_set(smartData->image, 0, 0, width, height);
857 #if OS(TIZEN)
858     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
859 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
860     evas_object_image_native_surface_set(smartData->image, 0);
861
862 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
863     if (!ewk_view_is_opengl_backend(ewkView))
864         _ewk_view_composite(smartData);
865     else // OpenGL backend
866 #endif
867     impl->pageClient->displayViewport();
868 #endif
869 #endif // #if OS(TIZEN)
870
871     smartData->changed.size = true;
872     _ewk_view_smart_changed(smartData);
873 }
874
875 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
876 {
877     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
878
879     smartData->changed.position = true;
880     _ewk_view_smart_changed(smartData);
881 }
882
883 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
884 {
885     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
886     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
887
888     Evas_Coord x, y, width, height;
889
890     smartData->changed.any = false;
891
892     evas_object_geometry_get(ewkView, &x, &y, &width, &height);
893
894     if (smartData->changed.size) {
895 #if !OS(TIZEN)
896 #if USE(COORDINATED_GRAPHICS)
897         impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
898 #endif
899 #if USE(ACCELERATED_COMPOSITING)
900         needsNewSurface = impl->evasGlSurface;
901 #endif
902
903         if (impl->pageProxy->drawingArea())
904             impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
905
906 #if USE(ACCELERATED_COMPOSITING)
907         if (!impl->evasGlSurface)
908             return;
909         evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
910         impl->evasGlSurface = 0;
911         ewk_view_create_gl_surface(ewkView, IntSize(width, height));
912         ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
913 #endif
914 #endif // #if !OS(TIZEN)
915
916         smartData->view.w = width;
917         smartData->view.h = height;
918         smartData->changed.size = false;
919
920 #if OS(TIZEN)
921         if (impl->pageClient) {
922             if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
923 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
924                 if (impl->pageProxy->isViewVisible())
925                     drawingArea->setSize(IntSize(width, height), IntSize());
926 #else
927                 drawingArea->setSize(IntSize(width, height), IntSize());
928 #endif
929 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
930                 impl->pageClient->updateViewportSize(IntSize(width, height));
931                 if (ewk_view_is_opengl_backend(ewkView))
932                     impl->pageClient->displayViewport();
933 #endif
934             }
935 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
936             impl->pageClient->frameRectChanged();
937 #endif
938         }
939 #endif // #if OS(TIZEN)
940     }
941
942     if (smartData->changed.position) {
943         evas_object_move(smartData->image, x, y);
944         smartData->view.x = x;
945         smartData->view.y = y;
946         smartData->changed.position = false;
947 #if OS(TIZEN)
948 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
949         impl->pageClient->frameRectChanged();
950 #endif
951 #if ENABLE(TIZEN_SCREEN_READER)
952         impl->pageProxy->recalcScreenReaderFocusRect();
953 #endif
954 #endif // #if OS(TIZEN)
955     }
956 #if OS(TIZEN)
957     if (impl->popupPicker)
958         ewk_popup_picker_resize(impl->popupPicker);
959 #endif // #if OS(TIZEN)
960 }
961
962 static void _ewk_view_smart_show(Evas_Object* ewkView)
963 {
964     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
965     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
966
967     if (evas_object_clipees_get(smartData->base.clipper))
968         evas_object_show(smartData->base.clipper);
969     evas_object_show(smartData->image);
970 }
971
972 static void _ewk_view_smart_hide(Evas_Object* ewkView)
973 {
974     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
975
976     evas_object_hide(smartData->base.clipper);
977     evas_object_hide(smartData->image);
978 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
979     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
980     if (impl->pageClient->isTextSelectionMode())
981         impl->pageClient->setIsTextSelectionMode(false);
982 #endif
983 }
984
985 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
986 {
987     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
988     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
989
990     if (alpha < 0)
991         alpha = 0;
992     else if (alpha > 255)
993         alpha = 255;
994
995 #define CHECK_COLOR(color, alpha) \
996     if (color < 0)                \
997         color = 0;                \
998     else if (color > alpha)       \
999         color = alpha;
1000     CHECK_COLOR(red, alpha);
1001     CHECK_COLOR(green, alpha);
1002     CHECK_COLOR(blue, alpha);
1003 #undef CHECK_COLOR
1004
1005     evas_object_image_alpha_set(smartData->image, alpha < 255);
1006     impl->pageProxy->setDrawsBackground(red || green || blue);
1007     impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1008     impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1009
1010 #if !OS(TIZEN)
1011     g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1012 #endif
1013 }
1014
1015 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1016 {
1017     EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1018
1019     if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1020         EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1021              api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1022         return false;
1023     }
1024
1025     if (EINA_UNLIKELY(!g_parentSmartClass.add))
1026         evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1027
1028     evas_object_smart_clipped_smart_set(&api->sc);
1029
1030     // Set Evas_Smart_Class functions.
1031     api->sc.add = _ewk_view_smart_add;
1032     api->sc.del = _ewk_view_smart_del;
1033     api->sc.move = _ewk_view_smart_move;
1034     api->sc.resize = _ewk_view_smart_resize;
1035     api->sc.show = _ewk_view_smart_show;
1036     api->sc.hide = _ewk_view_smart_hide;
1037     api->sc.color_set = _ewk_view_smart_color_set;
1038     api->sc.calculate = _ewk_view_smart_calculate;
1039     api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1040
1041     // Set Ewk_View_Smart_Class functions.
1042     api->focus_in = _ewk_view_smart_focus_in;
1043     api->focus_out = _ewk_view_smart_focus_out;
1044     api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1045     api->mouse_down = _ewk_view_smart_mouse_down;
1046     api->mouse_up = _ewk_view_smart_mouse_up;
1047     api->mouse_move = _ewk_view_smart_mouse_move;
1048     api->key_down = _ewk_view_smart_key_down;
1049     api->key_up = _ewk_view_smart_key_up;
1050 #if OS(TIZEN)
1051     api->gesture_start = _ewk_view_smart_gesture_start;
1052     api->gesture_end = _ewk_view_smart_gesture_end;
1053     api->gesture_move = _ewk_view_smart_gesture_move;
1054
1055 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1056     api->popup_menu_show = _ewk_view_popup_menu_show;
1057 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1058     api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1059 #endif
1060     api->popup_menu_hide = _ewk_view_popup_menu_hide;
1061     api->popup_menu_update = _ewk_view_popup_menu_update;
1062 #endif
1063 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1064     api->text_selection_down = _ewk_view_text_selection_down;
1065     api->text_selection_move = _ewk_view_text_selection_move;
1066     api->text_selection_up = _ewk_view_text_selection_up;
1067 #endif
1068 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1069     api->input_picker_show = _ewk_view_input_picker_show;
1070 #endif
1071 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1072     api->data_list_show = _ewk_view_data_list_show;
1073     api->data_list_hide = _ewk_view_data_list_hide;
1074 #endif
1075 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1076     api->orientation_lock = _ewk_orientation_lock;
1077     api->orientation_unlock = _ewk_orientation_unlock;
1078 #endif
1079 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1080     api->input_picker_color_request = _ewk_input_picker_color_request;
1081     api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1082 #endif
1083 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1084     api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1085     api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1086     api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1087     api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1088 #endif
1089 #if ENABLE(TIZEN_SCREEN_READER)
1090     api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1091 #endif
1092 #endif //#if OS(TIZEN)
1093
1094     return true;
1095 }
1096
1097 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1098 {
1099     static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1100     static Evas_Smart* smart = 0;
1101
1102     if (EINA_UNLIKELY(!smart)) {
1103         ewk_view_smart_class_set(&api);
1104         smart = evas_smart_class_new(&api.sc);
1105     }
1106
1107     return smart;
1108 }
1109
1110 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1111 {
1112     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1113     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1114     EINA_SAFETY_ON_NULL_RETURN(context);
1115
1116     if (impl->pageClient)
1117         return;
1118
1119 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1120     bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1121     if (isOpenGL)
1122         impl->pageClient = PageClientEvasGL::create(impl);
1123     else
1124         impl->pageClient = PageClientImpl::create(impl);
1125 #else
1126     impl->pageClient = PageClientImpl::create(impl);
1127 #endif
1128
1129     if (pageGroupRef)
1130         impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1131     else
1132         impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1133
1134     EwkViewImpl::addToPageViewMap(ewkView);
1135
1136 #if OS(TIZEN)
1137     impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1138     impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1139     impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1140     impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1141
1142     int deviceWidth, deviceHeight;
1143     ecore_evas_screen_geometry_get(ecore_evas_ecore_evas_get(evas_object_evas_get(ewkView)), 0, 0, &deviceWidth, &deviceHeight);
1144     impl->pageProxy->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
1145     impl->pageProxy->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
1146 #endif
1147
1148     impl->pageProxy->initializeWebPage();
1149
1150 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1151     impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1152 #else
1153     impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1154 #endif
1155
1156 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1157     impl->pageProxy->setUseFixedLayout(true);
1158 #endif
1159 #if ENABLE(FULLSCREEN_API)
1160     impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1161 #endif
1162
1163 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1164     if (isOpenGL)
1165         impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1166     else {
1167         impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1168         impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1169         impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1170     }
1171 #endif
1172
1173     impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1174
1175     impl->context = context;
1176
1177 #if OS(TIZEN)
1178     ewkViewContextMenuClientAttachClient(ewkView);
1179     ewkViewTizenClientAttachClient(ewkView);
1180
1181 #if ENABLE(TIZEN_GEOLOCATION)
1182     ewkViewGeolocationProviderAttachProvider(ewkView, impl->context->wkContext());
1183 #endif
1184
1185 #if ENABLE(TIZEN_NOTIFICATIONS)
1186     ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1187 #endif
1188
1189 #if ENABLE(TIZEN_ICON_DATABASE)
1190     ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1191 #endif
1192
1193     ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1194     ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1195     ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1196 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1197     ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1198 #endif
1199     ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1200 #else // #if OS(TIZEN)
1201 #if USE(COORDINATED_GRAPHICS)
1202     impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1203 #endif
1204 #endif // #if OS(TIZEN)
1205
1206 #if ENABLE(FULLSCREEN_API)
1207     impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1208     impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1209 #endif
1210
1211     // Initialize page clients.
1212     impl->pageLoadClient = PageLoadClientEfl::create(impl);
1213     impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1214     impl->pageUIClient = PageUIClientEfl::create(impl);
1215     impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1216     impl->findClient = FindClientEfl::create(impl);
1217     impl->formClient = FormClientEfl::create(impl);
1218
1219     /* Listen for favicon changes */
1220     Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1221     iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1222
1223 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1224     ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1225 #endif
1226
1227 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1228     if (!impl->context->xWindow())
1229         impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1230 #endif
1231
1232 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1233     impl->focusRing = FocusRing::create(impl);
1234 #endif
1235 }
1236
1237 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1238 {
1239     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1240     EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1241
1242 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1243     {
1244         using namespace EGL;
1245         if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1246             EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1247             return 0;
1248         }
1249     }
1250 #endif
1251
1252     Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1253     if (!ewkView)
1254         return 0;
1255
1256     EWK_VIEW_SD_GET(ewkView, smartData);
1257     if (!smartData) {
1258         evas_object_del(ewkView);
1259         return 0;
1260     }
1261
1262     EWK_VIEW_IMPL_GET(smartData, impl);
1263     if (!impl) {
1264         evas_object_del(ewkView);
1265         return 0;
1266     }
1267
1268     return ewkView;
1269 }
1270
1271 /**
1272  * @internal
1273  * Constructs a ewk_view Evas_Object with WKType parameters.
1274  */
1275 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1276 {
1277     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1278     EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1279
1280     Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1281     if (!ewkView)
1282         return 0;
1283
1284     _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1285
1286     return ewkView;
1287 }
1288
1289 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1290 {
1291     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1292     EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1293     EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1294
1295     Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1296     if (!ewkView)
1297         return 0;
1298
1299 #if ENABLE(TIZEN_ICON_DATABASE)
1300     //set default iconDatabasePath
1301     WKContextRef contextRef = context->wkContext();
1302     toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1303 #endif
1304
1305 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1306     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1307     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1308     _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1309 #else
1310     _ewk_view_initialize(ewkView, context, 0);
1311 #endif
1312
1313     return ewkView;
1314 }
1315
1316 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1317 {
1318     EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1319     return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1320 }
1321
1322 Evas_Object* ewk_view_add(Evas* canvas)
1323 {
1324     return ewk_view_add_with_context(canvas, ewk_context_default_get());
1325 }
1326
1327 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1328 {
1329     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1330     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1331
1332     return impl->ewkContext();
1333 }
1334
1335 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1336 {
1337     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1338     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1339     EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1340
1341     impl->pageProxy->loadURL(url);
1342     impl->informURLChange();
1343
1344     return true;
1345 }
1346
1347 const char* ewk_view_url_get(const Evas_Object* ewkView)
1348 {
1349     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1350     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1351
1352     return impl->url();
1353 }
1354
1355 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1356 {
1357     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1358     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1359
1360     return impl->faviconURL();
1361 }
1362
1363 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1364 {
1365     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1366     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1367
1368     impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1369     impl->informURLChange();
1370
1371     return true;
1372 }
1373
1374 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1375 {
1376     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1377     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1378
1379     impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1380     impl->informURLChange();
1381
1382     return true;
1383 }
1384
1385 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1386 {
1387     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1388     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1389
1390     impl->pageProxy->stopLoading();
1391
1392     return true;
1393 }
1394
1395 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1396 {
1397     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1398     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1399
1400     return impl->settings();
1401 }
1402
1403 const char* ewk_view_title_get(const Evas_Object* ewkView)
1404 {
1405     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1406     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1407
1408     return impl->title();
1409 }
1410
1411 /**
1412  * @internal
1413  * Reports that the requested text was found.
1414  *
1415  * Emits signal: "text,found" with the number of matches.
1416  */
1417 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1418 {
1419     evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1420 }
1421
1422 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1423 {
1424     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1425     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1426
1427     return impl->pageProxy->estimatedProgress();
1428 }
1429
1430 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1431 {
1432     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1433     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1434
1435 #if OS(TIZEN)
1436     // FIXME
1437     int centerX = x;
1438     int centerY = y;
1439     scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1440
1441     IntPoint scrollPosition = impl->pageClient->scrollPosition();
1442     double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1443     int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1444     int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1445
1446     impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1447 #else
1448     impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1449 #endif
1450     return true;
1451 }
1452
1453 double ewk_view_scale_get(const Evas_Object* ewkView)
1454 {
1455     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1456     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1457
1458 #if OS(TIZEN)
1459     return impl->pageProxy->scaleFactor();
1460 #else
1461     return impl->pageProxy->pageScaleFactor();
1462 #endif
1463 }
1464
1465 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1466 {
1467     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1468     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1469
1470     impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1471
1472     return true;
1473 }
1474
1475 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1476 {
1477     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1478     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1479
1480     return impl->pageProxy->deviceScaleFactor();
1481 }
1482
1483 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1484 {
1485     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1486     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1487
1488     impl->setThemePath(path);
1489 }
1490
1491 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1492 {
1493     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1494     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1495
1496     return impl->themePath();
1497 }
1498
1499 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1500 {
1501     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1502     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1503
1504     WebPageProxy* page = impl->pageProxy.get();
1505     if (page->canGoBack()) {
1506         page->goBack();
1507         return true;
1508     }
1509
1510     return false;
1511 }
1512
1513 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1514 {
1515     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1516     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1517
1518     WebPageProxy* page = impl->pageProxy.get();
1519     if (page->canGoForward()) {
1520         page->goForward();
1521         return true;
1522     }
1523
1524     return false;
1525 }
1526
1527 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1528 {
1529 #if ENABLE(WEB_INTENTS)
1530     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1531     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1532     EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1533
1534     WebPageProxy* page = impl->pageProxy.get();
1535     page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1536
1537     return true;
1538 #else
1539     return false;
1540 #endif
1541 }
1542
1543 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1544 {
1545     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1546     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1547
1548     return impl->pageProxy->canGoBack();
1549 }
1550
1551 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1552 {
1553     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1554     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1555
1556     return impl->pageProxy->canGoForward();
1557 }
1558
1559 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1560 {
1561     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1562     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1563
1564     return impl->backForwardList.get();
1565 }
1566
1567 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1568 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1569 {
1570     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1571     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1572
1573     if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1574         return;
1575
1576     InputMethodContextEfl* imfContext = impl->inputMethodContext();
1577     if (!imfContext || !imfContext->isShow())
1578         return;
1579
1580     if (value.isEmpty()) {
1581         if(smartData->api->formdata_candidate_is_showing(smartData))
1582             smartData->api->formdata_candidate_hide(smartData);
1583         return;
1584     }
1585
1586     Vector<String> popupCandidates;
1587     ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1588     std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1589
1590     Eina_List* candidateList = 0;
1591     for (size_t i = 0; i < popupCandidates.size(); ++i) {
1592         if (popupCandidates[i].startsWith(value, false))
1593             candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1594     }
1595
1596     if (!eina_list_count(candidateList)) {
1597         if(smartData->api->formdata_candidate_is_showing(smartData))
1598             smartData->api->formdata_candidate_hide(smartData);
1599         return;
1600     }
1601
1602     smartData->api->formdata_candidate_update_data(smartData, candidateList);
1603
1604     if (!smartData->api->formdata_candidate_is_showing(smartData))
1605         smartData->api->formdata_candidate_hide(smartData);
1606
1607     IntRect inputFieldRect = impl->pageClient->focusedNodeRect();
1608     smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1609 }
1610
1611 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
1612 {
1613     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1614     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1615     if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1616         && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1617         return;
1618     ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1619 }
1620
1621 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1622 {
1623     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1624     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1625
1626     if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1627         return;
1628
1629     Vector<std::pair<String, String> > passwordFormData;
1630     ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1631
1632     if (!passwordFormData.size())
1633         return;
1634
1635     String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
1636     for (size_t i = 0; i < passwordFormData.size(); i++) {
1637         passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
1638             " for (var i = 0; i < inputFields.length; i++)"
1639             " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\"))"
1640             " inputFields[i].value = \"%s\";",
1641             passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
1642     }
1643     passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
1644     ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1645 }
1646
1647 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1648 {
1649     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1650     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1651     ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1652 }
1653 #endif
1654
1655 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1656 {
1657     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1658     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1659     EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1660
1661     if (unreachableUrl && *unreachableUrl)
1662         impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1663     else
1664         impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1665
1666     impl->informURLChange();
1667
1668     return true;
1669 }
1670
1671 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1672 {
1673     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1674     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1675
1676     return impl->customTextEncodingName();
1677 }
1678
1679 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1680 {
1681     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1682     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1683
1684     impl->setCustomTextEncodingName(encoding);
1685
1686     return true;
1687 }
1688
1689 #if OS(TIZEN)
1690 // FIXME: It should be removed.
1691 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1692 {
1693     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1694     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1695
1696     return toAPI(impl->pageProxy.get());
1697 }
1698
1699 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1700 {
1701     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1702     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1703
1704     impl->setMouseEventsEnabled(!!enabled);
1705
1706     return true;
1707 }
1708
1709 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1710 {
1711     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1712     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1713
1714     return impl->mouseEventsEnabled();
1715 }
1716
1717 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1718 {
1719 #if ENABLE(INPUT_TYPE_COLOR)
1720     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1721     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1722
1723     return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1724 #else
1725     return false;
1726 #endif
1727 }
1728
1729 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1730 {
1731     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1732     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1733
1734     return impl->javascriptPopup->alert(alertText);
1735 }
1736
1737 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1738 {
1739     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1740     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1741
1742     return impl->javascriptPopup->confirm(message);
1743 }
1744
1745 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1746 {
1747     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1748     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1749
1750     return impl->javascriptPopup->prompt(message, defaultValue);
1751 }
1752
1753 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1754 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1755 {
1756     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1757     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1758
1759     return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1760 }
1761 #endif
1762
1763 static Eina_Bool _ewk_view_default_open_panel(Evas_Object* ewkView, Eina_Bool allow_multiple_files, Eina_List *accepted_mime_types, const char* capture, void* userData)
1764 {
1765     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1766     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1767
1768     return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1769 }
1770
1771 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1772 Eina_Bool _ewk_view_popup_menu_show(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items, int selectedIndex)
1773 {
1774     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1775
1776     if (impl->popupPicker)
1777         ewk_popup_picker_del(impl->popupPicker);
1778
1779 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1780     impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1781 #else
1782     impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1783 #endif
1784
1785     return true;
1786 }
1787
1788 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1789 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items)
1790 {
1791     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1792
1793     if (impl->popupPicker)
1794         ewk_popup_picker_del(impl->popupPicker);
1795
1796     impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1797
1798     return true;
1799 }
1800 #endif
1801
1802 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1803 {
1804     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1805
1806     if (!impl->popupPicker)
1807         return false;
1808
1809     ewk_popup_picker_del(impl->popupPicker);
1810     impl->popupPicker = 0;
1811
1812     return true;
1813 }
1814
1815 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, Eina_List* items, int selectedIndex)
1816 {
1817     // FIXME: The rect should be updated if it was changed
1818
1819     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1820
1821     if (!impl->popupPicker)
1822         return false;
1823
1824     ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1825
1826     return true;
1827 }
1828 #endif
1829
1830 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1831 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1832 {
1833     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1834
1835     impl->inputPicker->show(inputType, inputValue);
1836     return true;
1837 }
1838 #endif
1839
1840 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1841 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1842 {
1843     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1844
1845     impl->inputPicker->showDataList(inputType, optionList);
1846     return true;
1847 }
1848
1849 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1850 {
1851     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1852
1853     impl->inputPicker->hideDataList(inputType);
1854     return true;
1855 }
1856 #endif
1857
1858 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1859 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1860 {
1861     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1862
1863     impl->inputPicker->showColorPicker(r, g, b, a);
1864     return true;
1865 }
1866
1867 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1868 {
1869     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1870
1871     impl->inputPicker->hideColorPicker();
1872     return true;
1873 }
1874 #endif
1875
1876 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1877 {
1878     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1879     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1880
1881     return impl->pageClient.get();
1882 }
1883
1884 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
1885 {
1886     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1887     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
1888
1889     return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
1890 }
1891
1892 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
1893 {
1894     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1895     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1896
1897     WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
1898     return true;
1899 }
1900
1901 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1902 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
1903 {
1904     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1905     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1906
1907     return impl->focusRing.get();
1908 }
1909 #endif
1910
1911 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
1912 {
1913     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1914     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1915
1916     return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
1917 }
1918
1919 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
1920 {
1921     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1922     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1923
1924     return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
1925 }
1926
1927 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
1928 {
1929     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1930     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1931
1932     if (!impl->javascriptGlobalContext)
1933         impl->javascriptGlobalContext = JSGlobalContextCreate(0);
1934     return impl->javascriptGlobalContext;
1935 }
1936
1937 void ewkViewLoadCommitted(Evas_Object* ewkView)
1938 {
1939 #if ENABLE(TIZEN_GESTURE)
1940     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1941     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1942     impl->gestureClient->reset();
1943 #endif
1944 #if ENABLE(TIZEN_ISF_PORT)
1945     impl->inputMethodContext()->hideIMFContext();
1946 #endif
1947     impl->informURLChange();
1948     evas_object_smart_callback_call(ewkView, "load,committed", 0);
1949 }
1950
1951 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
1952 {
1953     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1954     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1955
1956     OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
1957     ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
1958     evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
1959 }
1960
1961 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
1962 {
1963 #if ENABLE(TIZEN_GESTURE)
1964     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1965     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1966     impl->gestureClient->reset();
1967 #endif
1968     evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
1969 }
1970
1971 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
1972 {
1973     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1974     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1975
1976     if (impl->authChallenge)
1977         ewkAuthChallengeDelete(impl->authChallenge);
1978     impl->authChallenge = authChallenge;
1979
1980     evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
1981 }
1982
1983 void ewk_view_process_crashed(Evas_Object* ewkView)
1984 {
1985     bool handled = false;
1986     evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
1987
1988     if (!handled)
1989         exit(0);
1990 }
1991
1992 #if ENABLE(TIZEN_SQL_DATABASE)
1993 unsigned long long ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
1994 {
1995     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
1996     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, currentQuota);
1997
1998     TIZEN_LOGI("database,quota,exceeded");
1999     uint64_t defaultQuota = ewkContextGetDatabaseQuota(impl->context.get());
2000     if (defaultQuota >= expectedUsage + currentQuota)
2001         return defaultQuota;
2002
2003     if (impl->exceededDatabaseQuota)
2004         ewkContextDeleteExceededQuota(impl->exceededDatabaseQuota);
2005     impl->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
2006     evas_object_smart_callback_call(ewkView, "database,quota,exceeded", impl->exceededDatabaseQuota);
2007
2008     return ewkContextGetNewQuotaForExceededQuota(impl->context.get(), impl->exceededDatabaseQuota);
2009 }
2010 #endif
2011
2012 #if ENABLE(TIZEN_NOTIFICATIONS)
2013 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2014 {
2015     TIZEN_LOGI("notification,cancel");
2016     evas_object_smart_callback_call(ewkView, "notification,cancel", &notificationID);
2017 }
2018
2019 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2020 {
2021     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2022     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2023
2024     TIZEN_LOGI("notification,permission,request");
2025     impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2026     evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2027 }
2028
2029 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2030 {
2031     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2032     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2033
2034     TIZEN_LOGI("notification,show");
2035     Eina_List* listIterator=0;
2036     void* data=0;
2037     const char* replaceID = ewkNotificationGetReplaceID(notification);
2038     if(strlen(replaceID)) {
2039         EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2040             Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2041             if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2042                 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2043         }
2044     }
2045
2046     impl->notifications = eina_list_append(impl->notifications, notification);
2047     evas_object_smart_callback_call(ewkView, "notification,show", notification);
2048 }
2049
2050 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2051 {
2052     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2053     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2054
2055     impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2056 }
2057 #endif
2058
2059 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2060 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2061 {
2062     EINA_SAFETY_ON_NULL_RETURN(ewkView);
2063
2064     TIZEN_LOGI("protocolhandler,registration,requested");
2065     Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2066     evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2067     ewkCustomHandlersDeleteData(customHandlersData);
2068 }
2069 #endif
2070
2071 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2072 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2073 {
2074     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2075
2076     TIZEN_LOGI("protocolhandler,isregistered");
2077     Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2078     evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2079
2080     Ewk_Custom_Handlers_State result;
2081     result = ewkGetCustomHandlersDataResult(customHandlersData);
2082     ewkCustomHandlersDeleteData(customHandlersData);
2083
2084     return result;
2085 }
2086
2087 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2088 {
2089     EINA_SAFETY_ON_NULL_RETURN(ewkView);
2090
2091     TIZEN_LOGI("protocolhandler,unregistration,requested");
2092     Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2093     evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2094     ewkCustomHandlersDeleteData(customHandlersData);
2095 }
2096 #endif
2097
2098 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2099 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2100 {
2101     EINA_SAFETY_ON_NULL_RETURN(ewkView);
2102
2103     TIZEN_LOGI("contenthandler,registration,requested");
2104     Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2105     evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2106     ewkCustomHandlersDeleteData(customHandlersData);
2107 }
2108
2109 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2110 {
2111     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2112
2113     TIZEN_LOGI("contenthandler,isregistered");
2114     Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2115     evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2116
2117     Ewk_Custom_Handlers_State result;
2118     result = ewkGetCustomHandlersDataResult(customHandlersData);
2119     ewkCustomHandlersDeleteData(customHandlersData);
2120
2121     return result;
2122 }
2123
2124 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2125 {
2126     EINA_SAFETY_ON_NULL_RETURN(ewkView);
2127
2128     TIZEN_LOGI("contenthandler,unregistration,requested");
2129     Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2130     evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2131     ewkCustomHandlersDeleteData(customHandlersData);
2132 }
2133 #endif
2134
2135 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2136 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2137 {
2138     EINA_SAFETY_ON_NULL_RETURN(ewkView);
2139
2140     TIZEN_LOGI("searchProvider,add");
2141     Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2142     evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2143     ewkSearchProviderDeleteData(searchProviderData);
2144 }
2145
2146 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2147 {
2148     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2149
2150     TIZEN_LOGI("searchProvider,installed");
2151     Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2152     evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2153     unsigned long result;
2154     result = ewkGetSearchProviderResult(searchProviderData);
2155     ewkSearchProviderDeleteData(searchProviderData);
2156     return result;
2157 }
2158 #endif
2159
2160 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2161 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2162 {
2163     TIZEN_LOGI("webapp,metatag,standalone");
2164     bool standalone = true;
2165     evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2166     return standalone;
2167 }
2168 #endif
2169
2170 #if ENABLE(TIZEN_MEDIA_STREAM)
2171 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2172 {
2173     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2174     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2175
2176     impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2177     evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2178 }
2179
2180 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2181 {
2182     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2183     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2184
2185     impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2186 }
2187
2188 #endif
2189
2190 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2191 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2192 {
2193     int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2194     OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2195     int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2196     OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2197     WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2198     WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2199
2200     evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2201 }
2202 #endif
2203
2204 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2205 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2206 {
2207     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2208     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2209     if (impl->certificatePolicyDecision)
2210         ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2211     impl->certificatePolicyDecision = certificatePolicyDecision;
2212
2213     evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2214 }
2215 #endif
2216
2217 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2218 {
2219     evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2220 }
2221
2222 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2223 {
2224     evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2225 }
2226
2227 #if ENABLE(TIZEN_GEOLOCATION)
2228 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2229 {
2230     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2231     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2232
2233     TIZEN_LOGI("geolocation,permission,request");
2234     impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2235     evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2236 }
2237
2238 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2239 {
2240     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2241     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2242
2243     impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2244 }
2245
2246 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2247 {
2248     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2249     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2250
2251     impl->geolocation = geolocation;
2252 }
2253
2254 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2255 {
2256     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2257     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2258
2259     return impl->geolocation;
2260 }
2261
2262 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2263 {
2264     TIZEN_LOGI("geolocation,valid");
2265
2266     bool valid = true;
2267     evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2268     return valid;
2269 }
2270 #endif
2271
2272 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2273 {
2274     evas_object_smart_callback_call(ewkView, "form,submit", formData);
2275 }
2276
2277 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2278 {
2279     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2280     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2281     if (impl->policyDecision)
2282         ewkPolicyDecisionDelete(impl->policyDecision);
2283     impl->policyDecision = policyDecision;
2284
2285     evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2286 }
2287
2288 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2289 {
2290     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2291     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2292     if (impl->policyDecision)
2293         ewkPolicyDecisionDelete(impl->policyDecision);
2294     impl->policyDecision = policyDecision;
2295
2296     evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2297 }
2298
2299 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2300 {
2301     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2302     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2303     if (impl->policyDecision)
2304         ewkPolicyDecisionDelete(impl->policyDecision);
2305     impl->policyDecision = policyDecision;
2306
2307     evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2308 }
2309
2310 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2311 {
2312     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2313     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2314
2315     IntPoint scrollPosition = impl->pageClient->scrollPosition();
2316     IntSize contentsSize = impl->pageProxy->contentsSize();
2317 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2318     contentsSize.scale(impl->pageClient->scaleFactor());
2319 #endif
2320
2321     // some website's contents size is smaller than view size,
2322     // so we have to adjust contents size to view size for that case.
2323     if (contentsSize.width() < smartData->view.w)
2324         contentsSize.setWidth(smartData->view.w);
2325     if (contentsSize.height() < smartData->view.h)
2326         contentsSize.setHeight(smartData->view.h);
2327
2328     // Call "scroll,down" if webview can be scrolled down.
2329     if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2330         evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2331     // Call "scroll,up" if webview can be scrolled up.
2332     else if (deltaY < 0 && scrollPosition.y() > 0)
2333         evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2334
2335     // Call "scroll,right" if webview can be scrolled down.
2336     if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2337         evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2338     // Call "scroll,left" if webview can be scrolled up.
2339     else if (deltaX < 0 && scrollPosition.x() > 0)
2340         evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2341 }
2342
2343 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2344 {
2345     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2346     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2347
2348     IntSize contentsSize = impl->pageProxy->contentsSize();
2349 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2350     contentsSize.scale(impl->pageClient->scaleFactor());
2351 #endif
2352
2353     int maxScrollY = contentsSize.height() - smartData->view.h;
2354     if (!impl->isVerticalEdge) {
2355         if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2356             evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2357             impl->isVerticalEdge = true;
2358         } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2359             evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2360             impl->isVerticalEdge = true;
2361         }
2362     } else {
2363         if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2364                            || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2365             impl->isVerticalEdge = false;
2366     }
2367
2368     int maxScrollX = contentsSize.width() - smartData->view.w;
2369     if (!impl->isHorizontalEdge) {
2370         if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2371             evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2372             impl->isHorizontalEdge = true;
2373         } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2374             evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2375             impl->isHorizontalEdge = true;
2376         }
2377     } else {
2378         if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2379                            || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2380             impl->isHorizontalEdge = false;
2381     }
2382 }
2383
2384 void ewkViewClearEdges(Evas_Object* ewkView)
2385 {
2386     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2387     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2388
2389     impl->isVerticalEdge = false;
2390     impl->isHorizontalEdge = false;
2391 }
2392
2393 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2394 {
2395     EWK_VIEW_SD_GET(ewkView, smartData);
2396     if (!smartData || !smartData->priv) {
2397         if (minimumScale)
2398             *minimumScale = -1;
2399         if (maximumScale)
2400             *maximumScale = -1;
2401         return;
2402     }
2403
2404     PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2405     if (minimumScale)
2406         *minimumScale = constraints.minimumScale;
2407     if (maximumScale)
2408         *maximumScale = constraints.maximumScale;
2409 }
2410
2411 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
2412 {
2413     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2414     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2415
2416     double scaleFactor = impl->pageClient->scaleFactor();
2417     IntSize contentsSize = impl->pageProxy->contentsSize();
2418
2419     double newScaleFactor = scaleFactor;
2420     // Readable zoom value is dependent on device DPI
2421     if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2422         && impl->pageClient->viewportConstraints().userScalable)
2423         newScaleFactor = impl->pageProxy->deviceScaleFactor();
2424
2425     // Readable zoom value should be inside of viewport scale range
2426     newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2427
2428     // scale contents' size with new scale factor
2429 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2430     contentsSize.scale(newScaleFactor);
2431 #else
2432     contentsSize.scale(newScaleFactor / scaleFactor);
2433 #endif
2434
2435 #if ENABLE(TIZEN_ISF_PORT)
2436     Ecore_X_Window rootWin = ecore_x_window_root_first_get();
2437     ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2438     Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
2439     unsigned int connectedKeyboardNum = 0;
2440     bool isExternalKeyboardConnected = false;
2441
2442     // get connected keyboard number
2443     if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
2444         && connectedKeyboardNum)
2445         isExternalKeyboardConnected = true;
2446
2447     // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2448     // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2449     // input field zoom should not work with below conditions
2450     // 1. view is not focused
2451     // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2452     // 3. imfContext is null(if adjustForExternalKeyboard is false)
2453     // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2454     if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2455         || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
2456         || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2457         || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
2458 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2459         && !(impl->pageClient->isClipboardWindowOpened())
2460 #endif
2461         )
2462         return false;
2463 #endif
2464
2465     IntSize visibleSize(smartData->view.w, smartData->view.h);
2466     // caret position can be outside of visible rect.
2467     // we need to consider it.
2468     IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
2469     IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2470 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2471     selectionRect.scale(newScaleFactor);
2472     focusedNodeRect.scale(newScaleFactor);
2473 #else
2474     selectionRect.scale(newScaleFactor / scaleFactor);
2475     focusedNodeRect.scale(newScaleFactor / scaleFactor);
2476 #endif
2477     if (selectionRect.isEmpty())
2478         return false;
2479
2480     // set paddings
2481     IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
2482     // If both input field's position x and selection rect can be displayed together,
2483     // adjust scroll position to input field's position x.
2484     if (!focusedNodeRect.isEmpty()
2485         && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
2486         scrollPosition.setX(focusedNodeRect.x());
2487
2488 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2489     impl->pageClient->setVisibleContentRect(IntRect(scrollPosition, impl->size()), newScaleFactor);
2490 #else
2491     if (newScaleFactor != scaleFactor)
2492         impl->pageProxy->scalePage(newScaleFactor, scrollPosition);
2493     else
2494         impl->pageProxy->scrollMainFrameTo(scrollPosition);
2495 #endif
2496     evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
2497     return true;
2498 }
2499
2500 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2501 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2502 static Eina_Bool _ewk_view_composite(void* data)
2503 {
2504     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2505     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2506
2507     if (!evas_object_visible_get(smartData->image))
2508         return ECORE_CALLBACK_CANCEL;
2509
2510     Evas_Coord ow, oh;
2511     evas_object_image_size_get(smartData->image, &ow, &oh);
2512     uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2513
2514     RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, ow, oh, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ow)));
2515     RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2516
2517     cairo_save(context.get());
2518     cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2519     cairo_rectangle(context.get(), 0, 0, ow, oh);
2520     cairo_fill(context.get());
2521     cairo_restore(context.get());
2522
2523     impl->pageClient->drawContents(context.get());
2524
2525     evas_object_image_data_set(smartData->image, pixels);
2526     evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2527
2528     ewkViewFrameRendered(smartData->self);
2529
2530     impl->compositionAnimator = 0;
2531
2532     return ECORE_CALLBACK_CANCEL;
2533 }
2534 #endif
2535
2536 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2537 {
2538     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2539     EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2540
2541 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2542     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2543
2544     if (!ewk_view_is_opengl_backend(ewkView)) {
2545         if (!impl->compositionAnimator)
2546             impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2547         return;
2548     }
2549 #endif
2550
2551     evas_object_image_pixels_dirty_set(smartData->image, true);
2552 }
2553
2554 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2555 {
2556     Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2557     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2558     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2559     impl->pageClient->drawContents();
2560 }
2561
2562 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2563 {
2564     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2565     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2566
2567     if (!smartData->image)
2568         return false;
2569
2570     evas_object_image_native_surface_set(smartData->image, nativeSurface);
2571     evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2572
2573     return true;
2574 }
2575 #endif
2576
2577 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2578 {
2579     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2580     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2581
2582     if (!impl->suspendedPainting) {
2583         impl->pageProxy->suspendPainting();
2584         impl->suspendedPainting = true;
2585     }
2586 }
2587
2588 void _ewk_view_resume_painting(Evas_Object* ewkView)
2589 {
2590     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2591     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2592
2593     if (impl->suspendedPainting) {
2594         impl->pageProxy->resumePainting();
2595         impl->suspendedPainting = false;
2596     }
2597 }
2598
2599 void ewk_view_suspend(Evas_Object* ewkView)
2600 {
2601     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2602     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2603
2604     if (impl->pageProxy->estimatedProgress() < 1.0) {
2605         impl->suspendRequested = true;
2606         return;
2607     }
2608     impl->suspendRequested = false;
2609
2610     _ewk_view_suspend_painting(ewkView);
2611
2612     // FIXME Workaround for suspend/resume while javascript popup is displayed.
2613     // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2614     // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2615     // suspend.
2616     // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2617     // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2618     // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2619     // will be suspended again.
2620     // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2621     // the ActiveDOMObject.
2622     if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2623         impl->pageProxy->suspendJavaScriptAndResource();
2624         impl->suspendedResources = true;
2625     }
2626
2627 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2628     impl->pageProxy->suspendPlugin();
2629 #endif
2630 }
2631
2632 void ewk_view_resume(Evas_Object* ewkView)
2633 {
2634     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2635     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2636
2637     if (impl->suspendRequested) {
2638         impl->suspendRequested = false;
2639         return;
2640     }
2641
2642     _ewk_view_resume_painting(ewkView);
2643
2644     // FIXME Workaround for suspend/resume while javascript popup is displayed.
2645     // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2646     // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2647     // suspend.
2648     // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2649     // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2650     // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2651     // will be suspended again.
2652     // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2653     // the ActiveDOMObject.
2654     if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2655         impl->pageProxy->resumeJavaScriptAndResource();
2656         impl->suspendedResources = false;
2657     }
2658
2659 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2660     impl->pageProxy->resumePlugin();
2661 #endif
2662 }
2663
2664 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2665 {
2666     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2667     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2668     EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2669
2670     ResourceRequest request(String::fromUTF8(url));
2671
2672     switch (method) {
2673     case EWK_HTTP_METHOD_GET:
2674         request.setHTTPMethod("GET");
2675         break;
2676     case EWK_HTTP_METHOD_HEAD:
2677         request.setHTTPMethod("HEAD");
2678         break;
2679     case EWK_HTTP_METHOD_POST:
2680         request.setHTTPMethod("POST");
2681         break;
2682     case EWK_HTTP_METHOD_PUT:
2683         request.setHTTPMethod("PUT");
2684         break;
2685     case EWK_HTTP_METHOD_DELETE:
2686         request.setHTTPMethod("DELETE");
2687         break;
2688     default:
2689         return false;
2690     }
2691
2692     if (headers) {
2693         Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2694         void* data;
2695         while (eina_iterator_next(it, &data)) {
2696             Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2697             const char* name = static_cast<const char*>(t->key);
2698             const char* value = static_cast<const char*>(t->data);
2699             request.addHTTPHeaderField(name, value);
2700         }
2701         eina_iterator_free(it);
2702     }
2703
2704     if (body)
2705         request.setHTTPBody(FormData::create(body));
2706
2707     WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2708     WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2709
2710     return true;
2711 }
2712
2713 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2714 {
2715     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2716     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2717
2718     WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2719     WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2720
2721     return true;
2722 }
2723
2724 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2725 {
2726     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2727     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2728     EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2729
2730     if (contentsSize == 0)
2731         return false;
2732
2733     String mimeTypeString;
2734     if (mimeType)
2735         mimeTypeString = String::fromUTF8(mimeType);
2736     else
2737         mimeTypeString = String::fromUTF8("text/html");
2738
2739     String encodingString;
2740     if (encoding)
2741         encodingString = String::fromUTF8(encoding);
2742     else
2743         encodingString = String::fromUTF8("UTF-8");
2744
2745     String baseUriString;
2746     if (baseUri)
2747         baseUriString = String::fromUTF8(baseUri);
2748     else
2749         baseUriString = String::fromUTF8("about:blank");
2750
2751     WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2752     impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2753
2754     return true;
2755 }
2756
2757 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2758 {
2759     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2760     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2761
2762     WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2763     WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2764
2765     WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2766
2767     return true;
2768 }
2769
2770 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2771 {
2772     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2773     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2774
2775     TIZEN_LOGI("initialState (%d)", initialState);
2776 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2777     WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2778     return true;
2779 #else
2780     return false;
2781 #endif
2782 }
2783
2784 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2785 {
2786     EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2787
2788     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2789     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2790
2791     impl->userAgent = userAgent;
2792
2793     WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2794     WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2795
2796     return true;
2797 }
2798
2799 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2800 {
2801     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2802     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2803
2804     if (!impl->userAgent) {
2805         WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2806
2807         int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2808         OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2809         WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2810         impl->userAgent = buffer.get();
2811     }
2812
2813     return impl->userAgent;
2814 }
2815 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2816 {
2817 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2818     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2819     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2820
2821     WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2822     WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2823
2824     WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2825     return true;
2826 #else
2827     ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2828     return false;
2829 #endif
2830 }
2831
2832 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2833 {
2834 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2835     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2836     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2837
2838     WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2839
2840     WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2841     return true;
2842 #else
2843     ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2844     return false;
2845 #endif
2846 }
2847
2848 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2849 {
2850 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2851     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2852     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2853
2854     WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2855     return true;
2856 #else
2857     ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2858     return false;
2859 #endif
2860 }
2861
2862 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2863 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2864 {
2865     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2866     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2867
2868 #if ENABLE(TIZEN_DRAG_SUPPORT)
2869     if (impl->pageClient->isDragMode())
2870         impl->pageClient->setDragMode(false);
2871 #endif
2872
2873     impl->pageClient->setIsVisible(enable);
2874     return true;
2875 }
2876 #endif
2877
2878 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
2879 {
2880     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
2881
2882     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2883     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2884
2885     WKRect rect;
2886     rect.origin.x = viewArea.x;
2887     rect.origin.y = viewArea.y;
2888     rect.size.width = viewArea.w;
2889     rect.size.height = viewArea.h;
2890
2891     WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
2892     if (!snapshot.get())
2893         return 0;
2894
2895     RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
2896
2897     Evas_Object* screenshotImage = evas_object_image_add(canvas);
2898     int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
2899     int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
2900     evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
2901     evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
2902
2903     uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
2904
2905     RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_RGB24, surfaceWidth, surfaceHeight, cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, surfaceWidth)));
2906     RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
2907
2908     cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
2909     cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
2910     cairo_fill(cairo.get());
2911
2912     evas_object_image_smooth_scale_set(screenshotImage, true);
2913     evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
2914     evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
2915     evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
2916     evas_object_image_data_set(screenshotImage, pixels);
2917
2918     return screenshotImage;
2919 }
2920
2921 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
2922 {
2923 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
2924     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
2925     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
2926
2927     return impl->pageProxy->startInspectorServer(port);
2928 #else
2929     LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
2930     return 0;
2931 #endif
2932 }
2933
2934 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
2935 {
2936 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
2937     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
2938     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
2939
2940     return impl->pageProxy->stopInspectorServer();
2941 #else
2942     LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
2943     return false;
2944 #endif
2945 }
2946
2947 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
2948 {
2949     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2950     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2951
2952     WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
2953 }
2954
2955 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
2956 {
2957     if (x)
2958         *x = 0;
2959     if (y)
2960         *y = 0;
2961     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2962     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2963
2964     IntPoint scrollPosition = impl->pageClient->scrollPosition();
2965     if (x)
2966         *x = scrollPosition.x();
2967     if (y)
2968         *y = scrollPosition.y();
2969
2970     return true;
2971 }
2972
2973 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
2974 {
2975     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2976     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2977
2978     impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
2979     return true;
2980 }
2981
2982 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
2983 {
2984     if (width)
2985         *width = 0;
2986     if (height)
2987         *height = 0;
2988     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2989     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2990
2991     IntSize contentsSize = impl->pageProxy->contentsSize();
2992 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2993     contentsSize.scale(impl->pageClient->scaleFactor());
2994 #endif
2995
2996     if (width && contentsSize.width() > smartData->view.w)
2997         *width = contentsSize.width() - smartData->view.w;
2998     if (height && contentsSize.height() > smartData->view.h)
2999         *height = contentsSize.height() - smartData->view.h;
3000     return true;
3001 }
3002
3003 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3004 {
3005     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3006     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3007     if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3008         return false;
3009     EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3010
3011     impl->isWaitingForJavaScriptPopupReply = true;
3012     int length = WKStringGetMaximumUTF8CStringSize(alertText);
3013     OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3014     WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3015     return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3016 }
3017
3018 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3019 {
3020     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3021     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3022     if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3023         return false;
3024     EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3025
3026     impl->isWaitingForJavaScriptPopupReply = true;
3027     int length = WKStringGetMaximumUTF8CStringSize(message);
3028     OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3029     WKStringGetUTF8CString(message, messageBuffer.get(), length);
3030     return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3031 }
3032
3033 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3034 {
3035     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3036     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3037     if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3038         return false;
3039     EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3040
3041     impl->isWaitingForJavaScriptPopupReply = true;
3042     int length = WKStringGetMaximumUTF8CStringSize(message);
3043     OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3044     WKStringGetUTF8CString(message, messageBuffer.get(), length);
3045     length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3046     OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3047     WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3048     return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3049 }
3050
3051 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3052 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3053 {
3054     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3055     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3056     if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3057         return false;
3058     EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3059
3060     impl->isWaitingForJavaScriptPopupReply = true;
3061     int length = WKStringGetMaximumUTF8CStringSize(message);
3062     OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3063     WKStringGetUTF8CString(message, messageBuffer.get(), length);
3064     bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3065     return result;
3066 }
3067 #endif
3068
3069 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3070 {
3071     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3072     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3073     if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3074         return false;
3075
3076     EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3077
3078     impl->openPanelListener = listener;
3079
3080     Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3081     Eina_List* acceptedMimeTypes = 0;
3082     WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3083     size_t len = WKArrayGetSize(array.get());
3084     for (size_t i = 0; i < len; i++) {
3085         WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3086         if (WKGetTypeID(item) != WKStringGetTypeID())
3087             continue;
3088         WKStringRef mime = static_cast<WKStringRef>(item);
3089         int length = WKStringGetMaximumUTF8CStringSize(mime);
3090         char* buffer = new char[length];
3091         WKStringGetUTF8CString(mime, buffer, length);
3092         acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3093     }
3094     const char* capture = 0;
3095 #if ENABLE(MEDIA_CAPTURE)
3096     WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3097     capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3098 #endif
3099     bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3100     if (!acceptedMimeTypes)
3101         return result;
3102
3103     Eina_List* list;
3104     void* data = 0;
3105     EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3106         delete[] (char*)data;
3107     eina_list_free(acceptedMimeTypes);
3108     return result;
3109 }
3110
3111 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3112 {
3113     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3114     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3115
3116     if (!impl->alertContext)
3117         impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3118     impl->alertContext->javascriptAlertCallback = callback;
3119     impl->alertContext->ewkView = ewkView;
3120     impl->alertContext->userData = userData;
3121 }
3122
3123 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3124 {
3125     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3126     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3127
3128     WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3129     impl->isWaitingForJavaScriptPopupReply = false;
3130 }
3131
3132 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3133 {
3134     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3135     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3136
3137     if (!impl->confirmContext)
3138         impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3139     impl->confirmContext->javascriptConfirmCallback = callback;
3140     impl->confirmContext->ewkView = ewkView;
3141     impl->confirmContext->userData = userData;
3142 }
3143
3144 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3145 {
3146     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3147     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3148
3149     WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3150     impl->isWaitingForJavaScriptPopupReply = false;
3151 }
3152
3153 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3154 {
3155     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3156     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3157
3158     if (!impl->promptContext)
3159         impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3160     impl->promptContext->javascriptPromptCallback = callback;
3161     impl->promptContext->ewkView = ewkView;
3162     impl->promptContext->userData = userData;
3163 }
3164
3165 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3166 {
3167     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3168     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3169
3170     WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3171     WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3172     impl->isWaitingForJavaScriptPopupReply = false;
3173 }
3174
3175 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3176 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3177 {
3178     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3179     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3180
3181     if (!impl->beforeUnloadConfirmPanelContext)
3182         impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3183     impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3184     impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3185     impl->beforeUnloadConfirmPanelContext->userData = userData;
3186 }
3187
3188 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3189 {
3190     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3191     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3192
3193     WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3194     impl->isWaitingForJavaScriptPopupReply = false;
3195 }
3196 #endif
3197
3198 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3199 {
3200     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3201     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3202
3203     if (!impl->openpanelContext)
3204         impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3205
3206     impl->openpanelContext->openPanelCallback = callback;
3207     impl->openpanelContext->ewkView = ewkView;
3208     impl->openpanelContext->userData = userData;
3209 }
3210
3211 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3212 {
3213     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3214     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3215
3216     if (!impl->openPanelListener)
3217         return;
3218
3219     unsigned int size = eina_list_count(fileUrls);
3220     if ((result == EINA_FALSE) || (size == 0)) {
3221         WKOpenPanelResultListenerCancel(impl->openPanelListener);
3222         impl->openPanelListener = 0;
3223         return;
3224     }
3225
3226     WKTypeRef* items = new WKTypeRef[size];
3227     Eina_List* list;
3228     void* data;
3229     unsigned int i = 0;
3230     KURL base(KURL(), "file://");
3231     EINA_LIST_FOREACH(fileUrls, list, data) {
3232         KURL url(base, static_cast<char*>(data));
3233         items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3234     }
3235     WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3236     WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3237     impl->openPanelListener = 0;
3238     delete [] items;
3239     eina_list_free(fileUrls);
3240 }
3241
3242 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3243 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3244 {
3245     EINA_SAFETY_ON_NULL_RETURN(capable);
3246     EINA_SAFETY_ON_NULL_RETURN(context);
3247
3248     Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3249
3250     ASSERT(webAppContext->webAppCapableCallback);
3251
3252     TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3253     if (capable)
3254         webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3255     else
3256         webAppContext->webAppCapableCallback(0, webAppContext->userData);
3257
3258     delete webAppContext;
3259 }
3260
3261 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3262 {
3263     EINA_SAFETY_ON_NULL_RETURN(iconURL);
3264     EINA_SAFETY_ON_NULL_RETURN(context);
3265
3266     Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3267
3268     EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3269     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3270
3271     ASSERT(webAppContext->webAppIconURLCallback);
3272
3273     if (iconURL) {
3274         impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3275         webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3276     } else
3277         webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3278
3279     delete webAppContext;
3280 }
3281
3282 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3283 {
3284     EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3285     EINA_SAFETY_ON_NULL_RETURN(context);
3286
3287     Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3288
3289     EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3290     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3291
3292     ASSERT(webAppContext->webAppIconURLsCallback);
3293
3294     if (impl->webAppIconURLs) {
3295         void* data = 0;
3296         EINA_LIST_FREE(impl->webAppIconURLs, data)
3297             ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3298     }
3299
3300     WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3301     size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3302     for (size_t i = 0; i < iconURLCount; i++) {
3303         WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3304         WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3305         impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3306     }
3307     TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3308
3309     webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3310     delete webAppContext;
3311 }
3312 #endif
3313
3314 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3315 {
3316 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3317     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3318     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3319     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3320
3321     TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3322     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3323     context->webAppCapableCallback = callback;
3324     context->ewkView = ewkView;
3325     context->userData = userData;
3326
3327     WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3328
3329     return true;
3330 #else
3331     return false;
3332 #endif
3333 }
3334
3335 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3336 {
3337 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3338     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3339     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3340     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3341
3342     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3343     context->webAppIconURLCallback = callback;
3344     context->ewkView = ewkView;
3345     context->userData = userData;
3346
3347     WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3348
3349     return true;
3350 #else
3351     return 0;
3352 #endif
3353 }
3354
3355 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3356 {
3357 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3358     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3359     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3360     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3361
3362     TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3363     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3364     context->webAppIconURLsCallback = callback;
3365     context->ewkView = ewkView;
3366     context->userData = userData;
3367
3368     WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3369
3370     return true;
3371 #else
3372     UNUSED_PARAM(ewkView);
3373     UNUSED_PARAM(callback);
3374     UNUSED_PARAM(userData);
3375     return 0;
3376 #endif
3377 }
3378
3379 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3380 {
3381     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3382     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3383     EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3384
3385     WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3386     WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3387     WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3388
3389     return true;
3390 }
3391
3392 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3393 {
3394     if (width)
3395         *width = 0;
3396     if (height)
3397         *height = 0;
3398
3399     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3400     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3401
3402     IntSize contentsSize = impl->pageProxy->contentsSize();
3403
3404     if (width)
3405         *width = contentsSize.width();
3406     if (height)
3407         *height = contentsSize.height();
3408
3409     return true;
3410 }
3411
3412 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3413 {
3414 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3415     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3416     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3417     EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3418
3419     IntSize contentsSize = impl->pageProxy->contentsSize();
3420     WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3421
3422     return true;
3423 #else
3424     return false;
3425 #endif
3426 }
3427
3428 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3429 {
3430 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3431     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3432     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3433     EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3434
3435     IntSize contentsSize = impl->pageProxy->contentsSize();
3436     WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3437
3438     return true;
3439 #else
3440     return false;
3441 #endif
3442 }
3443
3444 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3445 {
3446     EINA_SAFETY_ON_NULL_RETURN(context);
3447     Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3448
3449     if (!callbackContext->scriptExecuteCallback) {
3450         delete callbackContext;
3451         return;
3452     }
3453
3454     JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3455
3456     if (scriptValue) {
3457         JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3458         JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3459         size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3460         OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3461         JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3462         callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3463     } else
3464         callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3465
3466     delete callbackContext;
3467 }
3468
3469 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3470 {
3471     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3472     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3473     EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3474     EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3475
3476     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3477     context->scriptExecuteCallback = callback;
3478     context->ewkView = ewkView;
3479     context->userData = user_data;
3480     WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3481     WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3482
3483     return true;
3484 }
3485
3486 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3487 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3488 {
3489     Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3490
3491     if (quota)
3492         storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3493     else
3494         storageContext->webStorageQuotaCallback(0, storageContext->userData);
3495
3496     delete storageContext;
3497 }
3498 #endif
3499
3500 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3501 {
3502 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3503     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3504     EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3505     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3506     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3507     TIZEN_LOGI("resultCallback (%p)", resultCallback);
3508
3509     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3510     context->webStorageQuotaCallback = resultCallback;
3511     context->userData = userData;
3512
3513     WKPageRef pageRef = toAPI(impl->page());
3514     WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3515
3516     return true;
3517 #else
3518     return false;
3519 #endif
3520 }
3521
3522 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3523 {
3524 #if ENABLE(TIZEN_WEB_STORAGE)
3525     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3526     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3527     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3528
3529     TIZEN_LOGI("quota (%d)", quota);
3530     WKPageRef pageRef = toAPI(impl->page());
3531     WKPageSetWebStorageQuota(pageRef, quota);
3532
3533     return true;
3534 #else
3535     return false;
3536 #endif
3537 }
3538
3539 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3540 {
3541     EINA_SAFETY_ON_NULL_RETURN(context);
3542     Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3543
3544     ASSERT(callbackContext->plainTextGetCallback);
3545
3546     if (plain_text) {
3547         size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3548         OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3549         WKStringGetUTF8CString(plain_text, buffer.get(), length);
3550
3551         callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3552     } else
3553         callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3554
3555     delete callbackContext;
3556 }
3557
3558 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3559 {
3560     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3561     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3562     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3563     EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3564
3565     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3566     context->plainTextGetCallback = callback;
3567     context->ewkView = ewkView;
3568     context->userData = user_data;
3569     WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3570
3571     return true;
3572 }
3573
3574 #if ENABLE(TIZEN_SUPPORT_MHTML)
3575 /**
3576  * @internal
3577  * Callback function used for ewk_view_mhtml_data_get().
3578  */
3579 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3580 {
3581     EINA_SAFETY_ON_NULL_RETURN(context);
3582     Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3583
3584     ASSERT(callbackContext->mhtmlDataGetCallback);
3585
3586     callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3587
3588     delete callbackContext;
3589 }
3590
3591 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3592 {
3593     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3594     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3595     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3596
3597     Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3598     context->mhtmlDataGetCallback = callback;
3599     context->ewkView = ewkView;
3600     context->userData = user_data;
3601
3602     WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3603
3604     return true;
3605 }
3606 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3607
3608 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3609 {
3610 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3611     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3612     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3613
3614     IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3615     WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3616     Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3617
3618     return hitTest;
3619 #else
3620     return 0;
3621 #endif
3622 }
3623
3624 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3625 {
3626     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3627     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3628     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3629     WebPageProxy* page = impl->page();
3630     EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3631
3632     return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3633 }
3634
3635 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3636 {
3637     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3638     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3639
3640     WKPageRecordingSurfaceSetEnable(toAPI(impl->pageProxy.get()), enable);
3641
3642     return true;
3643 }
3644
3645 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3646 {
3647 #if ENABLE(TIZEN_NOTIFICATIONS)
3648     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3649     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3650     EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3651
3652     TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3653     if (!eina_list_count(ewkNotifications))
3654         return false;
3655
3656     Eina_List* listIterator = 0;
3657     void* data = 0;
3658     Vector<WKTypeRef> ids;
3659     EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3660         Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3661         WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3662         ids.append(idRef);
3663         impl->notifications = eina_list_remove(impl->notifications, notification);
3664     }
3665
3666     WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3667     WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3668     WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3669     ewkNotificationDeleteNotificationList(ewkNotifications);
3670
3671     return true;
3672 #else
3673     return false;
3674 #endif
3675 }
3676
3677 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3678 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3679 {
3680     Eina_List* popupItems = 0;
3681     size_t size = items.size();
3682     for (size_t i = 0; i < size; ++i)
3683         popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3684     TIZEN_LOGI("size : %d", size);
3685     return popupItems;
3686 }
3687
3688 static void releasePopupMenuList(Eina_List* popupMenuItems)
3689 {
3690     if (!popupMenuItems)
3691         return;
3692
3693     void* item;
3694     EINA_LIST_FREE(popupMenuItems, item)
3695         delete static_cast<Ewk_Popup_Menu_Item*>(item);
3696 }
3697 #endif
3698
3699 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3700 {
3701     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3702     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3703     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3704 #if OS(TIZEN)
3705     TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3706 #endif
3707
3708     if (!impl->popupMenuProxy)
3709         return false;
3710
3711     impl->popupMenuProxy = 0;
3712
3713     if (smartData->api->popup_menu_hide)
3714         smartData->api->popup_menu_hide(smartData);
3715 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3716     ewk_view_touch_events_enabled_set(ewkView, true);
3717
3718     releasePopupMenuList(impl->popupMenuItems);
3719     impl->popupMenuItems = 0;
3720 #else
3721     void* item;
3722     EINA_LIST_FREE(impl->popupMenuItems, item)
3723         delete static_cast<Ewk_Popup_Menu_Item*>(item);
3724 #endif
3725
3726     return true;
3727 }
3728
3729 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3730 {
3731     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3732     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3733     EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3734 #if OS(TIZEN)
3735     TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3736
3737     if (!impl->popupMenuItems)
3738         return false;
3739 #endif
3740
3741     if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3742         return false;
3743
3744     impl->popupMenuProxy->valueChanged(selectedIndex);
3745
3746     return true;
3747 }
3748
3749 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3750 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3751 {
3752     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3753     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3754     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3755     TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3756
3757     if (!impl->popupMenuProxy)
3758         return;
3759
3760     if (!smartData->api->popup_menu_update)
3761         return;
3762
3763     releasePopupMenuList(impl->popupMenuItems);
3764     impl->popupMenuItems = createPopupMenuList(items);
3765
3766     // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3767     smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3768 }
3769 #endif
3770
3771 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3772 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3773 {
3774     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3775     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3776     EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3777
3778     Vector<int> selectedIndex;
3779
3780     if (!impl->popupMenuItems)
3781         return false;
3782
3783     Eina_Iterator* itr;
3784     void* data;
3785     itr = eina_inarray_iterator_new(changeList);
3786     EINA_ITERATOR_FOREACH(itr, data)
3787     {
3788         int* pData = static_cast<int*>(data);
3789         selectedIndex.append(*pData);
3790     }
3791     eina_iterator_free(itr);
3792
3793     impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3794     return true;
3795 }
3796 #endif
3797
3798 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3799 {
3800 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3801     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3802     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3803     TIZEN_LOGI("orientation : %d", orientation);
3804
3805     if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3806         return;
3807
3808     if (impl->orientation == orientation)
3809         return;
3810
3811     impl->orientation = orientation;
3812
3813     impl->pageProxy->sendOrientationChangeEvent(orientation);
3814 #endif
3815 }
3816
3817 void ewkViewFrameRendered(Evas_Object* ewkView)
3818 {
3819     evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3820 }
3821
3822 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3823 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3824 {
3825     return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3826 }
3827
3828 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3829 {
3830     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3831     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3832
3833     IntRect leftSelectionRect;
3834     IntRect rightSelectionRect;
3835     if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3836         leftRect->x = 0;
3837         leftRect->y = 0;
3838         leftRect->w = 0;
3839         leftRect->h = 0;
3840
3841         rightRect->x = 0;
3842         rightRect->y = 0;
3843         rightRect->w = 0;
3844         rightRect->h = 0;
3845         return false;
3846     }
3847
3848     AffineTransform contentToScreen = impl->transformToScene();
3849     leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3850     rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3851
3852     leftRect->x = leftSelectionRect.x();
3853     leftRect->y = leftSelectionRect.y();
3854     leftRect->w = leftSelectionRect.width();
3855     leftRect->h = leftSelectionRect.height();
3856
3857     rightRect->x = rightSelectionRect.x();
3858     rightRect->y = rightSelectionRect.y();
3859     rightRect->w = rightSelectionRect.width();
3860     rightRect->h = rightSelectionRect.height();
3861
3862     return true;;
3863 }
3864
3865 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
3866 {
3867     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3868     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3869
3870     const CString selectedString = impl->pageProxy->getSelectionText().utf8();
3871     impl->selectedText = selectedString.data();
3872
3873     return impl->selectedText;
3874 }
3875
3876 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
3877 {
3878     return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
3879 }
3880
3881 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
3882 {
3883     return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
3884 }
3885 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3886
3887 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3888 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
3889 {
3890     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3891     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3892     EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
3893
3894     smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
3895 }
3896 #endif
3897
3898 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
3899 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
3900 {
3901     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3902     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3903     IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
3904     if (x)
3905         *x = drawingPosition.x();
3906     if (y)
3907         *y = drawingPosition.y();
3908     if (w)
3909         *w = impl->pageClient->visibleContentRect().width();
3910     if (h)
3911         *h = impl->pageClient->visibleContentRect().height();
3912 }
3913 #endif
3914
3915 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
3916 {
3917 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3918     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3919     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3920
3921     impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
3922 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3923 }
3924
3925 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
3926 {
3927 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3928     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3929     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3930
3931     impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
3932     return impl->inputValue;
3933 #else
3934     return 0;
3935 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3936 }
3937
3938 #if ENABLE(TIZEN_DATALIST_ELEMENT)
3939 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
3940 {
3941     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3942     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3943     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3944     EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
3945
3946     if (impl->dataList)
3947         ewkViewDataListHideRequest(ewkView, inputType);
3948
3949     for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
3950         String value = *it;
3951         impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
3952     }
3953
3954     smartData->api->data_list_show(smartData, inputType, impl->dataList);
3955 }
3956
3957 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
3958 {
3959     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3960     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3961     EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
3962     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3963     EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
3964
3965     impl->deleteDataList();
3966
3967     smartData->api->data_list_hide(smartData, inputType);
3968 }
3969 #endif
3970
3971 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
3972 {
3973 #if ENABLE(TIZEN_DATALIST_ELEMENT)
3974     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3975     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3976
3977     impl->deleteDataList();
3978
3979     ewk_view_focused_input_element_value_set(ewkView, value);
3980 #endif
3981 }
3982
3983 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
3984 {
3985 #if ENABLE(TIZEN_GESTURE)
3986     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3987     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3988     return impl->holdHorizontalPanning;
3989 #else
3990     return false;
3991 #endif
3992 }
3993
3994 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
3995 {
3996 #if ENABLE(TIZEN_GESTURE)
3997     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3998     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3999     impl->holdHorizontalPanning = hold;
4000 #endif
4001 }
4002
4003 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4004 {
4005 #if ENABLE(TIZEN_GESTURE)
4006     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4007     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4008     return impl->holdVerticalPanning;
4009 #else
4010     return false;
4011 #endif
4012 }
4013
4014 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4015 {
4016 #if ENABLE(TIZEN_GESTURE)
4017     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4018     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4019     impl->holdVerticalPanning = hold;
4020 #endif
4021 }
4022
4023 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4024 {
4025 #if ENABLE(TIZEN_GESTURE)
4026     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4027     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4028
4029 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4030     if (impl->focusRing && wasHandled)
4031         impl->focusRing->hide();
4032 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4033
4034     if (impl->mouseEventsEnabled())
4035         return;
4036
4037 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4038     if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4039         if (type == WebEvent::TouchStart)
4040             impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4041         else if (type == WebEvent::TouchMove)
4042             impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4043         else if (type == WebEvent::TouchEnd)
4044             impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4045     }
4046 #endif
4047
4048     // We have to check TouchStart, TouchMove and TouchEnd with handled.
4049     // The Pan and Flick will be enabled if Touch Start was not handled,
4050     // and Touch Move was not handled or did not occur.
4051     // Tap will be enabled if Touch Start and End was not handled
4052     // and Touch Move did not occur.
4053     // The gestures are disabled as a default.
4054     // o: handled, x: not handled
4055     // ------------------------------------------------------------
4056     // Touch Start | Touch Move | Touch End ||   Tap   | Pan, Flick
4057     // ------------------------------------------------------------
4058     //      o      |   o or x   |   o or x  || disable |  disable
4059     //      x      |      o     |   o or x  || disable |  disable
4060     //      x      |      x     |   o or x  || disable |  enable
4061     //      x      |not occured |     x     || enable  |  enable
4062     // ------------------------------------------------------------
4063     if (type == WebEvent::TouchStart) {
4064         impl->gestureClient->setGestureEnabled(!wasHandled);
4065         impl->wasHandledTouchStart = wasHandled;
4066
4067         // Initialize wasHandledTouchMove to true and notify that to the application
4068         // to prevent applications scrolling at the beginning of touch.
4069         impl->wasHandledTouchMove = true;
4070         evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4071     } else if (type == WebEvent::TouchMove) {
4072         impl->gestureClient->setMovingEnabled(!wasHandled);
4073
4074         // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4075         if (impl->wasHandledTouchStart)
4076             wasHandled = true;
4077
4078         // Notify the result of touchmove to applications when handled value is changed
4079         // in order to make applications to choose whether scrolling its scrollable objects or not.
4080         if (impl->wasHandledTouchMove != wasHandled)
4081             evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4082         impl->wasHandledTouchMove = wasHandled;
4083     } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold && !wasHandled) {
4084         impl->gestureClient->setMovingEnabled(!wasHandled);
4085         impl->gestureClient->setTapEnabled(!wasHandled);
4086     }
4087 #endif
4088 }
4089
4090 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4091 void  ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
4092 {
4093     Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
4094     evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4095     ewkTextStyleDelete(textStyle);
4096 }
4097 #endif
4098
4099 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4100 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4101 {
4102     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4103     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4104
4105     TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4106     if (!smartData->api->orientation_lock) {
4107         TIZEN_LOGE("fail");
4108         return false;
4109     }
4110
4111     return smartData->api->orientation_lock(smartData, willLockOrientation);
4112 }
4113
4114 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4115 {
4116     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4117     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4118
4119     TIZEN_LOGI("ewkView (%p)", ewkView);
4120     if (!smartData->api->orientation_unlock) {
4121         TIZEN_LOGE("fail");
4122         return;
4123     }
4124
4125     smartData->api->orientation_unlock(smartData);
4126 }
4127 #endif
4128
4129 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4130 {
4131 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4132     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4133     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4134     TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4135
4136     impl->orientationLock.callback = func;
4137     impl->orientationLock.data = data;
4138 #endif
4139 }
4140
4141 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4142 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4143 {
4144     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4145     TIZEN_LOGI("locked orientations : %d", orientations);
4146
4147     if (impl->orientationLock.callback)
4148         return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4149
4150     return false;
4151 }
4152
4153 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4154 {
4155     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4156     TIZEN_LOGI("unlock is requested");
4157
4158     if (impl->orientationLock.callback)
4159         impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4160 }
4161 #endif
4162
4163 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4164 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4165 {
4166     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4167
4168     Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4169     const char *engine = ecore_evas_engine_name_get(ee);
4170     if (engine && !strcmp(engine, "opengl_x11"))
4171         return true;
4172     return false;
4173 }
4174 #endif
4175
4176 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4177 {
4178 #if ENABLE(TIZEN_GESTURE)
4179     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4180     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4181
4182     impl->gestureClient->setZoomableArea(target, area);
4183 #endif
4184 }
4185
4186 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4187 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4188 {
4189     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4190     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4191
4192     WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4193 }
4194 #endif
4195
4196 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4197 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4198 {
4199     evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4200 }
4201 #endif
4202
4203 #if ENABLE(TIZEN_ICON_DATABASE)
4204 void ewkViewIconReceived(Evas_Object* ewkView)
4205 {
4206     if (!ewkView)
4207         return;
4208     evas_object_smart_callback_call(ewkView, "icon,received", 0);
4209 }
4210 #endif
4211
4212 #endif // #if OS(TIZEN)
4213
4214 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4215 {
4216 #if ENABLE(TOUCH_EVENTS)
4217     EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4218     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4219     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4220
4221 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4222     if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4223         Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4224         IntPoint handlePoint(point->x, point->y);
4225
4226         if (type == EWK_TOUCH_START)
4227             impl->pageClient->textSelectonHandleDown(handlePoint);
4228         else if (type == EWK_TOUCH_MOVE)
4229             impl->pageClient->textSelectonHandleMove(handlePoint);
4230         else
4231             impl->pageClient->textSelectonHandleUp();
4232     }
4233 #endif
4234
4235 #if ENABLE(TIZEN_GESTURE)
4236 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4237     // We don't want to process touch event when context menu is shown.
4238     if (impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4239         return true;
4240 #endif
4241 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4242     if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4243         return true;
4244 #endif
4245
4246     if (type == EWK_TOUCH_START) {
4247         if (eina_list_count(points) == 1) {
4248             impl->gestureClient->reset();
4249             Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4250             impl->touchDownPoint.x = point->x;
4251             impl->touchDownPoint.y = point->y;
4252             impl->exceedTouchMoveThreshold = false;
4253         }
4254     } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4255         if (eina_list_count(points) == 1) {
4256             unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4257             Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4258             int diffX = impl->touchDownPoint.x - point->x;
4259             int diffY = impl->touchDownPoint.y - point->y;
4260             if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4261                 impl->exceedTouchMoveThreshold = true;
4262             else
4263                 return true;
4264         } else {
4265             impl->exceedTouchMoveThreshold = true;
4266         }
4267     }
4268 #endif // #if ENABLE(TIZEN_GESTURE)
4269
4270     // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4271     //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4272     impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4273
4274     return true;
4275 #else
4276     return false;
4277 #endif
4278 }
4279
4280 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4281 {
4282 #if ENABLE(TOUCH_EVENTS)
4283     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4284     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4285
4286     impl->setTouchEventsEnabled(!!enabled);
4287
4288     return true;
4289 #else
4290     return false;
4291 #endif
4292 }
4293
4294 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4295 {
4296 #if ENABLE(TOUCH_EVENTS)
4297     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4298     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4299
4300     return impl->touchEventsEnabled();
4301 #else
4302     return false;
4303 #endif
4304 }
4305
4306 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4307 {
4308 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4309     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4310     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4311
4312     impl->mainFrameScrollbarVisibility = visible;
4313     impl->pageClient->updateVisibility();
4314
4315     return true;
4316 #else
4317     return false;
4318 #endif
4319 }
4320
4321 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4322 {
4323 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4324     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4325     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4326
4327     return impl->mainFrameScrollbarVisibility;
4328 #else
4329     return false;
4330 #endif
4331 }
4332
4333 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4334 {
4335 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4336     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4337     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4338     EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4339
4340     String title = ewk_view_title_get(ewkView);
4341     String url = ewk_view_url_get(ewkView);
4342     String directoryPath(path);
4343     impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4344
4345     return true;
4346 #else
4347     UNUSED_PARAM(ewkView);
4348     UNUSED_PARAM(path);
4349     return false;
4350 #endif
4351 }
4352
4353 /**
4354  * @internal
4355  * Callback function used for ewk_view_page_contents_get().
4356  */
4357 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4358 {
4359     EINA_SAFETY_ON_NULL_RETURN(context);
4360
4361     RefPtr<WebData> webData = toImpl(wkData);
4362     Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4363     contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4364 }
4365
4366 /**
4367  * @internal
4368  * Callback function used for ewk_view_page_contents_get().
4369  */
4370 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4371 {
4372     EINA_SAFETY_ON_NULL_RETURN(context);
4373
4374     RefPtr<WebString> webString = toImpl(wkString);
4375     Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4376     contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4377 }
4378
4379 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4380 {
4381     EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4382     EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4383     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4384     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4385
4386     switch (context->type) {
4387     case EWK_PAGE_CONTENTS_TYPE_MHTML:
4388         impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4389         break;
4390
4391     case EWK_PAGE_CONTENTS_TYPE_STRING:
4392         impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4393         break;
4394
4395     default:
4396         ASSERT_NOT_REACHED();
4397         return false;
4398     }
4399
4400     return true;
4401 }
4402
4403 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4404 {
4405 #if ENABLE(TIZEN_GESTURE)
4406     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4407     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4408
4409     return impl->gestureClient->scrollToWithAnimation(x, y);
4410 #else
4411     UNUSED_PARAM(ewkView);
4412     UNUSED_PARAM(x);
4413     UNUSED_PARAM(y);
4414     return false;
4415 #endif
4416 }
4417
4418 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4419 void ewkViewFocusRingHide(Evas_Object* ewkView)
4420 {
4421     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4422     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4423
4424     if (impl->focusRing)
4425         impl->focusRing->hide();
4426 }
4427 #endif
4428
4429 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4430 {
4431 #if ENABLE(TIZEN_CSP)
4432     EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4433     EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4434
4435     TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4436     impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4437 #endif
4438 }
4439
4440 #if ENABLE(TIZEN_APPLICATION_CACHE)
4441 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4442 {
4443     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4444     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4445
4446     if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4447         return false;
4448
4449     impl->isWaitingForApplicationCachePermission = true;
4450     if (impl->applicationCachePermissionOrigin)
4451         deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4452     impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4453
4454     return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4455 }
4456 #endif
4457
4458 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4459 {
4460 #if ENABLE(TIZEN_APPLICATION_CACHE)
4461     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4462     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4463
4464     if (!impl->applicationCachePermissionContext)
4465         impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4466     impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4467     impl->applicationCachePermissionContext->userData = userData;
4468 #else
4469     UNUSED_PARAM(ewkView);
4470     UNUSED_PARAM(callback);
4471     UNUSED_PARAM(userData);
4472 #endif
4473 }
4474
4475 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4476 {
4477 #if ENABLE(TIZEN_APPLICATION_CACHE)
4478     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4479     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4480
4481     TIZEN_LOGI("allow %d", allow);
4482     WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4483     if (impl->applicationCachePermissionOrigin)
4484         deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4485     impl->applicationCachePermissionOrigin = 0;
4486     impl->isWaitingForApplicationCachePermission = false;
4487 #else
4488     UNUSED_PARAM(ewkView);
4489     UNUSED_PARAM(allow);
4490 #endif
4491 }
4492
4493 #if ENABLE(TIZEN_INDEXED_DATABASE)
4494 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4495 {
4496     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4497     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4498
4499     if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4500         return false;
4501
4502     impl->isWaitingForExceededQuotaPopupReply = true;
4503     if (impl->exceededQuotaOrigin)
4504         deleteSecurityOrigin(impl->exceededQuotaOrigin);
4505     impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4506
4507     TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4508
4509     return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4510 }
4511 #endif
4512
4513 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4514 {
4515 #if ENABLE(TIZEN_INDEXED_DATABASE)
4516     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4517     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4518
4519     if (!impl->exceededIndexedDatabaseQuotaContext)
4520         impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4521     impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4522     impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4523 #else
4524     UNUSED_PARAM(ewkView);
4525     UNUSED_PARAM(callback);
4526     UNUSED_PARAM(userData);
4527 #endif
4528 }
4529
4530 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4531 {
4532 #if ENABLE(TIZEN_INDEXED_DATABASE)
4533     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4534     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4535
4536     TIZEN_LOGI("allow %d", allow);
4537     WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4538     if (impl->exceededQuotaOrigin)
4539         deleteSecurityOrigin(impl->exceededQuotaOrigin);
4540     impl->exceededQuotaOrigin = 0;
4541     impl->isWaitingForExceededQuotaPopupReply = false;
4542 #else
4543     UNUSED_PARAM(ewkView);
4544     UNUSED_PARAM(allow);
4545 #endif
4546 }
4547
4548 // EwkFindOptions should be matched up orders with WkFindOptions.
4549 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4550 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4551 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4552 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4553 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4554 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4555 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4556 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4557
4558 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4559 {
4560     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4561     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4562     EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4563
4564     impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4565
4566     return true;
4567 }
4568
4569 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4570 {
4571     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4572     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4573
4574     impl->pageProxy->hideFindUI();
4575
4576     return true;
4577 }
4578
4579 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4580 {
4581     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4582     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4583     EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4584
4585     impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4586
4587     return true;
4588 }