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