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