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