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