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