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