2 Copyright (C) 2011 Samsung Electronics
3 Copyright (C) 2012 Intel Corporation. All rights reserved.
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.
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.
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.
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"
42 #include "WebContext.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>
59 #include <WebKit2/WKPageGroup.h>
60 #include <wtf/text/CString.h>
62 #if ENABLE(FULLSCREEN_API)
63 #include "WebFullScreenManagerProxy.h"
66 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
73 #include "DrawingAreaProxyImpl.h"
76 #include "WKDownload.h"
78 #include "WKGeolocationPermissionRequest.h"
79 #include "WKImageCairo.h"
80 #include "WKOpenPanelParameters.h"
81 #include "WKOpenPanelResultListener.h"
83 #include "WKPageGroup.h"
85 #include "WKPageTizen.h"
86 #include "WKPreferences.h"
87 #include "WKSerializedScriptValue.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"
100 #include <Elementary.h>
101 #include <WebCore/EflScreenUtilities.h>
102 #include <WebCore/NotImplemented.h>
105 #if ENABLE(TIZEN_ICON_DATABASE)
106 #include "WKContextPrivate.h"
109 #if ENABLE(TIZEN_GEOLOCATION)
110 #include "ewk_geolocation_private.h"
111 #include "ewk_security_origin.h"
112 #include "ewk_view_geolocation_provider.h"
115 #if ENABLE(TOUCH_EVENTS)
116 #include "NativeWebTouchEvent.h"
117 #include "WebEvent.h"
120 #if ENABLE(TIZEN_ISF_PORT)
121 #include <Ecore_IMF.h>
124 #if ENABLE(TIZEN_NOTIFICATIONS)
126 #include "WKNotificationManager.h"
127 #include "WKNumber.h"
128 #include "ewk_notification_private.h"
129 #include "ewk_view_notification_provider.h"
132 #if ENABLE(TIZEN_MEDIA_STREAM)
133 #include "WKUserMediaPermissionRequest.h"
134 #include "ewk_user_media_private.h"
137 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
138 #include "WebPageGroup.h"
139 #include "WebPreferences.h"
142 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
143 #include "ewk_hit_test_private.h"
146 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
147 #include "ewk_text_style.h"
150 #if ENABLE(TIZEN_SCREEN_READER)
151 #include "ScreenReaderProxy.h"
154 #if ENABLE(TIZEN_CSP)
155 #include <WebCore/ContentSecurityPolicy.h>
158 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
159 #include "WKDictionary.h"
160 #include "ewk_web_application_icon_data_private.h"
162 #endif // #if OS(TIZEN)
164 using namespace WebKit;
165 using namespace WebCore;
167 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
169 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
170 bool result = true; \
173 EINA_LOG_CRIT("null is not a ewk_view"); \
177 const char* _tmp_otype = evas_object_type_get(ewkView); \
178 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
179 if (EINA_UNLIKELY(!_tmp_s)) { \
181 ("%p (%s) is not a smart object!", \
182 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
186 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
187 if (EINA_UNLIKELY(!_tmp_sc)) { \
189 ("%p (%s) is not a smart object!", \
190 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
194 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
196 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
197 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
198 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
203 #define EWK_VIEW_SD_GET(ewkView, smartData) \
204 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
205 Ewk_View_Smart_Data* smartData = 0; \
207 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView)
209 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
210 EWK_VIEW_SD_GET(ewkView, smartData); \
213 EINA_LOG_CRIT("no smart data for object %p (%s)", \
214 ewkView, evas_object_type_get(ewkView)); \
215 return __VA_ARGS__; \
220 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
221 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
222 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
223 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
224 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
226 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);
228 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
229 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);
230 #if ENABLE(TIZEN_MULTIPLE_SELECT)
231 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
233 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
234 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
236 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
237 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
238 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
241 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
242 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
245 #if ENABLE(TIZEN_DATALIST_ELEMENT)
246 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
247 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
250 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
251 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
252 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
254 #endif // #if OS(TIZEN)
256 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
258 if (smartData->changed.any)
260 smartData->changed.any = true;
261 evas_object_smart_changed(smartData->self);
264 #if !ENABLE(TIZEN_ICON_DATABASE)
265 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
267 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
268 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
269 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
271 const char* viewURL = ewk_view_url_get(ewkView);
272 if (!viewURL || strcasecmp(viewURL, pageURL))
275 impl->informIconChange();
279 // Default Event Handling.
280 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
282 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
286 impl->pageClient->setViewFocused(true);
287 #endif // #if OS(TIZEN)
288 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
289 #if ENABLE(TIZEN_ISF_PORT)
290 if (impl->inputMethodContext())
291 impl->inputMethodContext()->onFocusIn();
296 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
298 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
302 #if ENABLE(TIZEN_ISF_PORT)
303 // Keypad should be hidden rapidly when moving focus on elementary
304 // because Ecore-ime doesn't support it.
305 if (impl->inputMethodContext())
306 impl->inputMethodContext()->onFocusOut();
309 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
310 if (impl->pageClient->isTextSelectionMode())
311 impl->pageClient->setIsTextSelectionMode(false);
314 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
315 if (impl->pageClient->isContextMenuVisible())
316 impl->pageProxy->hideContextMenu();
319 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
320 if (impl->pageClient->isClipboardWindowOpened())
321 impl->pageClient->closeClipboardWindow();
324 #if ENABLE(TIZEN_DRAG_SUPPORT)
325 if (impl->pageClient->isDragMode())
326 impl->pageClient->setDragMode(false);
329 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
330 if (smartData->api->formdata_candidate_is_showing(smartData))
331 smartData->api->formdata_candidate_hide(smartData);
334 impl->pageClient->setViewFocused(false);
335 #endif // #if OS(TIZEN)
336 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
340 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
342 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
344 impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
348 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
350 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
352 impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
356 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
358 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
360 impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
362 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
363 if (inputMethodContext)
364 inputMethodContext->handleMouseUpEvent(upEvent);
369 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
371 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
373 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
374 impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
378 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
380 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
382 bool isFiltered = false;
383 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
384 if (inputMethodContext)
385 inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
387 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
391 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
393 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
395 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
400 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
402 #if ENABLE(TIZEN_GESTURE)
403 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
405 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
406 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
410 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
411 if (impl->focusRing) {
412 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
413 impl->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
414 } else if (event->type == EWK_GESTURE_PAN) {
415 if (impl->exceedTouchMoveThreshold)
416 impl->focusRing->hide();
418 if (event->type != EWK_GESTURE_LONG_PRESS) {
419 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
420 if (!impl->pageClient->isContextMenuVisible())
422 impl->focusRing->hide();
428 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
429 if (smartData->api->formdata_candidate_is_showing(smartData))
430 smartData->api->formdata_candidate_hide(smartData);
433 switch (event->type) {
434 case EWK_GESTURE_TAP:
435 impl->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
437 case EWK_GESTURE_LONG_PRESS: {
438 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
439 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
440 if (ewk_settings_text_selection_enabled_get(impl->settings()))
441 impl->pageClient->setIsTextSelectionMode(false);
443 IntPoint scenePoint(event->position.x, event->position.y);
444 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
445 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(contentsPoint);
446 if (!hitTestResultData.absoluteMediaURL.isEmpty())
448 #if ENABLE(TIZEN_DRAG_SUPPORT)
449 // 1. Check to start dragging.
450 if (hitTestResultData.isDragSupport) {
451 impl->pageClient->setDragPoint(scenePoint);
452 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
454 impl->focusRing->show(IntRect(), true);
456 impl->gestureClient->showContextMenu(scenePoint);
460 // 2. Check to show context menu.
461 if (!hitTestResultData.absoluteImageURL.isEmpty()
462 || !hitTestResultData.absoluteLinkURL.isEmpty()) {
463 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
465 impl->focusRing->show(IntRect(), true);
467 impl->gestureClient->showContextMenu(scenePoint);
470 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
471 // 3. Check for text selection.
472 if (ewk_settings_text_selection_enabled_get(impl->settings())) {
473 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
474 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
475 if (smartData->api && smartData->api->gesture_end) {
476 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
477 smartData->api->gesture_end(smartData, &tapEvent);
481 if (impl->pageClient->textSelectionDown(scenePoint)) {
482 impl->gestureClient->setGestureEnabled(false);
483 impl->feedTouchEventsByType(EWK_TOUCH_CANCEL);
488 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
490 case EWK_GESTURE_PAN:
491 impl->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
493 case EWK_GESTURE_FLICK:
494 impl->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
496 case EWK_GESTURE_PINCH:
497 if (impl->pageClient->viewportConstraints().userScalable)
498 impl->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
501 ASSERT_NOT_REACHED();
508 #endif // #if ENABLE(TIZEN_GESTURE)
511 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
513 #if ENABLE(TIZEN_GESTURE)
514 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
516 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
517 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
521 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
522 if (impl->focusRing) {
523 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
524 if (!impl->pageClient->isContextMenuVisible())
526 impl->focusRing->hide();
530 switch (event->type) {
531 case EWK_GESTURE_TAP:
532 if (event->count == 1) {
533 #if ENABLE(TIZEN_DRAG_SUPPORT)
534 if (impl->pageClient->isDragMode())
535 impl->pageClient->setDragMode(false);
537 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
538 if (impl->pageClient->isTextSelectionMode())
539 impl->pageClient->setIsTextSelectionMode(false);
542 #if ENABLE(TIZEN_ISF_PORT)
543 if (impl->inputMethodContext()->isIMEPostion(event->position.x, event->position.y))
547 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
548 } else if (event->count == 2)
549 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
551 case EWK_GESTURE_LONG_PRESS:
552 #if ENABLE(TIZEN_DRAG_SUPPORT)
553 if (impl->pageClient->isDragMode())
554 impl->pageClient->setDragMode(false);
556 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
557 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
559 case EWK_GESTURE_PAN:
560 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
562 case EWK_GESTURE_FLICK:
563 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
565 case EWK_GESTURE_PINCH:
566 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
569 ASSERT_NOT_REACHED();
576 #endif // #if ENABLE(TIZEN_GESTURE)
579 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
581 #if ENABLE(TIZEN_GESTURE)
582 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
584 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
585 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
589 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
590 if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold))
591 impl->focusRing->hide();
594 switch (event->type) {
595 case EWK_GESTURE_PAN:
596 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
598 case EWK_GESTURE_TAP:
599 case EWK_GESTURE_LONG_PRESS:
600 case EWK_GESTURE_FLICK:
602 case EWK_GESTURE_PINCH:
603 if (impl->pageClient->viewportConstraints().userScalable)
604 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
607 ASSERT_NOT_REACHED();
614 #endif // #if ENABLE(TIZEN_GESTURE)
616 #endif //#if OS(TIZEN)
619 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
621 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
622 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
623 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
624 smartData->api->focus_in(smartData);
627 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
629 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
630 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
631 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
632 smartData->api->focus_out(smartData);
635 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
637 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
638 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
639 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
640 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
641 smartData->api->mouse_wheel(smartData, wheelEvent);
644 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
646 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
647 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
648 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
649 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
650 smartData->api->key_down(smartData, downEvent);
653 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
655 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
656 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
657 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
658 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
659 smartData->api->key_up(smartData, upEvent);
662 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
664 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
665 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
666 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
669 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
671 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
672 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
674 // This call may look wrong, but we really need to pass ViewIsVisible here.
675 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
676 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
677 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
682 #if ENABLE(TIZEN_FULLSCREEN_API)
683 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
685 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
687 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
688 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", 0);
692 Eina_Bool _ewk_view_smart_fullscreen_exit(Ewk_View_Smart_Data* smartData)
694 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
696 ewk_view_main_frame_scrollbar_visible_set(impl->view(), true);
697 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
702 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
703 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
705 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
707 return impl->pageClient->textSelectionDown(IntPoint(x, y), true);
710 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
712 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
714 IntPoint point(x, y);
715 impl->pageClient->textSelectionMove(point, true);
720 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
722 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
724 IntPoint point(x, y);
725 impl->pageClient->textSelectionUp(point, true);
731 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
732 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
734 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
736 impl->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
741 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
743 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
745 impl->pageClient->hideFormDataCandidate();
750 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
752 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
754 Vector<String> formData;
757 EINA_LIST_FOREACH(dataList, list, data)
758 formData.append(String::fromUTF8(static_cast<char*>(data)));
760 impl->pageClient->updateFormDataCandidate(formData);
765 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
767 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
769 return impl->pageClient->isShowingFormDataCandidate();
773 #if ENABLE(TIZEN_SCREEN_READER)
774 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
776 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
778 return ScreenReaderProxy::screenReader().executeAction(impl, static_cast<Elm_Access_Action_Info*>(actionInfo));
781 #endif // #if OS(TIZEN)
783 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
785 static void _ewk_view_impl_del(EwkViewImpl* impl)
787 #if !ENABLE(TIZEN_ICON_DATABASE)
788 /* Unregister icon change callback */
789 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
790 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
796 static void _ewk_view_smart_add(Evas_Object* ewkView)
798 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
799 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
800 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
801 EWK_VIEW_SD_GET(ewkView, smartData);
804 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
806 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
809 evas_object_smart_data_set(ewkView, smartData);
812 smartData->self = ewkView;
813 smartData->api = api;
815 g_parentSmartClass.add(ewkView);
817 smartData->priv = new EwkViewImpl(ewkView);
818 if (!smartData->priv) {
819 EINA_LOG_CRIT("could not allocate EwkViewImpl");
820 evas_object_smart_data_set(ewkView, 0);
825 // Create evas_object_image to draw web contents.
826 smartData->image = evas_object_image_add(smartData->base.evas);
827 evas_object_image_alpha_set(smartData->image, false);
828 evas_object_image_filled_set(smartData->image, true);
829 evas_object_smart_member_add(smartData->image, ewkView);
832 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
833 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
834 const char *engine = ecore_evas_engine_name_get(ee);
835 if (engine && !strcmp(engine, "opengl_x11"))
836 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
838 ewk_view_mouse_events_enabled_set(ewkView, false);
839 ewk_view_touch_events_enabled_set(ewkView, true);
841 // FIXME: This code should be removed if side effect occur.
842 // WebView does not have focus after url loading.
843 // If focus is set as true to webview,
844 // elementary steal webview's focus during mouse up event
845 // So, added code that events are not propagated to smart parent according to guide from EFL
846 evas_object_propagate_events_set(ewkView, false);
847 #endif // #if OS(TIZEN)
849 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
850 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
851 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
852 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
853 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
854 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
855 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
856 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
860 static void _ewk_view_smart_del(Evas_Object* ewkView)
862 EwkViewImpl::removeFromPageViewMap(ewkView);
863 EWK_VIEW_SD_GET(ewkView, smartData);
864 #if ENABLE(TIZEN_SCREEN_READER)
865 ScreenReaderProxy::screenReader().disable(smartData->priv);
867 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
868 // Close color picker if it's opened.
869 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
870 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
872 if (smartData && smartData->priv)
873 _ewk_view_impl_del(smartData->priv);
875 g_parentSmartClass.del(ewkView);
878 static Eina_Bool _ewk_view_composite(void* data);
880 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
882 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
884 evas_object_resize(smartData->image, width, height);
885 evas_object_image_size_set(smartData->image, width, height);
886 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
888 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
889 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
890 evas_object_image_native_surface_set(smartData->image, 0);
892 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
893 if (!ewk_view_is_opengl_backend(ewkView))
894 _ewk_view_composite(smartData);
895 else // OpenGL backend
897 impl->pageClient->displayViewport();
899 #endif // #if OS(TIZEN)
901 smartData->changed.size = true;
902 _ewk_view_smart_changed(smartData);
905 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
907 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
909 smartData->changed.position = true;
910 _ewk_view_smart_changed(smartData);
913 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
915 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
916 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
918 Evas_Coord x, y, width, height;
920 smartData->changed.any = false;
922 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
924 if (smartData->changed.size) {
926 #if USE(COORDINATED_GRAPHICS)
927 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
929 #if USE(ACCELERATED_COMPOSITING)
930 needsNewSurface = impl->evasGlSurface;
933 if (impl->pageProxy->drawingArea())
934 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
936 #if USE(ACCELERATED_COMPOSITING)
937 if (!impl->evasGlSurface)
939 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
940 impl->evasGlSurface = 0;
941 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
942 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
944 #endif // #if !OS(TIZEN)
946 smartData->view.w = width;
947 smartData->view.h = height;
948 smartData->changed.size = false;
951 if (impl->pageClient) {
952 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
953 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
954 if (impl->pageProxy->isViewVisible())
955 drawingArea->setSize(IntSize(width, height), IntSize());
957 drawingArea->setSize(IntSize(width, height), IntSize());
959 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
960 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
961 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
962 if (ewk_view_is_opengl_backend(ewkView))
963 impl->pageClient->displayViewport();
966 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
967 impl->pageClient->frameRectChanged();
970 #endif // #if OS(TIZEN)
973 if (smartData->changed.position) {
974 evas_object_move(smartData->image, x, y);
975 smartData->view.x = x;
976 smartData->view.y = y;
977 smartData->changed.position = false;
979 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
980 impl->pageClient->frameRectChanged();
982 #if ENABLE(TIZEN_SCREEN_READER)
983 impl->pageProxy->recalcScreenReaderFocusRect();
985 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
986 impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
988 #endif // #if OS(TIZEN)
991 if (impl->popupPicker)
992 ewk_popup_picker_resize(impl->popupPicker);
993 #endif // #if OS(TIZEN)
996 static void _ewk_view_smart_show(Evas_Object* ewkView)
998 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
999 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1001 if (evas_object_clipees_get(smartData->base.clipper))
1002 evas_object_show(smartData->base.clipper);
1003 evas_object_show(smartData->image);
1006 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1008 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1010 evas_object_hide(smartData->base.clipper);
1011 evas_object_hide(smartData->image);
1012 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1013 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1014 if (impl->pageClient->isTextSelectionMode())
1015 impl->pageClient->setIsTextSelectionMode(false);
1019 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1021 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1022 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1026 else if (alpha > 255)
1029 #define CHECK_COLOR(color, alpha) \
1032 else if (color > alpha) \
1034 CHECK_COLOR(red, alpha);
1035 CHECK_COLOR(green, alpha);
1036 CHECK_COLOR(blue, alpha);
1039 evas_object_image_alpha_set(smartData->image, alpha < 255);
1040 impl->pageProxy->setDrawsBackground(red || green || blue);
1041 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1042 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1045 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1049 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1051 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1053 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1054 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1055 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1059 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1060 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1062 evas_object_smart_clipped_smart_set(&api->sc);
1064 // Set Evas_Smart_Class functions.
1065 api->sc.add = _ewk_view_smart_add;
1066 api->sc.del = _ewk_view_smart_del;
1067 api->sc.move = _ewk_view_smart_move;
1068 api->sc.resize = _ewk_view_smart_resize;
1069 api->sc.show = _ewk_view_smart_show;
1070 api->sc.hide = _ewk_view_smart_hide;
1071 api->sc.color_set = _ewk_view_smart_color_set;
1072 api->sc.calculate = _ewk_view_smart_calculate;
1073 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1075 // Set Ewk_View_Smart_Class functions.
1076 api->focus_in = _ewk_view_smart_focus_in;
1077 api->focus_out = _ewk_view_smart_focus_out;
1078 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1079 api->mouse_down = _ewk_view_smart_mouse_down;
1080 api->mouse_up = _ewk_view_smart_mouse_up;
1081 api->mouse_move = _ewk_view_smart_mouse_move;
1082 api->key_down = _ewk_view_smart_key_down;
1083 api->key_up = _ewk_view_smart_key_up;
1085 api->gesture_start = _ewk_view_smart_gesture_start;
1086 api->gesture_end = _ewk_view_smart_gesture_end;
1087 api->gesture_move = _ewk_view_smart_gesture_move;
1089 #if ENABLE(TIZEN_FULLSCREEN_API)
1090 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1091 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1094 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1095 api->popup_menu_show = _ewk_view_popup_menu_show;
1096 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1097 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1099 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1100 api->popup_menu_update = _ewk_view_popup_menu_update;
1102 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1103 api->text_selection_down = _ewk_view_text_selection_down;
1104 api->text_selection_move = _ewk_view_text_selection_move;
1105 api->text_selection_up = _ewk_view_text_selection_up;
1107 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1108 api->input_picker_show = _ewk_view_input_picker_show;
1110 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1111 api->data_list_show = _ewk_view_data_list_show;
1112 api->data_list_hide = _ewk_view_data_list_hide;
1114 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1115 api->orientation_lock = _ewk_orientation_lock;
1116 api->orientation_unlock = _ewk_orientation_unlock;
1118 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1119 api->input_picker_color_request = _ewk_input_picker_color_request;
1120 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1122 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1123 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1124 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1125 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1126 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1128 #if ENABLE(TIZEN_SCREEN_READER)
1129 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1131 #endif //#if OS(TIZEN)
1136 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1138 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1139 static Evas_Smart* smart = 0;
1141 if (EINA_UNLIKELY(!smart)) {
1142 ewk_view_smart_class_set(&api);
1143 smart = evas_smart_class_new(&api.sc);
1149 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1151 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1152 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1153 EINA_SAFETY_ON_NULL_RETURN(context);
1155 if (impl->pageClient)
1158 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1159 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1161 impl->pageClient = PageClientEvasGL::create(impl);
1163 impl->pageClient = PageClientImpl::create(impl);
1165 impl->pageClient = PageClientImpl::create(impl);
1169 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1171 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1173 EwkViewImpl::addToPageViewMap(ewkView);
1176 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1177 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1178 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1179 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1182 impl->pageProxy->initializeWebPage();
1184 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1185 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1187 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1190 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1191 impl->pageProxy->setUseFixedLayout(true);
1193 #if ENABLE(FULLSCREEN_API)
1194 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1197 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1199 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1201 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1202 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1203 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1207 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1209 impl->context = context;
1212 ewkViewContextMenuClientAttachClient(ewkView);
1213 ewkViewTizenClientAttachClient(ewkView);
1215 #if ENABLE(TIZEN_GEOLOCATION)
1216 ewkViewGeolocationProviderAttachProvider(ewkView, impl->context->wkContext());
1219 #if ENABLE(TIZEN_NOTIFICATIONS)
1220 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1223 #if ENABLE(TIZEN_ICON_DATABASE)
1224 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1227 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1228 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1229 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1230 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1231 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1233 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1234 #else // #if OS(TIZEN)
1235 #if USE(COORDINATED_GRAPHICS)
1236 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1238 #endif // #if OS(TIZEN)
1240 #if ENABLE(FULLSCREEN_API)
1241 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1242 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1245 // Initialize page clients.
1246 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1247 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1248 impl->pageUIClient = PageUIClientEfl::create(impl);
1249 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1250 impl->findClient = FindClientEfl::create(impl);
1251 impl->formClient = FormClientEfl::create(impl);
1252 #if !ENABLE(TIZEN_ICON_DATABASE)
1253 /* Listen for favicon changes */
1254 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1255 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1257 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1258 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1261 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1262 if (!impl->context->xWindow())
1263 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1266 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1267 impl->focusRing = FocusRing::create(impl);
1271 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1273 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1274 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1276 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1278 using namespace EGL;
1279 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1280 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1286 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1290 EWK_VIEW_SD_GET(ewkView, smartData);
1292 evas_object_del(ewkView);
1296 EWK_VIEW_IMPL_GET(smartData, impl);
1298 evas_object_del(ewkView);
1307 * Constructs a ewk_view Evas_Object with WKType parameters.
1309 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1311 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1312 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1314 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1318 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1323 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1325 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1326 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1327 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1329 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1333 #if ENABLE(TIZEN_ICON_DATABASE)
1334 //set default iconDatabasePath
1335 WKContextRef contextRef = context->wkContext();
1336 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1339 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1340 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1341 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1342 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1344 _ewk_view_initialize(ewkView, context, 0);
1350 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1352 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1353 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1356 Evas_Object* ewk_view_add(Evas* canvas)
1358 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1361 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1363 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1364 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1366 return impl->ewkContext();
1369 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1371 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1372 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1373 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1375 impl->pageProxy->loadURL(String::fromUTF8(url));
1376 impl->informURLChange();
1381 const char* ewk_view_url_get(const Evas_Object* ewkView)
1383 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1384 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1389 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1391 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1392 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1394 return impl->faviconURL();
1397 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1399 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1400 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1402 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1403 impl->informURLChange();
1408 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1410 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1411 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1413 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1414 impl->informURLChange();
1419 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1421 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1422 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1424 impl->pageProxy->stopLoading();
1429 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1431 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1432 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1434 return impl->settings();
1437 const char* ewk_view_title_get(const Evas_Object* ewkView)
1439 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1440 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1442 return impl->title();
1447 * Reports that the requested text was found.
1449 * Emits signal: "text,found" with the number of matches.
1451 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1453 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1456 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1458 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1459 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1461 return impl->pageProxy->estimatedProgress();
1464 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1466 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1467 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1473 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1475 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1476 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1477 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1478 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1480 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1482 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1487 double ewk_view_scale_get(const Evas_Object* ewkView)
1489 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1490 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1493 return impl->pageProxy->scaleFactor();
1495 return impl->pageProxy->pageScaleFactor();
1499 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1501 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1502 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1504 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1509 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1511 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1512 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1514 return impl->pageProxy->deviceScaleFactor();
1517 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1519 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1520 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1522 impl->setThemePath(path);
1525 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1527 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1528 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1530 return impl->themePath();
1533 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1535 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1536 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1538 WebPageProxy* page = impl->pageProxy.get();
1539 if (page->canGoBack()) {
1547 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1549 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1550 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1552 WebPageProxy* page = impl->pageProxy.get();
1553 if (page->canGoForward()) {
1561 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1563 #if ENABLE(WEB_INTENTS)
1564 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1565 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1566 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1568 WebPageProxy* page = impl->pageProxy.get();
1569 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1577 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1579 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1580 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1582 return impl->pageProxy->canGoBack();
1585 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1587 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1588 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1590 return impl->pageProxy->canGoForward();
1593 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1595 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1596 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1598 return impl->backForwardList.get();
1601 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1602 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1604 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1605 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1607 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1610 if (value.isEmpty()) {
1611 if(smartData->api->formdata_candidate_is_showing(smartData))
1612 smartData->api->formdata_candidate_hide(smartData);
1616 Vector<String> popupCandidates;
1617 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1618 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1620 Eina_List* candidateList = 0;
1621 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1622 if (popupCandidates[i].startsWith(value, false))
1623 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1626 if (!eina_list_count(candidateList)) {
1627 if(smartData->api->formdata_candidate_is_showing(smartData))
1628 smartData->api->formdata_candidate_hide(smartData);
1632 smartData->api->formdata_candidate_update_data(smartData, candidateList);
1634 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1635 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1638 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
1640 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1641 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1642 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1643 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1645 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1648 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1650 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1651 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1653 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1656 Vector<std::pair<String, String> > passwordFormData;
1657 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1659 if (!passwordFormData.size())
1662 String passwordFormAutofill = String::fromUTF8("try { function passwordFormAutofill() { var inputFields;");
1663 for (size_t i = 0; i < passwordFormData.size(); i++) {
1664 passwordFormAutofill += String::fromUTF8(" inputFields = document.getElementsByName(\"");
1665 passwordFormAutofill += passwordFormData[i].first;
1666 passwordFormAutofill += String::fromUTF8("\");");
1667 passwordFormAutofill += String::fromUTF8(" for (var i = 0; i < inputFields.length; i++)");
1668 passwordFormAutofill += String::fromUTF8(" if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\"))");
1669 passwordFormAutofill += String::fromUTF8(" inputFields[i].value = \"");
1670 passwordFormAutofill += passwordFormData[i].second;
1671 passwordFormAutofill += String::fromUTF8("\";");
1673 passwordFormAutofill += String::fromUTF8("} passwordFormAutofill(); } catch(e) { }");
1674 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1677 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1679 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1680 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1681 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1685 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1687 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1688 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1689 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1691 if (unreachableUrl && *unreachableUrl)
1692 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1694 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1696 impl->informURLChange();
1701 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1703 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1704 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1706 return impl->customTextEncodingName();
1709 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1711 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1712 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1714 impl->setCustomTextEncodingName(encoding);
1720 // FIXME: It should be removed.
1721 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1723 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1724 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1726 return toAPI(impl->pageProxy.get());
1729 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1731 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1732 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1734 impl->setMouseEventsEnabled(!!enabled);
1739 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1741 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1744 return impl->mouseEventsEnabled();
1747 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1749 #if ENABLE(INPUT_TYPE_COLOR)
1750 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1751 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1753 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1759 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1761 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1762 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1764 return impl->javascriptPopup->alert(alertText);
1767 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1769 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1770 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1772 return impl->javascriptPopup->confirm(message);
1775 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1777 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1778 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1780 return impl->javascriptPopup->prompt(message, defaultValue);
1783 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1784 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1786 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1787 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1789 return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1793 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)
1795 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1796 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1798 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1801 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1802 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)
1804 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1806 if (impl->popupPicker)
1807 ewk_popup_picker_del(impl->popupPicker);
1809 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1810 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1812 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1818 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1819 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)
1821 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1823 if (impl->popupPicker)
1824 ewk_popup_picker_del(impl->popupPicker);
1826 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1832 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1834 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1836 if (!impl->popupPicker)
1839 ewk_popup_picker_del(impl->popupPicker);
1840 impl->popupPicker = 0;
1845 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)
1847 // FIXME: The rect should be updated if it was changed
1849 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1851 if (!impl->popupPicker)
1854 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1860 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1861 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1863 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1865 impl->inputPicker->show(inputType, inputValue);
1870 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1871 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1873 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1875 impl->inputPicker->showDataList(inputType, optionList);
1879 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1881 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1883 impl->inputPicker->hideDataList(inputType);
1888 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1889 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1891 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1893 impl->inputPicker->showColorPicker(r, g, b, a);
1897 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1899 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1901 impl->inputPicker->hideColorPicker();
1906 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1908 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1909 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1911 return impl->pageClient.get();
1914 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
1916 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1917 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
1919 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
1922 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
1924 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1925 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1927 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
1931 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1932 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
1934 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1935 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1937 return impl->focusRing.get();
1941 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
1943 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1944 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1946 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
1949 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
1951 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1952 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1954 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
1957 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
1959 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1960 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1962 if (!impl->javascriptGlobalContext)
1963 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
1964 return impl->javascriptGlobalContext;
1967 void ewkViewLoadCommitted(Evas_Object* ewkView)
1969 #if ENABLE(TIZEN_GESTURE)
1970 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1971 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1972 impl->gestureClient->reset();
1974 #if ENABLE(TIZEN_ISF_PORT)
1975 impl->inputMethodContext()->hideIMFContext();
1977 impl->informURLChange();
1978 evas_object_smart_callback_call(ewkView, "load,committed", 0);
1981 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
1983 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1984 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1986 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
1987 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
1988 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
1991 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
1993 #if ENABLE(TIZEN_GESTURE)
1994 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1995 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1996 impl->gestureClient->reset();
1998 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2001 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2003 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2004 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2006 if (impl->authChallenge)
2007 ewkAuthChallengeDelete(impl->authChallenge);
2008 impl->authChallenge = authChallenge;
2010 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2013 void ewk_view_process_crashed(Evas_Object* ewkView)
2015 bool handled = false;
2016 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2022 #if ENABLE(TIZEN_SQL_DATABASE)
2023 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2025 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2026 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2028 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2031 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2032 impl->isWaitingForExceededQuotaPopupReply = true;
2033 if (impl->exceededQuotaOrigin)
2034 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2035 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2037 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2038 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2039 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2041 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2045 #if ENABLE(TIZEN_NOTIFICATIONS)
2046 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2048 TIZEN_LOGI("notification,cancel");
2049 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2052 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2054 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2055 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2057 TIZEN_LOGI("notification,permission,request");
2058 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2059 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2062 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2064 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2065 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2067 TIZEN_LOGI("notification,show");
2068 Eina_List* listIterator=0;
2070 const char* replaceID = ewkNotificationGetReplaceID(notification);
2071 if(strlen(replaceID)) {
2072 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2073 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2074 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2075 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2079 impl->notifications = eina_list_append(impl->notifications, notification);
2080 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2083 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2085 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2086 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2088 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2092 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2093 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2095 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2097 TIZEN_LOGI("protocolhandler,registration,requested");
2098 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2099 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2100 ewkCustomHandlersDeleteData(customHandlersData);
2104 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2105 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2107 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2109 TIZEN_LOGI("protocolhandler,isregistered");
2110 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2111 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2113 Ewk_Custom_Handlers_State result;
2114 result = ewkGetCustomHandlersDataResult(customHandlersData);
2115 ewkCustomHandlersDeleteData(customHandlersData);
2120 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2122 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2124 TIZEN_LOGI("protocolhandler,unregistration,requested");
2125 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2126 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2127 ewkCustomHandlersDeleteData(customHandlersData);
2131 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2132 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2134 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2136 TIZEN_LOGI("contenthandler,registration,requested");
2137 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2138 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2139 ewkCustomHandlersDeleteData(customHandlersData);
2142 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2144 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2146 TIZEN_LOGI("contenthandler,isregistered");
2147 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2148 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2150 Ewk_Custom_Handlers_State result;
2151 result = ewkGetCustomHandlersDataResult(customHandlersData);
2152 ewkCustomHandlersDeleteData(customHandlersData);
2157 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2159 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2161 TIZEN_LOGI("contenthandler,unregistration,requested");
2162 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2163 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2164 ewkCustomHandlersDeleteData(customHandlersData);
2168 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2169 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2171 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2173 TIZEN_LOGI("searchProvider,add");
2174 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2175 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2176 ewkSearchProviderDeleteData(searchProviderData);
2179 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2181 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2183 TIZEN_LOGI("searchProvider,installed");
2184 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2185 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2186 unsigned long result;
2187 result = ewkGetSearchProviderResult(searchProviderData);
2188 ewkSearchProviderDeleteData(searchProviderData);
2193 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2194 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2196 TIZEN_LOGI("webapp,metatag,standalone");
2197 bool standalone = true;
2198 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2203 #if ENABLE(TIZEN_MEDIA_STREAM)
2204 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2206 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2207 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2209 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2210 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2213 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2215 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2216 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2218 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2223 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2224 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2226 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2227 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2228 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2229 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2230 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2231 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2233 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2237 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2238 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2240 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2241 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2242 if (impl->certificatePolicyDecision)
2243 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2244 impl->certificatePolicyDecision = certificatePolicyDecision;
2246 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2250 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2252 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2255 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2257 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2260 #if ENABLE(TIZEN_GEOLOCATION)
2261 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2263 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2264 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2266 TIZEN_LOGI("geolocation,permission,request");
2267 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2268 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2271 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2273 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2274 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2276 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2279 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2281 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2282 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2284 impl->geolocation = geolocation;
2287 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2289 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2290 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2292 return impl->geolocation;
2295 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2297 TIZEN_LOGI("geolocation,valid");
2300 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2305 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2307 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2310 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2312 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2313 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2314 if (impl->policyDecision)
2315 ewkPolicyDecisionDelete(impl->policyDecision);
2316 impl->policyDecision = policyDecision;
2318 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2321 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2323 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2324 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2325 if (impl->policyDecision)
2326 ewkPolicyDecisionDelete(impl->policyDecision);
2327 impl->policyDecision = policyDecision;
2329 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2332 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2334 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2335 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2336 if (impl->policyDecision)
2337 ewkPolicyDecisionDelete(impl->policyDecision);
2338 impl->policyDecision = policyDecision;
2340 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2343 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2345 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2346 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2348 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2349 IntSize contentsSize = impl->pageProxy->contentsSize();
2350 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2351 contentsSize.scale(impl->pageClient->scaleFactor());
2354 // some website's contents size is smaller than view size,
2355 // so we have to adjust contents size to view size for that case.
2356 if (contentsSize.width() < smartData->view.w)
2357 contentsSize.setWidth(smartData->view.w);
2358 if (contentsSize.height() < smartData->view.h)
2359 contentsSize.setHeight(smartData->view.h);
2361 // Call "scroll,down" if webview can be scrolled down.
2362 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2363 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2364 // Call "scroll,up" if webview can be scrolled up.
2365 else if (deltaY < 0 && scrollPosition.y() > 0)
2366 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2368 // Call "scroll,right" if webview can be scrolled down.
2369 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2370 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2371 // Call "scroll,left" if webview can be scrolled up.
2372 else if (deltaX < 0 && scrollPosition.x() > 0)
2373 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2376 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2378 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2379 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2381 IntSize contentsSize = impl->pageProxy->contentsSize();
2382 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2383 contentsSize.scale(impl->pageClient->scaleFactor());
2386 int maxScrollY = contentsSize.height() - smartData->view.h;
2387 if (!impl->isVerticalEdge) {
2388 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2389 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2390 impl->isVerticalEdge = true;
2391 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2392 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2393 impl->isVerticalEdge = true;
2396 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2397 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2398 impl->isVerticalEdge = false;
2401 int maxScrollX = contentsSize.width() - smartData->view.w;
2402 if (!impl->isHorizontalEdge) {
2403 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2404 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2405 impl->isHorizontalEdge = true;
2406 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2407 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2408 impl->isHorizontalEdge = true;
2411 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2412 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2413 impl->isHorizontalEdge = false;
2417 void ewkViewClearEdges(Evas_Object* ewkView)
2419 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2420 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2422 impl->isVerticalEdge = false;
2423 impl->isHorizontalEdge = false;
2426 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2428 EWK_VIEW_SD_GET(ewkView, smartData);
2429 if (!smartData || !smartData->priv) {
2437 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2439 *minimumScale = constraints.minimumScale;
2441 *maximumScale = constraints.maximumScale;
2444 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
2446 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2447 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2449 double scaleFactor = impl->pageClient->scaleFactor();
2450 IntSize contentsSize = impl->pageProxy->contentsSize();
2452 double newScaleFactor = scaleFactor;
2453 // Readable zoom value is dependent on device DPI
2454 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2455 && impl->pageClient->viewportConstraints().userScalable)
2456 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2458 // Readable zoom value should be inside of viewport scale range
2459 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2461 // scale contents' size with new scale factor
2462 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2463 contentsSize.scale(newScaleFactor);
2465 contentsSize.scale(newScaleFactor / scaleFactor);
2468 #if ENABLE(TIZEN_ISF_PORT)
2469 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
2470 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2471 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
2472 unsigned int connectedKeyboardNum = 0;
2473 bool isExternalKeyboardConnected = false;
2475 // get connected keyboard number
2476 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
2477 && connectedKeyboardNum)
2478 isExternalKeyboardConnected = true;
2480 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2481 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2482 // input field zoom should not work with below conditions
2483 // 1. view is not focused
2484 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2485 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2486 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2487 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2488 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
2489 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2490 || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
2491 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2492 && !(impl->pageClient->isClipboardWindowOpened())
2498 // caret position can be outside of visible rect.
2499 // we need to consider it.
2500 IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
2501 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2502 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2503 selectionRect.scale(newScaleFactor);
2504 focusedNodeRect.scale(newScaleFactor);
2506 selectionRect.scale(newScaleFactor / scaleFactor);
2507 focusedNodeRect.scale(newScaleFactor / scaleFactor);
2509 if (selectionRect.isEmpty())
2512 IntRect visibleRect = impl->pageClient->visibleContentRect();
2513 IntPoint scrollPosition = visibleRect.location();
2514 // Do not adjust scroll position if selection rect (caret) is visible after scaling.
2515 if (!visibleRect.contains(selectionRect)) {
2517 scrollPosition = IntPoint(selectionRect.x() - visibleRect.width() / 3, selectionRect.y() - visibleRect.height() / 3);
2518 // If both input field's position x and selection rect can be displayed together,
2519 // adjust scroll position to input field's position x.
2520 if (!focusedNodeRect.isEmpty() && selectionRect.x() - focusedNodeRect.x() < visibleRect.width() * 4 / 5)
2521 scrollPosition.setX(focusedNodeRect.x());
2524 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2525 impl->pageClient->setVisibleContentRect(IntRect(scrollPosition, impl->size()), newScaleFactor);
2527 if (newScaleFactor != scaleFactor)
2528 impl->pageProxy->scalePage(newScaleFactor, scrollPosition);
2530 impl->pageProxy->scrollMainFrameTo(scrollPosition);
2532 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
2536 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2537 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2538 static Eina_Bool _ewk_view_composite(void* data)
2540 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2541 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2543 if (!evas_object_visible_get(smartData->image))
2544 return ECORE_CALLBACK_CANCEL;
2547 evas_object_image_size_get(smartData->image, &ow, &oh);
2548 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2550 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)));
2551 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2553 cairo_save(context.get());
2554 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2555 cairo_rectangle(context.get(), 0, 0, ow, oh);
2556 cairo_fill(context.get());
2557 cairo_restore(context.get());
2559 impl->pageClient->drawContents(context.get());
2561 evas_object_image_data_set(smartData->image, pixels);
2562 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2564 ewkViewFrameRendered(smartData->self);
2566 impl->compositionAnimator = 0;
2568 return ECORE_CALLBACK_CANCEL;
2572 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2574 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2575 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2577 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2578 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2580 if (!ewk_view_is_opengl_backend(ewkView)) {
2581 if (!impl->compositionAnimator)
2582 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2587 evas_object_image_pixels_dirty_set(smartData->image, true);
2590 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2592 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2593 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2594 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2595 impl->pageClient->drawContents();
2598 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2601 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2603 if (!smartData->image)
2606 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2607 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2613 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2615 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2616 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2618 if (!impl->suspendedPainting) {
2619 impl->pageProxy->suspendPainting();
2620 impl->suspendedPainting = true;
2624 void _ewk_view_resume_painting(Evas_Object* ewkView)
2626 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2627 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2629 if (impl->suspendedPainting) {
2630 impl->pageProxy->resumePainting();
2631 impl->suspendedPainting = false;
2635 void ewk_view_suspend(Evas_Object* ewkView)
2637 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2638 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2640 if (impl->pageProxy->estimatedProgress() < 1.0) {
2641 impl->suspendRequested = true;
2644 impl->suspendRequested = false;
2646 _ewk_view_suspend_painting(ewkView);
2648 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2649 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2650 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2652 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2653 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2654 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2655 // will be suspended again.
2656 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2657 // the ActiveDOMObject.
2658 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2659 impl->pageProxy->suspendAnimations();
2660 impl->pageProxy->suspendJavaScriptAndResource();
2661 impl->suspendedResources = true;
2664 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2665 impl->pageProxy->suspendPlugin();
2669 void ewk_view_resume(Evas_Object* ewkView)
2671 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2672 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2674 if (impl->suspendRequested) {
2675 impl->suspendRequested = false;
2679 _ewk_view_resume_painting(ewkView);
2681 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2682 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2683 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2685 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2686 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2687 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2688 // will be suspended again.
2689 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2690 // the ActiveDOMObject.
2691 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2692 impl->pageProxy->resumeAnimations();
2693 impl->pageProxy->resumeJavaScriptAndResource();
2694 impl->suspendedResources = false;
2697 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2698 impl->pageProxy->resumePlugin();
2702 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2704 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2705 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2706 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2708 ResourceRequest request(String::fromUTF8(url));
2711 case EWK_HTTP_METHOD_GET:
2712 request.setHTTPMethod("GET");
2714 case EWK_HTTP_METHOD_HEAD:
2715 request.setHTTPMethod("HEAD");
2717 case EWK_HTTP_METHOD_POST:
2718 request.setHTTPMethod("POST");
2720 case EWK_HTTP_METHOD_PUT:
2721 request.setHTTPMethod("PUT");
2723 case EWK_HTTP_METHOD_DELETE:
2724 request.setHTTPMethod("DELETE");
2731 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2733 while (eina_iterator_next(it, &data)) {
2734 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2735 const char* name = static_cast<const char*>(t->key);
2736 const char* value = static_cast<const char*>(t->data);
2737 request.addHTTPHeaderField(name, value);
2739 eina_iterator_free(it);
2743 request.setHTTPBody(FormData::create(body));
2745 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2746 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2751 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2753 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2754 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2756 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2757 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2762 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2764 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2765 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2766 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2768 if (contentsSize == 0)
2771 String mimeTypeString;
2773 mimeTypeString = String::fromUTF8(mimeType);
2775 mimeTypeString = String::fromUTF8("text/html");
2777 String encodingString;
2779 encodingString = String::fromUTF8(encoding);
2781 encodingString = String::fromUTF8("UTF-8");
2783 String baseUriString;
2785 baseUriString = String::fromUTF8(baseUri);
2787 baseUriString = String::fromUTF8("about:blank");
2789 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2790 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2795 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2797 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2798 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2800 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2801 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2803 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2808 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2810 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2811 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2813 TIZEN_LOGI("initialState (%d)", initialState);
2814 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2815 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2822 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2824 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2826 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2827 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2829 impl->userAgent = userAgent;
2831 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2832 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2837 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2839 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2840 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2842 if (!impl->userAgent) {
2843 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2845 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2846 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2847 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2848 impl->userAgent = buffer.get();
2851 return impl->userAgent;
2853 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2855 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2856 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2857 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2859 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2860 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2862 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2865 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2870 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2872 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2873 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2874 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2876 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2878 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2881 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2886 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2888 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2889 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2890 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2892 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2895 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2900 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2901 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2903 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2904 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2906 #if ENABLE(TIZEN_DRAG_SUPPORT)
2907 if (impl->pageClient->isDragMode())
2908 impl->pageClient->setDragMode(false);
2911 #if ENABLE(TIZEN_SCREEN_READER)
2913 ScreenReaderProxy::screenReader().enable(impl);
2916 impl->pageClient->setIsVisible(enable);
2921 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
2922 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
2928 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
2930 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
2932 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2933 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2936 rect.origin.x = viewArea.x;
2937 rect.origin.y = viewArea.y;
2938 rect.size.width = viewArea.w;
2939 rect.size.height = viewArea.h;
2941 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
2942 if (!snapshot.get())
2945 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
2947 Evas_Object* screenshotImage = evas_object_image_add(canvas);
2948 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
2949 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
2950 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
2951 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
2953 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
2955 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)));
2956 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
2958 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
2959 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
2960 cairo_fill(cairo.get());
2962 evas_object_image_smooth_scale_set(screenshotImage, true);
2963 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
2964 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
2965 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
2966 evas_object_image_data_set(screenshotImage, pixels);
2968 return screenshotImage;
2971 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
2973 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
2974 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
2975 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
2977 return impl->pageProxy->startInspectorServer(port);
2979 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
2984 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
2986 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
2987 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
2988 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
2990 return impl->pageProxy->stopInspectorServer();
2992 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
2997 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
2999 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3000 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3002 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3005 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3011 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3012 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3014 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3016 *x = scrollPosition.x();
3018 *y = scrollPosition.y();
3023 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3025 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3026 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3028 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3032 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3038 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3039 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3041 IntSize contentsSize = impl->pageProxy->contentsSize();
3042 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3043 contentsSize.scale(impl->pageClient->scaleFactor());
3046 if (width && contentsSize.width() > smartData->view.w)
3047 *width = contentsSize.width() - smartData->view.w;
3048 if (height && contentsSize.height() > smartData->view.h)
3049 *height = contentsSize.height() - smartData->view.h;
3053 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3055 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3056 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3057 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3059 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3061 impl->isWaitingForJavaScriptPopupReply = true;
3062 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3063 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3064 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3065 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3068 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3070 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3071 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3072 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3074 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3076 impl->isWaitingForJavaScriptPopupReply = true;
3077 int length = WKStringGetMaximumUTF8CStringSize(message);
3078 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3079 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3080 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3083 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3085 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3086 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3087 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3089 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3091 impl->isWaitingForJavaScriptPopupReply = true;
3092 int length = WKStringGetMaximumUTF8CStringSize(message);
3093 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3094 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3095 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3096 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3097 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3098 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3101 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3102 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3104 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3105 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3106 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3108 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3110 impl->isWaitingForJavaScriptPopupReply = true;
3111 int length = WKStringGetMaximumUTF8CStringSize(message);
3112 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3113 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3114 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3119 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3121 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3122 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3123 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3126 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3128 impl->openPanelListener = listener;
3130 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3131 Eina_List* acceptedMimeTypes = 0;
3132 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3133 size_t len = WKArrayGetSize(array.get());
3134 for (size_t i = 0; i < len; i++) {
3135 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3136 if (WKGetTypeID(item) != WKStringGetTypeID())
3138 WKStringRef mime = static_cast<WKStringRef>(item);
3139 int length = WKStringGetMaximumUTF8CStringSize(mime);
3140 char* buffer = new char[length];
3141 WKStringGetUTF8CString(mime, buffer, length);
3142 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3144 const char* capture = 0;
3145 #if ENABLE(MEDIA_CAPTURE)
3146 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3147 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3149 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3150 if (!acceptedMimeTypes)
3155 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3156 delete[] (char*)data;
3157 eina_list_free(acceptedMimeTypes);
3161 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3163 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3164 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3166 if (!impl->alertContext)
3167 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3168 impl->alertContext->javascriptAlertCallback = callback;
3169 impl->alertContext->ewkView = ewkView;
3170 impl->alertContext->userData = userData;
3173 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3175 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3176 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3178 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3179 impl->isWaitingForJavaScriptPopupReply = false;
3182 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3184 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3185 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3187 if (!impl->confirmContext)
3188 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3189 impl->confirmContext->javascriptConfirmCallback = callback;
3190 impl->confirmContext->ewkView = ewkView;
3191 impl->confirmContext->userData = userData;
3194 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3196 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3197 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3199 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3200 impl->isWaitingForJavaScriptPopupReply = false;
3203 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3205 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3206 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3208 if (!impl->promptContext)
3209 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3210 impl->promptContext->javascriptPromptCallback = callback;
3211 impl->promptContext->ewkView = ewkView;
3212 impl->promptContext->userData = userData;
3215 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3217 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3218 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3220 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3221 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3222 impl->isWaitingForJavaScriptPopupReply = false;
3225 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3226 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3228 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3229 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3231 if (!impl->beforeUnloadConfirmPanelContext)
3232 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3233 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3234 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3235 impl->beforeUnloadConfirmPanelContext->userData = userData;
3238 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3240 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3241 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3243 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3244 impl->isWaitingForJavaScriptPopupReply = false;
3248 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3250 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3251 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3253 if (!impl->openpanelContext)
3254 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3256 impl->openpanelContext->openPanelCallback = callback;
3257 impl->openpanelContext->ewkView = ewkView;
3258 impl->openpanelContext->userData = userData;
3261 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3263 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3264 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3266 if (!impl->openPanelListener)
3269 unsigned int size = eina_list_count(fileUrls);
3270 if ((result == EINA_FALSE) || (size == 0)) {
3271 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3272 impl->openPanelListener = 0;
3276 WKTypeRef* items = new WKTypeRef[size];
3280 KURL base(KURL(), "file://");
3281 EINA_LIST_FOREACH(fileUrls, list, data) {
3282 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3283 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3285 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3286 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3287 impl->openPanelListener = 0;
3289 eina_list_free(fileUrls);
3292 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3293 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3295 EINA_SAFETY_ON_NULL_RETURN(capable);
3296 EINA_SAFETY_ON_NULL_RETURN(context);
3298 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3300 ASSERT(webAppContext->webAppCapableCallback);
3302 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3304 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3306 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3308 delete webAppContext;
3311 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3313 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3314 EINA_SAFETY_ON_NULL_RETURN(context);
3316 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3318 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3319 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3321 ASSERT(webAppContext->webAppIconURLCallback);
3324 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3325 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3327 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3329 delete webAppContext;
3332 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3334 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3335 EINA_SAFETY_ON_NULL_RETURN(context);
3337 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3339 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3340 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3342 ASSERT(webAppContext->webAppIconURLsCallback);
3344 if (impl->webAppIconURLs) {
3346 EINA_LIST_FREE(impl->webAppIconURLs, data)
3347 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3350 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3351 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3352 for (size_t i = 0; i < iconURLCount; i++) {
3353 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3354 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3355 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3357 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3359 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3360 delete webAppContext;
3364 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3366 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3367 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3368 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3369 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3371 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3372 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3373 context->webAppCapableCallback = callback;
3374 context->ewkView = ewkView;
3375 context->userData = userData;
3377 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3385 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3387 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3388 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3389 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3390 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3392 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3393 context->webAppIconURLCallback = callback;
3394 context->ewkView = ewkView;
3395 context->userData = userData;
3397 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3405 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3407 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3408 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3409 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3410 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3412 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3413 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3414 context->webAppIconURLsCallback = callback;
3415 context->ewkView = ewkView;
3416 context->userData = userData;
3418 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3422 UNUSED_PARAM(ewkView);
3423 UNUSED_PARAM(callback);
3424 UNUSED_PARAM(userData);
3429 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3431 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3432 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3433 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3435 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3436 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3437 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3442 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3449 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3450 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3452 IntSize contentsSize = impl->pageProxy->contentsSize();
3455 *width = contentsSize.width();
3457 *height = contentsSize.height();
3462 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3464 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3465 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3466 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3467 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3469 IntSize contentsSize = impl->pageProxy->contentsSize();
3470 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3478 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3480 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3481 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3482 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3483 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3485 IntSize contentsSize = impl->pageProxy->contentsSize();
3486 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3494 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3496 EINA_SAFETY_ON_NULL_RETURN(context);
3497 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3499 if (!callbackContext->scriptExecuteCallback) {
3500 delete callbackContext;
3504 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3507 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3508 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3509 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3510 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3511 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3512 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3514 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3516 delete callbackContext;
3519 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3521 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3522 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3523 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3524 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3526 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3527 context->scriptExecuteCallback = callback;
3528 context->ewkView = ewkView;
3529 context->userData = user_data;
3530 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3531 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3536 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3537 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3539 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3542 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3544 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3546 delete storageContext;
3550 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3552 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3553 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3554 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3556 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3557 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3559 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3560 context->webStorageQuotaCallback = resultCallback;
3561 context->userData = userData;
3563 WKPageRef pageRef = toAPI(impl->page());
3564 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3572 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3574 #if ENABLE(TIZEN_WEB_STORAGE)
3575 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3576 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3577 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3579 TIZEN_LOGI("quota (%d)", quota);
3580 WKPageRef pageRef = toAPI(impl->page());
3581 WKPageSetWebStorageQuota(pageRef, quota);
3589 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3591 EINA_SAFETY_ON_NULL_RETURN(context);
3592 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3594 ASSERT(callbackContext->plainTextGetCallback);
3597 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3598 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3599 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3601 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3603 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3605 delete callbackContext;
3608 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3610 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3611 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3612 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3613 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3615 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3616 context->plainTextGetCallback = callback;
3617 context->ewkView = ewkView;
3618 context->userData = user_data;
3619 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3624 #if ENABLE(TIZEN_SUPPORT_MHTML)
3627 * Callback function used for ewk_view_mhtml_data_get().
3629 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3631 EINA_SAFETY_ON_NULL_RETURN(context);
3632 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3634 ASSERT(callbackContext->mhtmlDataGetCallback);
3636 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3638 delete callbackContext;
3641 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3643 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3644 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3645 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3647 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3648 context->mhtmlDataGetCallback = callback;
3649 context->ewkView = ewkView;
3650 context->userData = user_data;
3652 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3656 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3658 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3660 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3661 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3662 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3664 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3665 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3666 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3674 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3676 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3677 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3678 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3679 WebPageProxy* page = impl->page();
3680 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3682 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3685 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3690 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3692 #if ENABLE(TIZEN_NOTIFICATIONS)
3693 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3694 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3695 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3697 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3698 if (!eina_list_count(ewkNotifications))
3701 Eina_List* listIterator = 0;
3703 Vector<WKTypeRef> ids;
3704 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3705 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3706 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3708 impl->notifications = eina_list_remove(impl->notifications, notification);
3711 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3712 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3713 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3714 ewkNotificationDeleteNotificationList(ewkNotifications);
3722 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3723 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3725 Eina_List* popupItems = 0;
3726 size_t size = items.size();
3727 for (size_t i = 0; i < size; ++i)
3728 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3729 TIZEN_LOGI("size : %d", size);
3733 static void releasePopupMenuList(Eina_List* popupMenuItems)
3735 if (!popupMenuItems)
3739 EINA_LIST_FREE(popupMenuItems, item)
3740 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3744 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3746 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3747 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3748 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3750 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3753 if (!impl->popupMenuProxy)
3756 impl->popupMenuProxy = 0;
3758 if (smartData->api->popup_menu_hide)
3759 smartData->api->popup_menu_hide(smartData);
3760 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3761 ewk_view_touch_events_enabled_set(ewkView, true);
3763 releasePopupMenuList(impl->popupMenuItems);
3764 impl->popupMenuItems = 0;
3767 EINA_LIST_FREE(impl->popupMenuItems, item)
3768 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3774 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3776 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3777 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3778 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3780 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3782 if (!impl->popupMenuItems)
3786 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3789 impl->popupMenuProxy->valueChanged(selectedIndex);
3794 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3795 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3797 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3798 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3799 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3800 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3802 if (!impl->popupMenuProxy)
3805 if (!smartData->api->popup_menu_update)
3808 releasePopupMenuList(impl->popupMenuItems);
3809 impl->popupMenuItems = createPopupMenuList(items);
3811 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3812 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3816 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3817 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3819 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3820 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3821 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3823 Vector<int> selectedIndex;
3825 if (!impl->popupMenuItems)
3830 itr = eina_inarray_iterator_new(changeList);
3831 EINA_ITERATOR_FOREACH(itr, data)
3833 int* pData = static_cast<int*>(data);
3834 selectedIndex.append(*pData);
3836 eina_iterator_free(itr);
3838 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3843 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3845 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3846 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3847 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3848 TIZEN_LOGI("orientation : %d", orientation);
3850 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3853 if (impl->orientation == orientation)
3856 impl->orientation = orientation;
3858 impl->pageProxy->sendOrientationChangeEvent(orientation);
3862 void ewkViewFrameRendered(Evas_Object* ewkView)
3864 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3867 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3868 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3870 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3873 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3875 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3876 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3878 IntRect leftSelectionRect;
3879 IntRect rightSelectionRect;
3880 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3893 AffineTransform contentToScreen = impl->transformToScene();
3894 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3895 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3897 leftRect->x = leftSelectionRect.x();
3898 leftRect->y = leftSelectionRect.y();
3899 leftRect->w = leftSelectionRect.width();
3900 leftRect->h = leftSelectionRect.height();
3902 rightRect->x = rightSelectionRect.x();
3903 rightRect->y = rightSelectionRect.y();
3904 rightRect->w = rightSelectionRect.width();
3905 rightRect->h = rightSelectionRect.height();
3910 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
3912 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3913 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3915 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
3916 impl->selectedText = selectedString.data();
3918 return impl->selectedText;
3921 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
3923 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
3926 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
3928 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
3931 void ewk_view_text_selection_range_clear(Evas_Object* ewkView)
3933 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3934 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3936 impl->pageProxy->selectionRangeClear();
3938 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3940 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3941 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
3943 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3944 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3945 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
3947 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
3951 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
3952 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
3954 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3955 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3956 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
3958 *x = drawingPosition.x();
3960 *y = drawingPosition.y();
3962 *w = impl->pageClient->visibleContentRect().width();
3964 *h = impl->pageClient->visibleContentRect().height();
3968 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
3970 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3971 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3972 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3974 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
3975 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3978 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
3980 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3981 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3982 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3984 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
3985 return impl->inputValue;
3988 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3991 #if ENABLE(TIZEN_DATALIST_ELEMENT)
3992 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
3994 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3995 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3996 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3997 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4000 ewkViewDataListHideRequest(ewkView, inputType);
4002 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4004 impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
4007 smartData->api->data_list_show(smartData, inputType, impl->dataList);
4010 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4012 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4013 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4014 EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
4015 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4016 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4018 impl->deleteDataList();
4020 smartData->api->data_list_hide(smartData, inputType);
4024 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4026 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4027 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4028 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4030 impl->deleteDataList();
4032 ewk_view_focused_input_element_value_set(ewkView, value);
4036 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4038 #if ENABLE(TIZEN_GESTURE)
4039 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4040 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4041 return impl->holdHorizontalPanning;
4047 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4049 #if ENABLE(TIZEN_GESTURE)
4050 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4051 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4052 impl->holdHorizontalPanning = hold;
4056 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4058 #if ENABLE(TIZEN_GESTURE)
4059 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4060 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4061 return impl->holdVerticalPanning;
4067 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4069 #if ENABLE(TIZEN_GESTURE)
4070 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4071 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4072 impl->holdVerticalPanning = hold;
4076 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4078 #if ENABLE(TIZEN_GESTURE)
4079 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4080 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4082 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4083 if (impl->focusRing && wasHandled)
4084 impl->focusRing->hide();
4085 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4087 if (impl->mouseEventsEnabled())
4090 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4091 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4092 if (type == WebEvent::TouchStart)
4093 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4094 else if (type == WebEvent::TouchMove)
4095 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4096 else if (type == WebEvent::TouchEnd)
4097 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4101 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4102 // The Pan and Flick will be enabled if Touch Start was not handled,
4103 // and Touch Move was not handled or did not occur.
4104 // Tap will be enabled if Touch Start and End was not handled
4105 // and Touch Move did not occur.
4106 // The gestures are disabled as a default.
4107 // o: handled, x: not handled
4108 // ------------------------------------------------------------
4109 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4110 // ------------------------------------------------------------
4111 // o | o or x | o or x || disable | disable
4112 // x | o | o or x || disable | disable
4113 // x | x | o or x || disable | enable
4114 // x |not occured | x || enable | enable
4115 // ------------------------------------------------------------
4116 if (type == WebEvent::TouchStart) {
4117 impl->gestureClient->setGestureEnabled(!wasHandled);
4118 impl->wasHandledTouchStart = wasHandled;
4120 // Initialize wasHandledTouchMove to true and notify that to the application
4121 // to prevent applications scrolling at the beginning of touch.
4122 impl->wasHandledTouchMove = true;
4123 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4124 } else if (type == WebEvent::TouchMove) {
4125 impl->gestureClient->setMovingEnabled(!wasHandled);
4127 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4128 if (impl->wasHandledTouchStart)
4131 // Notify the result of touchmove to applications when handled value is changed
4132 // in order to make applications to choose whether scrolling its scrollable objects or not.
4133 if (impl->wasHandledTouchMove != wasHandled)
4134 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4135 impl->wasHandledTouchMove = wasHandled;
4136 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4138 impl->gestureClient->setMovingEnabled(!wasHandled);
4139 impl->gestureClient->setTapEnabled(!wasHandled);
4141 #if ENABLE(TIZEN_ISF_PORT)
4143 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4144 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4145 if (hitTestResultData.isContentEditable && impl->inputMethodContext()) {
4146 evas_object_focus_set(ewkView, true);
4147 impl->inputMethodContext()->updateTextInputState();
4155 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4156 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
4158 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4159 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4161 EditorState editorState = impl->page()->editorState();
4163 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint, editorState.bgColor, editorState.color);
4164 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4165 ewkTextStyleDelete(textStyle);
4169 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4170 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4172 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4173 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4175 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4176 if (!smartData->api->orientation_lock) {
4181 return smartData->api->orientation_lock(smartData, willLockOrientation);
4184 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4186 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4187 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4189 TIZEN_LOGI("ewkView (%p)", ewkView);
4190 if (!smartData->api->orientation_unlock) {
4195 smartData->api->orientation_unlock(smartData);
4199 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4201 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4202 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4203 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4204 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4206 impl->orientationLock.callback = func;
4207 impl->orientationLock.data = data;
4211 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4212 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4214 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4215 TIZEN_LOGI("locked orientations : %d", orientations);
4217 if (impl->orientationLock.callback)
4218 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4223 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4225 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4226 TIZEN_LOGI("unlock is requested");
4228 if (impl->orientationLock.callback)
4229 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4233 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4234 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4236 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4238 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4239 const char *engine = ecore_evas_engine_name_get(ee);
4240 if (engine && !strcmp(engine, "opengl_x11"))
4246 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4248 #if ENABLE(TIZEN_GESTURE)
4249 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4250 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4252 impl->gestureClient->setZoomableArea(target, area);
4256 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4257 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4259 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4260 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4262 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4266 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4267 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4269 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4273 #if ENABLE(TIZEN_ICON_DATABASE)
4274 void ewkViewIconReceived(Evas_Object* ewkView)
4278 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4282 #endif // #if OS(TIZEN)
4284 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4286 #if ENABLE(TOUCH_EVENTS)
4287 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4288 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4289 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4291 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4292 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4293 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4294 IntPoint handlePoint(point->x, point->y);
4296 if (type == EWK_TOUCH_START)
4297 impl->pageClient->textSelectonHandleDown(handlePoint);
4298 else if (type == EWK_TOUCH_MOVE)
4299 impl->pageClient->textSelectonHandleMove(handlePoint);
4301 impl->pageClient->textSelectonHandleUp();
4303 if (impl->pageClient->isTextSelectionHandleDowned())
4308 #if ENABLE(TIZEN_GESTURE)
4309 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4310 // We don't want to process touch event when context menu is shown.
4311 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4312 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4313 && !impl->pageClient->isTextSelectionMode()
4318 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4319 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4323 if (type == EWK_TOUCH_START) {
4324 if (eina_list_count(points) == 1) {
4325 impl->gestureClient->reset();
4326 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4327 impl->touchDownPoint.x = point->x;
4328 impl->touchDownPoint.y = point->y;
4329 impl->exceedTouchMoveThreshold = false;
4331 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4332 if (eina_list_count(points) == 1) {
4333 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4334 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4335 int diffX = impl->touchDownPoint.x - point->x;
4336 int diffY = impl->touchDownPoint.y - point->y;
4337 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4338 impl->exceedTouchMoveThreshold = true;
4342 impl->exceedTouchMoveThreshold = true;
4345 #endif // #if ENABLE(TIZEN_GESTURE)
4347 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4348 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4349 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4357 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4359 #if ENABLE(TOUCH_EVENTS)
4360 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4361 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4363 impl->setTouchEventsEnabled(!!enabled);
4371 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4373 #if ENABLE(TOUCH_EVENTS)
4374 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4375 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4377 return impl->touchEventsEnabled();
4383 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4385 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4386 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4387 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4389 impl->mainFrameScrollbarVisibility = visible;
4390 impl->pageClient->updateVisibility();
4398 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4400 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4401 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4402 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4404 return impl->mainFrameScrollbarVisibility;
4410 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4412 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4413 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4414 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4415 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4417 String title = ewk_view_title_get(ewkView);
4418 String url = ewk_view_url_get(ewkView);
4419 String directoryPath(path);
4420 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4424 UNUSED_PARAM(ewkView);
4432 * Callback function used for ewk_view_page_contents_get().
4434 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4436 EINA_SAFETY_ON_NULL_RETURN(context);
4438 RefPtr<WebData> webData = toImpl(wkData);
4439 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4440 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4445 * Callback function used for ewk_view_page_contents_get().
4447 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4449 EINA_SAFETY_ON_NULL_RETURN(context);
4451 RefPtr<WebString> webString = toImpl(wkString);
4452 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4453 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4456 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4458 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4459 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4460 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4461 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4463 switch (context->type) {
4464 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4465 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4468 case EWK_PAGE_CONTENTS_TYPE_STRING:
4469 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4473 ASSERT_NOT_REACHED();
4480 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4482 #if ENABLE(TIZEN_GESTURE)
4483 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4484 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4486 return impl->gestureClient->scrollToWithAnimation(x, y);
4488 UNUSED_PARAM(ewkView);
4495 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4496 void ewkViewFocusRingHide(Evas_Object* ewkView)
4498 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4499 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4501 if (impl->focusRing)
4502 impl->focusRing->hide();
4506 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4508 #if ENABLE(TIZEN_CSP)
4509 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4510 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4512 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4513 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4517 #if ENABLE(TIZEN_APPLICATION_CACHE)
4518 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4520 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4521 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4523 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4526 impl->isWaitingForApplicationCachePermission = true;
4527 if (impl->applicationCachePermissionOrigin)
4528 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4529 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4531 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4535 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4537 #if ENABLE(TIZEN_APPLICATION_CACHE)
4538 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4539 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4541 if (!impl->applicationCachePermissionContext)
4542 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4543 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4544 impl->applicationCachePermissionContext->userData = userData;
4546 UNUSED_PARAM(ewkView);
4547 UNUSED_PARAM(callback);
4548 UNUSED_PARAM(userData);
4552 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4554 #if ENABLE(TIZEN_APPLICATION_CACHE)
4555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4556 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4558 TIZEN_LOGI("allow %d", allow);
4559 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4560 if (impl->applicationCachePermissionOrigin)
4561 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4562 impl->applicationCachePermissionOrigin = 0;
4563 impl->isWaitingForApplicationCachePermission = false;
4565 UNUSED_PARAM(ewkView);
4566 UNUSED_PARAM(allow);
4570 #if ENABLE(TIZEN_INDEXED_DATABASE)
4571 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4573 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4574 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4576 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4579 impl->isWaitingForExceededQuotaPopupReply = true;
4580 if (impl->exceededQuotaOrigin)
4581 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4582 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4584 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4586 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4590 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4592 #if ENABLE(TIZEN_INDEXED_DATABASE)
4593 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4594 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4596 if (!impl->exceededIndexedDatabaseQuotaContext)
4597 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4598 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4599 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4601 UNUSED_PARAM(ewkView);
4602 UNUSED_PARAM(callback);
4603 UNUSED_PARAM(userData);
4607 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4609 #if ENABLE(TIZEN_INDEXED_DATABASE)
4610 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4611 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4613 TIZEN_LOGI("allow %d", allow);
4614 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4615 if (impl->exceededQuotaOrigin)
4616 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4617 impl->exceededQuotaOrigin = 0;
4618 impl->isWaitingForExceededQuotaPopupReply = false;
4620 UNUSED_PARAM(ewkView);
4621 UNUSED_PARAM(allow);
4625 // EwkFindOptions should be matched up orders with WkFindOptions.
4626 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4627 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4628 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4629 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4630 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4631 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4632 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4633 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4635 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4637 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4638 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4639 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4641 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4646 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4648 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4649 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4651 impl->pageProxy->hideFindUI();
4656 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4658 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4659 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4660 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4662 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4667 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4669 #if ENABLE(TIZEN_SQL_DATABASE)
4670 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4671 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4673 if (!impl->exceededDatabaseQuotaContext)
4674 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4675 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4676 impl->exceededDatabaseQuotaContext->userData = userData;
4678 UNUSED_PARAM(ewkView);
4679 UNUSED_PARAM(callback);
4680 UNUSED_PARAM(userData);
4684 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4686 #if ENABLE(TIZEN_SQL_DATABASE)
4687 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4688 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4690 TIZEN_LOGI("allow %d", allow);
4691 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4692 if (impl->exceededQuotaOrigin)
4693 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4694 impl->exceededQuotaOrigin = 0;
4695 impl->isWaitingForExceededQuotaPopupReply = false;
4697 UNUSED_PARAM(ewkView);
4698 UNUSED_PARAM(allow);
4702 #if ENABLE(TIZEN_FILE_SYSTEM)
4703 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4705 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4706 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4708 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4711 impl->isWaitingForExceededQuotaPopupReply = true;
4712 if (impl->exceededQuotaOrigin)
4713 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4714 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4716 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4718 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4722 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4724 #if ENABLE(TIZEN_FILE_SYSTEM)
4725 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4726 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4728 if (!impl->exceededLocalFileSystemQuotaContext)
4729 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4730 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4731 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4733 UNUSED_PARAM(ewkView);
4734 UNUSED_PARAM(callback);
4735 UNUSED_PARAM(userData);
4739 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4741 #if ENABLE(TIZEN_FILE_SYSTEM)
4742 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4743 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4745 TIZEN_LOGI("allow %d", allow);
4746 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4747 if (impl->exceededQuotaOrigin)
4748 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4749 impl->exceededQuotaOrigin = 0;
4750 impl->isWaitingForExceededQuotaPopupReply = false;
4752 UNUSED_PARAM(ewkView);
4753 UNUSED_PARAM(result);
4757 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4759 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4760 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4761 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4764 if (angle == 0 || angle == 180) {
4765 width = WebCore::getDefaultScreenResolution().width();
4766 height = WebCore::getDefaultScreenResolution().height() + 100;
4768 if (angle == 90 || angle == 270) {
4769 width = WebCore::getDefaultScreenResolution().height();
4770 height = WebCore::getDefaultScreenResolution().width() + 100;
4773 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4774 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4775 ewk_view_suspend(ewkView);
4776 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4780 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4781 void ewkViewRotatePrepared(Evas_Object* ewkView)
4783 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4787 void ewk_view_use_settings_font(Evas_Object* ewkView)
4789 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4790 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4791 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4793 impl->pageProxy->useSettingsFont();