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