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