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