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