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_geolocation_provider_private.h"
112 #include "ewk_security_origin.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"
163 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
164 #include "AutoFillPopup.h"
166 #endif // #if OS(TIZEN)
168 using namespace WebKit;
169 using namespace WebCore;
171 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
173 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
174 bool result = true; \
177 EINA_LOG_CRIT("null is not a ewk_view"); \
181 const char* _tmp_otype = evas_object_type_get(ewkView); \
182 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
183 if (EINA_UNLIKELY(!_tmp_s)) { \
185 ("%p (%s) is not a smart object!", \
186 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
190 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
191 if (EINA_UNLIKELY(!_tmp_sc)) { \
193 ("%p (%s) is not a smart object!", \
194 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
198 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
200 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
201 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
202 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
207 #define EWK_VIEW_SD_GET(ewkView, smartData) \
208 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
209 Ewk_View_Smart_Data* smartData = 0; \
211 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView)
213 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
214 EWK_VIEW_SD_GET(ewkView, smartData); \
217 EINA_LOG_CRIT("no smart data for object %p (%s)", \
218 ewkView, evas_object_type_get(ewkView)); \
219 return __VA_ARGS__; \
224 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
225 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
226 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
227 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
228 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
230 static Eina_Bool _ewk_view_default_open_panel(Evas_Object*, Eina_Bool allow_multiple_files, Eina_List *accepted_mime_types, const char* capture, void* userData);
232 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
233 Eina_Bool _ewk_view_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items, int selectedIndex);
234 #if ENABLE(TIZEN_MULTIPLE_SELECT)
235 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
237 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
238 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
240 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
241 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
242 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
245 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
246 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
249 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
250 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
251 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
253 #endif // #if OS(TIZEN)
255 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
257 if (smartData->changed.any)
259 smartData->changed.any = true;
260 evas_object_smart_changed(smartData->self);
263 #if !ENABLE(TIZEN_ICON_DATABASE)
264 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
266 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
267 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
268 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
270 const char* viewURL = ewk_view_url_get(ewkView);
271 if (!viewURL || strcasecmp(viewURL, pageURL))
274 impl->informIconChange();
278 #if ENABLE(TIZEN_GEOLOCATION)
279 static Eina_Bool _ewk_view_geolocation_validity_check(void* eventInfo)
281 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
282 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, true);
283 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, true);
285 return impl->isValidLocationService();
289 // Default Event Handling.
290 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
292 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
296 impl->pageClient->setViewFocused(true);
297 #endif // #if OS(TIZEN)
298 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
299 #if ENABLE(TIZEN_ISF_PORT)
300 if (impl->inputMethodContext())
301 impl->inputMethodContext()->onFocusIn();
306 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
308 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
312 #if ENABLE(TIZEN_ISF_PORT)
313 // Keypad should be hidden rapidly when moving focus on elementary
314 // because Ecore-ime doesn't support it.
315 if (impl->inputMethodContext())
316 impl->inputMethodContext()->onFocusOut();
319 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
320 if (impl->pageClient->isTextSelectionMode() && ewk_settings_clear_text_selection_automatically_get(impl->settings()))
321 impl->pageClient->setIsTextSelectionMode(false);
324 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
325 if (impl->pageClient->isContextMenuVisible())
326 impl->pageProxy->hideContextMenu();
329 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
330 if (impl->pageClient->isClipboardWindowOpened())
331 impl->pageClient->closeClipboardWindow();
334 #if ENABLE(TIZEN_DRAG_SUPPORT)
335 if (impl->pageClient->isDragMode())
336 impl->pageClient->setDragMode(false);
339 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
340 if (smartData->api->formdata_candidate_is_showing(smartData))
341 smartData->api->formdata_candidate_hide(smartData);
344 impl->pageClient->setViewFocused(false);
345 #endif // #if OS(TIZEN)
346 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
350 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
352 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
354 impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
358 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
360 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
362 impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
366 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
368 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
370 impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
372 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
373 if (inputMethodContext)
374 inputMethodContext->handleMouseUpEvent(upEvent);
379 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
381 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
383 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
384 impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
388 #if ENABLE(TIZEN_FOCUS_UI)
389 bool isFocusUIActivationKeyname(const char* key)
391 return !strcmp(key, "Up") || !strcmp(key, "Down") || !strcmp(key, "Left") || !strcmp(key, "Right") || !strcmp(key, "Tab");
395 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
397 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
399 #if ENABLE(TIZEN_FOCUS_UI)
400 if (InputMethodContextEfl::shouldUseExternalKeyboard() && !impl->page()->focusUIEnabled()) {
401 if (isFocusUIActivationKeyname(downEvent->keyname))
402 impl->page()->setFocusUIEnabled(true);
407 bool isFiltered = false;
408 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
409 if (inputMethodContext)
410 inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
412 #if ENABLE(TIZEN_ISF_PORT)
413 NativeWebKeyboardEvent nativeEvent(downEvent, isFiltered);
414 nativeEvent.setInputMethodContextID(impl->pageProxy->editorState().inputMethodContextID);
415 impl->pageProxy->handleKeyboardEvent(nativeEvent);
417 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
423 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
425 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
427 #if ENABLE(TIZEN_FOCUS_UI)
428 if (InputMethodContextEfl::shouldUseExternalKeyboard() && !impl->page()->focusUIEnabled())
432 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
437 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
439 #if ENABLE(TIZEN_GESTURE)
440 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
442 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
443 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
447 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
448 FocusRing* focusRing = impl->focusRing();
450 if (event->type == EWK_GESTURE_TAP) {
451 if (event->count == 1)
452 focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
453 } else if (event->type == EWK_GESTURE_PAN) {
454 if (impl->exceedTouchMoveThreshold)
455 focusRing->requestToHide();
456 } else if (event->type != EWK_GESTURE_LONG_PRESS) {
457 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
458 if (!impl->pageClient->isContextMenuVisible())
460 focusRing->requestToHide();
465 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
466 if (smartData->api->formdata_candidate_is_showing(smartData))
467 smartData->api->formdata_candidate_hide(smartData);
470 switch (event->type) {
471 case EWK_GESTURE_TAP:
472 impl->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
474 case EWK_GESTURE_LONG_PRESS: {
475 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
476 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
477 if (ewk_settings_text_selection_enabled_get(impl->settings()))
478 impl->pageClient->setIsTextSelectionMode(false);
481 IntPoint scenePoint(event->position.x, event->position.y);
482 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
483 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(contentsPoint, WebHitTestResult::HitTestModeDefault | WebHitTestResult::HitTestModeSetFocus);
484 if (!hitTestResultData.absoluteMediaURL.isEmpty())
487 #if ENABLE(TIZEN_DRAG_SUPPORT)
488 // 1. Check to start dragging.
489 if (hitTestResultData.isDragSupport && !hitTestResultData.isContentEditable) {
490 impl->pageClient->setDragPoint(scenePoint);
491 if (impl->pageClient->isDragMode())
492 impl->pageClient->setDragMode(false);
494 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
496 focusRing->showWithContextMenu(scenePoint, hitTestResultData.focusedColor, hitTestResultData.focusedRects);
502 // 2. Check to show context menu.
503 if ((!hitTestResultData.absoluteImageURL.isEmpty() || !hitTestResultData.absoluteLinkURL.isEmpty())
504 && !hitTestResultData.isContentEditable) {
505 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
507 focusRing->showWithContextMenu(scenePoint, hitTestResultData.focusedColor, hitTestResultData.focusedRects);
512 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
513 // 3. Check for text selection.
514 if (ewk_settings_text_selection_enabled_get(impl->settings())) {
515 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
516 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
517 if (smartData->api && smartData->api->gesture_end) {
518 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
519 smartData->api->gesture_end(smartData, &tapEvent);
523 if (impl->pageClient->textSelectionDown(scenePoint)) {
524 impl->gestureClient->setGestureEnabled(false);
525 impl->feedTouchEventsByType(EWK_TOUCH_CANCEL);
530 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
532 case EWK_GESTURE_PAN:
533 impl->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
535 case EWK_GESTURE_FLICK:
536 impl->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
538 case EWK_GESTURE_PINCH:
539 if (impl->pageClient->viewportConstraints().userScalable)
540 impl->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
543 ASSERT_NOT_REACHED();
550 #endif // #if ENABLE(TIZEN_GESTURE)
553 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
555 #if ENABLE(TIZEN_GESTURE)
556 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
558 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
559 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned()) {
560 impl->pageClient->initTextSelectionHandlesMouseDownedStatus();
565 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
566 FocusRing* focusRing = impl->focusRing();
568 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
569 if (!impl->pageClient->isContextMenuVisible() || impl->pageClient->isTextSelectionMode())
571 focusRing->requestToHide();
575 switch (event->type) {
576 case EWK_GESTURE_TAP:
577 if (event->count == 1) {
578 #if ENABLE(TIZEN_DRAG_SUPPORT)
579 if (impl->pageClient->isDragMode())
580 impl->pageClient->setDragMode(false);
582 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
583 if (impl->pageClient->isTextSelectionMode())
584 impl->pageClient->setIsTextSelectionMode(false);
587 #if ENABLE(TIZEN_ISF_PORT)
588 if (impl->inputMethodContext()->isIMEPostion(event->position.x, event->position.y))
592 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
593 } else if (event->count == 2) {
594 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
596 focusRing->requestToHide(true);
598 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
601 case EWK_GESTURE_LONG_PRESS:
602 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
603 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
605 case EWK_GESTURE_PAN:
606 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
608 case EWK_GESTURE_FLICK:
609 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
611 case EWK_GESTURE_PINCH:
612 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
615 ASSERT_NOT_REACHED();
622 #endif // #if ENABLE(TIZEN_GESTURE)
625 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
627 #if ENABLE(TIZEN_GESTURE)
628 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
630 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
631 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
635 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
636 FocusRing* focusRing = impl->focusRing();
637 if (focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold)) {
638 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
639 if (!impl->pageClient->isContextMenuVisible())
641 focusRing->requestToHide(true);
645 switch (event->type) {
646 case EWK_GESTURE_PAN:
647 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
649 case EWK_GESTURE_TAP:
650 case EWK_GESTURE_LONG_PRESS:
651 case EWK_GESTURE_FLICK:
653 case EWK_GESTURE_PINCH:
654 if (impl->pageClient->viewportConstraints().userScalable)
655 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
658 ASSERT_NOT_REACHED();
665 #endif // #if ENABLE(TIZEN_GESTURE)
667 #endif //#if OS(TIZEN)
670 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
672 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
673 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
674 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
675 smartData->api->focus_in(smartData);
678 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
680 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
681 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
682 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
683 smartData->api->focus_out(smartData);
686 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
688 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
689 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
690 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
691 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
692 smartData->api->mouse_wheel(smartData, wheelEvent);
695 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
697 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
698 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
699 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
700 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
701 smartData->api->key_down(smartData, downEvent);
704 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
706 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
707 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
708 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
709 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
710 smartData->api->key_up(smartData, upEvent);
713 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
715 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
716 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
717 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
720 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
722 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
723 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
725 // This call may look wrong, but we really need to pass ViewIsVisible here.
726 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
727 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
728 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
733 #if ENABLE(TIZEN_FULLSCREEN_API)
734 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
736 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
738 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
739 bool isNeed = impl->page()->fullScreenManager()->exitFullScreenByHwBackKey();
740 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", &isNeed);
744 Eina_Bool _ewk_view_smart_fullscreen_exit(Ewk_View_Smart_Data* smartData)
746 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
748 ewk_view_main_frame_scrollbar_visible_set(impl->view(), true);
749 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
754 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
755 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
757 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
759 return impl->pageClient->textSelectionDown(IntPoint(x, y));
762 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
764 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
766 IntPoint point(x, y);
767 impl->pageClient->textSelectionMove(point);
772 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
774 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
776 IntPoint point(x, y);
777 impl->pageClient->textSelectionUp(point, true);
783 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
784 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
786 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
788 impl->pageClient->showAutoFillPopup(IntRect(x, y, w, h));
793 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
795 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
797 impl->pageClient->hideAutoFillPopup();
802 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
804 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
806 Vector<AutoFillPopupItem> formData;
809 EINA_LIST_FOREACH(dataList, list, data)
810 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), candidateAutoFill));
812 impl->pageClient->updateAutoFillPopup(formData);
817 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
819 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
821 return impl->pageClient->isShowingAutoFillPopup();
825 #if ENABLE(TIZEN_SCREEN_READER)
826 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
828 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
830 return ScreenReaderProxy::executeAction(impl, 0, static_cast<Elm_Access_Action_Info*>(actionInfo));
833 #endif // #if OS(TIZEN)
835 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
837 static void _ewk_view_impl_del(EwkViewImpl* impl)
839 #if !ENABLE(TIZEN_ICON_DATABASE)
840 /* Unregister icon change callback */
841 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
842 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
848 static void _ewk_view_smart_add(Evas_Object* ewkView)
850 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
851 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
852 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
853 EWK_VIEW_SD_GET(ewkView, smartData);
856 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
858 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
861 evas_object_smart_data_set(ewkView, smartData);
864 smartData->self = ewkView;
865 smartData->api = api;
867 g_parentSmartClass.add(ewkView);
869 smartData->priv = new EwkViewImpl(ewkView);
870 if (!smartData->priv) {
871 EINA_LOG_CRIT("could not allocate EwkViewImpl");
872 evas_object_smart_data_set(ewkView, 0);
877 // Create evas_object_image to draw web contents.
878 smartData->image = evas_object_image_add(smartData->base.evas);
879 evas_object_image_alpha_set(smartData->image, false);
880 evas_object_image_filled_set(smartData->image, true);
881 evas_object_smart_member_add(smartData->image, ewkView);
884 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
885 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
886 const char *engine = ecore_evas_engine_name_get(ee);
887 if (engine && !strcmp(engine, "opengl_x11"))
888 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
890 ewk_view_mouse_events_enabled_set(ewkView, false);
891 ewk_view_touch_events_enabled_set(ewkView, true);
893 // FIXME: This code should be removed if side effect occur.
894 // WebView does not have focus after url loading.
895 // If focus is set as true to webview,
896 // elementary steal webview's focus during mouse up event
897 // So, added code that events are not propagated to smart parent according to guide from EFL
898 evas_object_propagate_events_set(ewkView, false);
899 #endif // #if OS(TIZEN)
901 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
902 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
903 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
904 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
905 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
906 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
907 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
908 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
912 static void _ewk_view_smart_del(Evas_Object* ewkView)
914 EwkViewImpl::removeFromPageViewMap(ewkView);
915 EWK_VIEW_SD_GET(ewkView, smartData);
916 #if ENABLE(TIZEN_SCREEN_READER)
917 ScreenReaderProxy::screenReader().finalize(smartData->priv);
919 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
920 // Close color picker if it's opened.
921 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
922 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
925 #if ENABLE(TIZEN_GEOLOCATION)
927 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
928 Ewk_Geolocation_Provider* geolocationProvider = impl->context->geolocationProvider();
929 TIZEN_LOGI("_ewk_view_smart_del:: unwatch validity");
930 geolocationProvider->unwatchValidity(ewkView);
934 if (smartData && smartData->priv)
935 _ewk_view_impl_del(smartData->priv);
937 g_parentSmartClass.del(ewkView);
940 static Eina_Bool _ewk_view_composite(void* data);
942 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
944 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
946 evas_object_resize(smartData->image, width, height);
947 evas_object_image_size_set(smartData->image, width, height);
948 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
950 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
951 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
952 evas_object_image_native_surface_set(smartData->image, 0);
954 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
955 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
956 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
957 if (!ewk_view_is_opengl_backend(ewkView))
958 _ewk_view_composite(smartData);
959 else // OpenGL backend
961 impl->pageClient->displayViewport();
963 #endif // #if OS(TIZEN)
965 smartData->changed.size = true;
966 _ewk_view_smart_changed(smartData);
969 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
971 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
973 smartData->changed.position = true;
974 _ewk_view_smart_changed(smartData);
977 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
979 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
980 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
982 Evas_Coord x, y, width, height;
984 smartData->changed.any = false;
986 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
988 if (smartData->changed.size) {
990 #if USE(COORDINATED_GRAPHICS)
991 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
993 #if USE(ACCELERATED_COMPOSITING)
994 needsNewSurface = impl->evasGlSurface;
997 if (impl->pageProxy->drawingArea())
998 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
1000 #if USE(ACCELERATED_COMPOSITING)
1001 if (!impl->evasGlSurface)
1003 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
1004 impl->evasGlSurface = 0;
1005 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1006 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1008 #endif // #if !OS(TIZEN)
1010 smartData->view.w = width;
1011 smartData->view.h = height;
1012 smartData->changed.size = false;
1015 if (impl->pageClient) {
1016 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
1017 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1018 if (impl->pageProxy->isViewVisible())
1019 drawingArea->setSize(IntSize(width, height), IntSize());
1021 drawingArea->setSize(IntSize(width, height), IntSize());
1023 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1024 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1025 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
1026 if (ewk_view_is_opengl_backend(ewkView))
1027 impl->pageClient->displayViewport();
1030 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1031 impl->pageClient->frameRectChanged();
1034 #endif // #if OS(TIZEN)
1037 if (smartData->changed.position) {
1038 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1039 IntSize diff(x - smartData->view.x, y - smartData->view.y);
1042 evas_object_move(smartData->image, x, y);
1043 smartData->view.x = x;
1044 smartData->view.y = y;
1045 smartData->changed.position = false;
1047 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1048 impl->pageClient->frameRectChanged();
1050 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1051 if (impl->pageClient->isTextSelectionMode()) {
1052 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
1053 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
1056 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1057 if (impl->focusRing())
1058 impl->focusRing()->moveBy(diff);
1060 #endif // #if OS(TIZEN)
1063 if (impl->popupPicker)
1064 ewk_popup_picker_resize(impl->popupPicker);
1065 #endif // #if OS(TIZEN)
1068 static void _ewk_view_smart_show(Evas_Object* ewkView)
1070 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1071 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1073 if (evas_object_clipees_get(smartData->base.clipper))
1074 evas_object_show(smartData->base.clipper);
1075 evas_object_show(smartData->image);
1077 #if ENABLE(TIZEN_SCREEN_READER)
1078 ScreenReaderProxy::screenReader().initialize(impl);
1082 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1084 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1086 evas_object_hide(smartData->base.clipper);
1087 evas_object_hide(smartData->image);
1088 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1089 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1090 if (impl->pageClient->isTextSelectionMode())
1091 impl->pageClient->setIsTextSelectionMode(false);
1095 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1097 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1098 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1102 else if (alpha > 255)
1105 #define CHECK_COLOR(color, alpha) \
1108 else if (color > alpha) \
1110 CHECK_COLOR(red, alpha);
1111 CHECK_COLOR(green, alpha);
1112 CHECK_COLOR(blue, alpha);
1115 evas_object_image_alpha_set(smartData->image, alpha < 255);
1116 impl->pageProxy->setDrawsBackground(red || green || blue);
1117 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1118 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1121 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1125 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1127 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1129 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1130 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1131 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1135 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1136 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1138 evas_object_smart_clipped_smart_set(&api->sc);
1140 // Set Evas_Smart_Class functions.
1141 api->sc.add = _ewk_view_smart_add;
1142 api->sc.del = _ewk_view_smart_del;
1143 api->sc.move = _ewk_view_smart_move;
1144 api->sc.resize = _ewk_view_smart_resize;
1145 api->sc.show = _ewk_view_smart_show;
1146 api->sc.hide = _ewk_view_smart_hide;
1147 api->sc.color_set = _ewk_view_smart_color_set;
1148 api->sc.calculate = _ewk_view_smart_calculate;
1149 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1151 // Set Ewk_View_Smart_Class functions.
1152 api->focus_in = _ewk_view_smart_focus_in;
1153 api->focus_out = _ewk_view_smart_focus_out;
1154 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1155 api->mouse_down = _ewk_view_smart_mouse_down;
1156 api->mouse_up = _ewk_view_smart_mouse_up;
1157 api->mouse_move = _ewk_view_smart_mouse_move;
1158 api->key_down = _ewk_view_smart_key_down;
1159 api->key_up = _ewk_view_smart_key_up;
1161 api->gesture_start = _ewk_view_smart_gesture_start;
1162 api->gesture_end = _ewk_view_smart_gesture_end;
1163 api->gesture_move = _ewk_view_smart_gesture_move;
1165 #if ENABLE(TIZEN_FULLSCREEN_API)
1166 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1167 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1170 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1171 api->popup_menu_show = _ewk_view_popup_menu_show;
1172 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1173 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1175 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1176 api->popup_menu_update = _ewk_view_popup_menu_update;
1178 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1179 api->text_selection_down = _ewk_view_text_selection_down;
1180 api->text_selection_move = _ewk_view_text_selection_move;
1181 api->text_selection_up = _ewk_view_text_selection_up;
1183 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1184 api->input_picker_show = _ewk_view_input_picker_show;
1186 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1187 api->orientation_lock = _ewk_orientation_lock;
1188 api->orientation_unlock = _ewk_orientation_unlock;
1190 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1191 api->input_picker_color_request = _ewk_input_picker_color_request;
1192 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1194 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1195 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1196 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1197 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1198 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1200 #if ENABLE(TIZEN_SCREEN_READER)
1201 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1203 #endif //#if OS(TIZEN)
1208 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1210 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1211 static Evas_Smart* smart = 0;
1213 if (EINA_UNLIKELY(!smart)) {
1214 ewk_view_smart_class_set(&api);
1215 smart = evas_smart_class_new(&api.sc);
1221 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1223 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1224 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1225 EINA_SAFETY_ON_NULL_RETURN(context);
1227 if (impl->pageClient)
1230 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1231 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1233 impl->pageClient = PageClientEvasGL::create(impl);
1235 impl->pageClient = PageClientImpl::create(impl);
1237 impl->pageClient = PageClientImpl::create(impl);
1241 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1243 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1245 EwkViewImpl::addToPageViewMap(ewkView);
1248 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1249 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1250 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1251 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1254 impl->pageProxy->initializeWebPage();
1256 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1257 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1259 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1262 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1263 impl->pageProxy->setUseFixedLayout(true);
1265 #if ENABLE(FULLSCREEN_API)
1266 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1269 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1271 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1273 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1274 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1275 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1279 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1281 impl->context = context;
1284 ewkViewContextMenuClientAttachClient(ewkView);
1285 ewkViewTizenClientAttachClient(ewkView);
1287 #if ENABLE(TIZEN_GEOLOCATION)
1288 Ewk_Geolocation_Provider* geolocationProvider = impl->context->geolocationProvider();
1289 geolocationProvider->watchValidity(GeolocationValidityCallbackData(_ewk_view_geolocation_validity_check, ewkView));
1292 #if ENABLE(TIZEN_NOTIFICATIONS)
1293 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1296 #if ENABLE(TIZEN_ICON_DATABASE)
1297 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1300 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1301 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1302 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1303 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1304 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1306 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1307 #else // #if OS(TIZEN)
1308 #if USE(COORDINATED_GRAPHICS)
1309 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1311 #endif // #if OS(TIZEN)
1313 #if ENABLE(FULLSCREEN_API)
1314 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1315 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1318 // Initialize page clients.
1319 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1320 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1321 impl->pageUIClient = PageUIClientEfl::create(impl);
1322 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1323 impl->findClient = FindClientEfl::create(impl);
1324 impl->formClient = FormClientEfl::create(impl);
1325 #if !ENABLE(TIZEN_ICON_DATABASE)
1326 /* Listen for favicon changes */
1327 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1328 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1330 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1331 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1334 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1335 if (!impl->context->xWindow())
1336 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1340 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1342 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1343 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1345 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1347 using namespace EGL;
1348 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1349 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1355 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1359 EWK_VIEW_SD_GET(ewkView, smartData);
1361 evas_object_del(ewkView);
1365 EWK_VIEW_IMPL_GET(smartData, impl);
1367 evas_object_del(ewkView);
1376 * Constructs a ewk_view Evas_Object with WKType parameters.
1378 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1380 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1381 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1383 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1387 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1392 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1394 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1395 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1396 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1398 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1402 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1403 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1404 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1405 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1407 _ewk_view_initialize(ewkView, context, 0);
1413 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1415 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1416 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1419 Evas_Object* ewk_view_add(Evas* canvas)
1421 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1424 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1426 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1427 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1429 return impl->ewkContext();
1432 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1434 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1435 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1436 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1438 impl->pageProxy->loadURL(String::fromUTF8(url));
1439 impl->informURLChange();
1444 const char* ewk_view_url_get(const Evas_Object* ewkView)
1446 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1447 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1452 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1454 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1455 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1457 return impl->faviconURL();
1460 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1462 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1463 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1465 impl->pageClient->prepareRestoredVisibleContectRect();
1466 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1467 impl->informURLChange();
1472 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1474 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1475 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1477 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1478 impl->informURLChange();
1483 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1485 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1486 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1488 impl->pageProxy->stopLoading();
1493 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1495 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1496 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1498 return impl->settings();
1501 const char* ewk_view_title_get(const Evas_Object* ewkView)
1503 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1504 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1506 return impl->title();
1511 * Reports that the requested text was found.
1513 * Emits signal: "text,found" with the number of matches.
1515 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1517 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1520 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1522 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1523 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1525 return impl->pageProxy->estimatedProgress();
1528 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1530 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1531 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1537 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1539 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1540 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1541 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1542 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1544 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1546 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1551 double ewk_view_scale_get(const Evas_Object* ewkView)
1553 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1554 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1557 return impl->pageProxy->scaleFactor();
1559 return impl->pageProxy->pageScaleFactor();
1563 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1565 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1566 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1568 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1573 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1575 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1576 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1578 return impl->pageProxy->deviceScaleFactor();
1581 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1583 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1584 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1586 impl->setThemePath(path);
1589 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1591 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1592 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1594 return impl->themePath();
1597 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1599 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1600 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1602 WebPageProxy* page = impl->pageProxy.get();
1603 if (page->canGoBack()) {
1611 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1613 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1614 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1616 WebPageProxy* page = impl->pageProxy.get();
1617 if (page->canGoForward()) {
1625 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1627 #if ENABLE(WEB_INTENTS)
1628 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1629 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1630 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1632 WebPageProxy* page = impl->pageProxy.get();
1633 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1641 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1643 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1644 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1646 return impl->pageProxy->canGoBack();
1649 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1651 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1652 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1654 return impl->pageProxy->canGoForward();
1657 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1659 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1660 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1662 return impl->backForwardList.get();
1665 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1666 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
1667 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value, bool isInputInForm)
1669 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1670 #endif // TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM
1672 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1673 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1675 if (value.isEmpty()) {
1676 if(smartData->api->formdata_candidate_is_showing(smartData))
1677 smartData->api->formdata_candidate_hide(smartData);
1681 Eina_List* optionList = 0;
1682 Vector<String> popupOptionLists = impl->pageProxy->getFocusedInputElementDataList();
1683 std::sort(popupOptionLists.begin(), popupOptionLists.end(), WTF::codePointCompareLessThan);
1684 for (size_t i = 0; i < popupOptionLists.size(); ++i) {
1685 if (popupOptionLists[i].startsWith(value, false))
1686 optionList = eina_list_append(optionList, eina_stringshare_add(popupOptionLists[i].utf8().data()));
1689 Eina_List* candidateList = 0;
1690 if (ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView))) {
1691 Vector<String> popupCandidates;
1692 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1693 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1695 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1696 if (popupCandidates[i].startsWith(value, false))
1697 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1701 Vector<AutoFillPopupItem> formData;
1703 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
1704 if (ewk_settings_form_profile_data_enabled_get(ewk_view_settings_get(ewkView)) && isInputInForm) {
1705 Vector<std::pair<int, std::pair<String, String> > > profileFormCandidates;
1706 ewk_view_profile_form_candidate_data_get(ewkView, name, value, profileFormCandidates);
1707 for (size_t ittr = 0; ittr < profileFormCandidates.size(); ++ittr) {
1708 std::pair<int, std::pair<String, String> > fullData(profileFormCandidates[ittr]);
1709 std::pair<String, String> dispStrings(fullData.second);
1710 formData.append(AutoFillPopupItem(dispStrings.first, dispStrings.second, fullData.first, profileAutoFill));
1717 if (eina_list_count(optionList)) {
1718 EINA_LIST_FOREACH(optionList, list, data)
1719 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), dataListAutoFill));
1722 if (eina_list_count(candidateList) && ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView))) {
1723 EINA_LIST_FOREACH(candidateList, list, data)
1724 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), candidateAutoFill));
1727 if (!formData.size()) {
1728 if(smartData->api->formdata_candidate_is_showing(smartData))
1729 smartData->api->formdata_candidate_hide(smartData);
1733 if (formData[0].itemtype == profileAutoFill)
1734 impl->pageClient->updateAutoFillPopup(formData);
1736 Eina_List* autoFillList = 0;
1738 if (eina_list_count(optionList)) {
1739 EINA_LIST_FOREACH(optionList, list, data)
1740 autoFillList = eina_list_append(autoFillList, eina_stringshare_add(static_cast<char*>(data)));
1742 if (eina_list_count(candidateList)) {
1743 EINA_LIST_FOREACH(candidateList, list, data)
1744 autoFillList = eina_list_append(autoFillList, eina_stringshare_add(static_cast<char*>(data)));
1746 smartData->api->formdata_candidate_update_data(smartData, autoFillList);
1749 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1750 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1753 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm, bool isAutoComplete)
1755 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1756 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1757 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1758 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1761 // if isAutoComplete is off then return
1762 if (isPasswordForm && !isAutoComplete)
1765 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1768 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1771 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1773 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1776 Vector<std::pair<String, String> > passwordFormData;
1777 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1779 if (!passwordFormData.size())
1782 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
1783 for (size_t i = 0; i < passwordFormData.size(); i++) {
1784 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
1785 " for (var i = 0; i < inputFields.length; i++)"
1786 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\")"
1787 " && inputFields[i].autocomplete.toLowerCase() != \"off\")"
1788 " inputFields[i].value = \"",passwordFormData[i].first.utf8().data());
1789 passwordFormAutofill.append(passwordFormData[i].second);
1790 passwordFormAutofill += "\";";
1792 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
1793 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1796 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1798 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1799 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1800 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1804 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1806 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1807 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1808 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1810 if (unreachableUrl && *unreachableUrl)
1811 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1813 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1815 impl->informURLChange();
1820 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1822 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1823 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1825 return impl->customTextEncodingName();
1828 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1830 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1831 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1833 impl->setCustomTextEncodingName(encoding);
1839 // FIXME: It should be removed.
1840 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1842 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1843 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1845 return toAPI(impl->pageProxy.get());
1848 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1850 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1851 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1853 impl->setMouseEventsEnabled(!!enabled);
1858 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1860 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1861 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1863 return impl->mouseEventsEnabled();
1866 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1868 #if ENABLE(INPUT_TYPE_COLOR)
1869 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1870 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1872 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1878 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1880 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1881 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1883 return impl->javascriptPopup->alert(alertText);
1886 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1888 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1889 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1891 return impl->javascriptPopup->confirm(message);
1894 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1896 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1897 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1899 return impl->javascriptPopup->prompt(message, defaultValue);
1902 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1903 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1905 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1906 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1908 return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1912 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)
1914 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1915 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1917 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1920 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1921 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)
1923 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1925 if (impl->popupPicker)
1926 ewk_popup_picker_del(impl->popupPicker);
1928 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1929 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1931 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1937 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1938 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)
1940 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1942 if (impl->popupPicker)
1943 ewk_popup_picker_del(impl->popupPicker);
1945 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1951 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1953 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1955 if (!impl->popupPicker)
1958 ewk_popup_picker_del(impl->popupPicker);
1959 impl->popupPicker = 0;
1964 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)
1966 // FIXME: The rect should be updated if it was changed
1968 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1970 if (!impl->popupPicker)
1973 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1979 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1980 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1982 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1984 impl->inputPicker->show(inputType, inputValue);
1989 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1990 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1992 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1994 impl->inputPicker->showColorPicker(r, g, b, a);
1998 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2000 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2002 impl->inputPicker->hideColorPicker();
2007 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2009 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2010 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2012 return impl->pageClient.get();
2015 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2017 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2018 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
2020 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
2023 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2025 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2026 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2028 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
2032 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2034 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2035 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2037 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
2040 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2042 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2043 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2045 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
2048 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2050 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2051 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2053 if (!impl->javascriptGlobalContext)
2054 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
2055 return impl->javascriptGlobalContext;
2058 void ewkViewLoadCommitted(Evas_Object* ewkView)
2060 #if ENABLE(TIZEN_GESTURE)
2061 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2062 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2063 impl->gestureClient->reset();
2065 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2066 if (impl->focusRing())
2067 impl->focusRing()->hide(false);
2069 #if ENABLE(TIZEN_ISF_PORT)
2070 impl->inputMethodContext()->hideIMFContext();
2072 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2073 if (smartData->api->formdata_candidate_is_showing(smartData))
2074 smartData->api->formdata_candidate_hide(smartData);
2076 impl->informURLChange();
2077 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2080 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2082 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2083 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2085 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
2086 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
2087 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
2090 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2092 #if ENABLE(TIZEN_GESTURE)
2093 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2094 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2095 impl->gestureClient->reset();
2097 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2100 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2102 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2103 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2105 if (impl->authChallenge)
2106 ewkAuthChallengeDelete(impl->authChallenge);
2107 impl->authChallenge = authChallenge;
2109 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2112 void ewk_view_process_crashed(Evas_Object* ewkView)
2114 bool handled = false;
2115 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2121 #if ENABLE(TIZEN_SQL_DATABASE)
2122 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2124 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2125 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2127 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2130 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2131 impl->isWaitingForExceededQuotaPopupReply = true;
2132 if (impl->exceededQuotaOrigin)
2133 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2134 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2136 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2137 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2138 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2140 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2144 #if ENABLE(TIZEN_NOTIFICATIONS)
2145 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2147 TIZEN_LOGI("notification,cancel");
2148 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2151 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2153 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2154 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2156 TIZEN_LOGI("notification,permission,request");
2157 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2158 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2161 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2163 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2164 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2166 TIZEN_LOGI("notification,show");
2167 Eina_List* listIterator=0;
2169 const char* replaceID = ewkNotificationGetReplaceID(notification);
2170 if(strlen(replaceID)) {
2171 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2172 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2173 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2174 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2178 impl->notifications = eina_list_append(impl->notifications, notification);
2179 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2182 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2184 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2185 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2187 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2191 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2192 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2194 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2196 TIZEN_LOGI("protocolhandler,registration,requested");
2197 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2198 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2199 ewkCustomHandlersDeleteData(customHandlersData);
2203 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2204 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2206 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2208 TIZEN_LOGI("protocolhandler,isregistered");
2209 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2210 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2212 Ewk_Custom_Handlers_State result;
2213 result = ewkGetCustomHandlersDataResult(customHandlersData);
2214 ewkCustomHandlersDeleteData(customHandlersData);
2219 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2221 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2223 TIZEN_LOGI("protocolhandler,unregistration,requested");
2224 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2225 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2226 ewkCustomHandlersDeleteData(customHandlersData);
2230 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2231 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2233 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2235 TIZEN_LOGI("contenthandler,registration,requested");
2236 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2237 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2238 ewkCustomHandlersDeleteData(customHandlersData);
2241 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2243 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2245 TIZEN_LOGI("contenthandler,isregistered");
2246 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2247 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2249 Ewk_Custom_Handlers_State result;
2250 result = ewkGetCustomHandlersDataResult(customHandlersData);
2251 ewkCustomHandlersDeleteData(customHandlersData);
2256 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2258 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2260 TIZEN_LOGI("contenthandler,unregistration,requested");
2261 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2262 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2263 ewkCustomHandlersDeleteData(customHandlersData);
2267 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2268 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2270 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2272 TIZEN_LOGI("searchProvider,add");
2273 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2274 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2275 ewkSearchProviderDeleteData(searchProviderData);
2278 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2280 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2282 TIZEN_LOGI("searchProvider,installed");
2283 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2284 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2285 unsigned long result;
2286 result = ewkGetSearchProviderResult(searchProviderData);
2287 ewkSearchProviderDeleteData(searchProviderData);
2292 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2293 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2295 TIZEN_LOGI("webapp,metatag,standalone");
2296 bool standalone = true;
2297 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2302 #if ENABLE(TIZEN_MEDIA_STREAM)
2303 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2305 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2306 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2308 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2309 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2312 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2314 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2315 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2317 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2322 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2323 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2325 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2326 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2327 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2328 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2329 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2330 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2332 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2336 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2337 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2339 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2340 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2341 if (impl->certificatePolicyDecision)
2342 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2343 impl->certificatePolicyDecision = certificatePolicyDecision;
2345 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2349 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2351 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2354 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2356 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2359 #if ENABLE(TIZEN_GEOLOCATION)
2360 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2362 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2363 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2365 TIZEN_LOGI("geolocation,permission,request");
2366 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2367 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2370 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2372 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2373 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2375 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2379 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2381 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2384 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2386 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2387 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2388 if (impl->policyDecision)
2389 ewkPolicyDecisionDelete(impl->policyDecision);
2390 impl->policyDecision = policyDecision;
2392 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2395 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2397 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2398 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2399 if (impl->policyDecision)
2400 ewkPolicyDecisionDelete(impl->policyDecision);
2401 impl->policyDecision = policyDecision;
2403 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2406 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2408 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2409 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2410 if (impl->policyDecision)
2411 ewkPolicyDecisionDelete(impl->policyDecision);
2412 impl->policyDecision = policyDecision;
2414 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2417 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2419 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2420 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2422 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2423 IntSize contentsSize = impl->pageProxy->contentsSize();
2424 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2425 contentsSize.scale(impl->pageClient->scaleFactor());
2428 // some website's contents size is smaller than view size,
2429 // so we have to adjust contents size to view size for that case.
2430 if (contentsSize.width() < smartData->view.w)
2431 contentsSize.setWidth(smartData->view.w);
2432 if (contentsSize.height() < smartData->view.h)
2433 contentsSize.setHeight(smartData->view.h);
2435 // Call "scroll,down" if webview can be scrolled down.
2436 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2437 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2438 // Call "scroll,up" if webview can be scrolled up.
2439 else if (deltaY < 0 && scrollPosition.y() > 0)
2440 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2442 // Call "scroll,right" if webview can be scrolled down.
2443 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2444 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2445 // Call "scroll,left" if webview can be scrolled up.
2446 else if (deltaX < 0 && scrollPosition.x() > 0)
2447 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2450 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2452 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2453 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2455 IntSize contentsSize = impl->pageProxy->contentsSize();
2456 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2457 contentsSize.scale(impl->pageClient->scaleFactor());
2460 int maxScrollY = contentsSize.height() - smartData->view.h;
2461 if (!impl->isVerticalEdge) {
2462 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2463 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2464 impl->isVerticalEdge = true;
2465 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2466 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2467 impl->isVerticalEdge = true;
2470 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2471 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2472 impl->isVerticalEdge = false;
2475 int maxScrollX = contentsSize.width() - smartData->view.w;
2476 if (!impl->isHorizontalEdge) {
2477 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2478 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2479 impl->isHorizontalEdge = true;
2480 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2481 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2482 impl->isHorizontalEdge = true;
2485 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2486 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2487 impl->isHorizontalEdge = false;
2491 void ewkViewClearEdges(Evas_Object* ewkView)
2493 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2494 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2496 impl->isVerticalEdge = false;
2497 impl->isHorizontalEdge = false;
2500 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2502 EWK_VIEW_SD_GET(ewkView, smartData);
2503 if (!smartData || !smartData->priv) {
2511 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2513 *minimumScale = constraints.minimumScale;
2515 *maximumScale = constraints.maximumScale;
2518 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard, Eina_Bool adjustForContentSizeChanged)
2520 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2521 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2523 #if ENABLE(TIZEN_ISF_PORT)
2524 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2525 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2526 // input field zoom should not work with below conditions
2527 // 1. view is not focused
2528 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2529 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2530 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2532 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2533 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2534 || (!adjustForContentSizeChanged && impl->pageProxy->editorState().isContentRichlyEditable)
2535 || (adjustForContentSizeChanged && !impl->inputMethodContext()->isShow()))
2536 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2537 && !(impl->pageClient->isClipboardWindowOpened())
2543 double scaleFactor = impl->pageClient->scaleFactor();
2544 IntSize contentsSize = impl->pageProxy->contentsSize();
2546 double newScaleFactor = scaleFactor;
2547 // Readable zoom value is dependent on device DPI
2548 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2549 && impl->pageClient->viewportConstraints().userScalable)
2550 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2552 // Readable zoom value should be inside of viewport scale range
2553 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2555 // caret position can be outside of visible rect.
2556 // we need to consider it.
2557 IntRect selectionRect = impl->pageProxy->editorState().selectionRect;
2558 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2559 IntRect focusedNodeRectScaled = focusedNodeRect;
2561 if (selectionRect.isEmpty())
2564 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2565 focusedNodeRectScaled.scale(newScaleFactor);
2567 focusedNodeRectScaled.scale(newScaleFactor / scaleFactor);
2570 IntRect visibleRect = impl->pageClient->visibleContentRect();
2571 if (visibleRect.contains(focusedNodeRectScaled))
2574 #if ENABLE(TIZEN_WEBKIT2_INPUT_FIELD_ZOOM)
2575 impl->inputFieldZoom->startInputFieldZoom(impl->transformFromScene().mapPoint(IntPoint(selectionRect.x(), selectionRect.y()))
2576 , IntRect(focusedNodeRect.x(), selectionRect.y(), focusedNodeRect.width(), selectionRect.height()));
2582 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2583 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2584 static Eina_Bool _ewk_view_composite(void* data)
2586 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2587 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2589 if (!evas_object_visible_get(smartData->image))
2590 return ECORE_CALLBACK_CANCEL;
2593 evas_object_image_size_get(smartData->image, &ow, &oh);
2594 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2596 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)));
2597 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2599 cairo_save(context.get());
2600 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2601 cairo_rectangle(context.get(), 0, 0, ow, oh);
2602 cairo_fill(context.get());
2603 cairo_restore(context.get());
2605 impl->pageClient->drawContents(context.get());
2607 evas_object_image_data_set(smartData->image, pixels);
2608 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2610 if (impl->pageClient->notifiedNonemptyLayout() && impl->pageClient->canUpdateVisibleContentRect())
2611 ewkViewFrameRendered(smartData->self);
2613 impl->compositionAnimator = 0;
2615 return ECORE_CALLBACK_CANCEL;
2619 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2621 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2622 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2624 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2625 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2627 if (!ewk_view_is_opengl_backend(ewkView)) {
2628 if (!impl->compositionAnimator)
2629 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2634 evas_object_image_pixels_dirty_set(smartData->image, true);
2637 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2639 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2640 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2641 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2642 impl->pageClient->drawContents();
2645 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2647 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2648 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2650 if (!smartData->image)
2653 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2654 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2660 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2662 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2663 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2665 if (!impl->suspendedPainting) {
2666 impl->pageProxy->suspendPainting();
2667 impl->suspendedPainting = true;
2671 void _ewk_view_resume_painting(Evas_Object* ewkView)
2673 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2674 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2676 if (impl->suspendedPainting) {
2677 impl->pageProxy->resumePainting();
2678 impl->suspendedPainting = false;
2682 void ewk_view_suspend(Evas_Object* ewkView)
2684 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2685 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2687 if (impl->pageProxy->estimatedProgress() < 1.0) {
2688 impl->suspendRequested = true;
2691 impl->suspendRequested = false;
2693 _ewk_view_suspend_painting(ewkView);
2695 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2696 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2697 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2699 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2700 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2701 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2702 // will be suspended again.
2703 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2704 // the ActiveDOMObject.
2705 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2706 impl->pageProxy->suspendAnimations();
2707 impl->pageProxy->suspendJavaScriptAndResource();
2708 impl->suspendedResources = true;
2711 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2712 impl->pageProxy->suspendPlugin();
2716 void ewk_view_resume(Evas_Object* ewkView)
2718 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2719 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2721 if (impl->suspendRequested) {
2722 impl->suspendRequested = false;
2726 _ewk_view_resume_painting(ewkView);
2728 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2729 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2730 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2732 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2733 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2734 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2735 // will be suspended again.
2736 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2737 // the ActiveDOMObject.
2738 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2739 impl->pageProxy->resumeAnimations();
2740 impl->pageProxy->resumeJavaScriptAndResource();
2741 impl->suspendedResources = false;
2744 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2745 impl->pageProxy->resumePlugin();
2749 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2751 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2752 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2753 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2755 ResourceRequest request(String::fromUTF8(url));
2758 case EWK_HTTP_METHOD_GET:
2759 request.setHTTPMethod("GET");
2761 case EWK_HTTP_METHOD_HEAD:
2762 request.setHTTPMethod("HEAD");
2764 case EWK_HTTP_METHOD_POST:
2765 request.setHTTPMethod("POST");
2767 case EWK_HTTP_METHOD_PUT:
2768 request.setHTTPMethod("PUT");
2770 case EWK_HTTP_METHOD_DELETE:
2771 request.setHTTPMethod("DELETE");
2778 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2780 while (eina_iterator_next(it, &data)) {
2781 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2782 const char* name = static_cast<const char*>(t->key);
2783 const char* value = static_cast<const char*>(t->data);
2784 request.addHTTPHeaderField(name, value);
2786 eina_iterator_free(it);
2790 request.setHTTPBody(FormData::create(body));
2792 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2793 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2798 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2800 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2801 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2803 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2804 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2809 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2811 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2812 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2813 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2815 if (contentsSize == 0)
2818 String mimeTypeString;
2820 mimeTypeString = String::fromUTF8(mimeType);
2822 mimeTypeString = String::fromUTF8("text/html");
2824 String encodingString;
2826 encodingString = String::fromUTF8(encoding);
2828 encodingString = String::fromUTF8("UTF-8");
2830 String baseUriString;
2832 baseUriString = String::fromUTF8(baseUri);
2834 baseUriString = String::fromUTF8("about:blank");
2836 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2837 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2842 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2844 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2845 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2847 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2848 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2850 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2855 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2857 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2858 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2860 TIZEN_LOGI("initialState (%d)", initialState);
2861 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2862 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2869 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2871 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2873 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2874 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2876 impl->userAgent = userAgent;
2878 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2879 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2884 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2886 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2887 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2890 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2892 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2893 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2894 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2895 impl->userAgent = buffer.get();
2897 if (!impl->userAgent) {
2898 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2900 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2901 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2902 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2903 impl->userAgent = buffer.get();
2907 return impl->userAgent;
2911 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* applicationName)
2913 EINA_SAFETY_ON_NULL_RETURN_VAL(applicationName, false);
2915 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2916 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2918 WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKStringCreateWithUTF8CString(applicationName));
2919 WKPageSetApplicationNameForUserAgent(toAPI(impl->pageProxy.get()), applicationNameString.get());
2924 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
2926 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2927 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2929 WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKPageCopyApplicationNameForUserAgent(toAPI(impl->pageProxy.get())));
2931 int length = WKStringGetMaximumUTF8CStringSize(applicationNameString.get());
2932 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2933 WKStringGetUTF8CString(applicationNameString.get(), buffer.get(), length);
2934 impl->applicationName = buffer.get();
2936 return impl->applicationName;
2940 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2942 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2943 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2944 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2946 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2947 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2949 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2952 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2957 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2959 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2960 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2961 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2963 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2965 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2968 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2973 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2975 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2976 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2977 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2979 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2982 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2987 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2988 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2990 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2991 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2993 #if ENABLE(TIZEN_DRAG_SUPPORT)
2994 if (impl->pageClient->isDragMode())
2995 impl->pageClient->setDragMode(false);
2998 impl->pageClient->setIsVisible(enable);
3003 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
3004 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
3010 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3012 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3014 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3015 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3018 rect.origin.x = viewArea.x;
3019 rect.origin.y = viewArea.y;
3020 rect.size.width = viewArea.w;
3021 rect.size.height = viewArea.h;
3023 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
3024 if (!snapshot.get())
3027 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3029 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3030 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3031 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3032 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3033 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3035 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3037 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)));
3038 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3040 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3041 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3042 cairo_fill(cairo.get());
3044 evas_object_image_smooth_scale_set(screenshotImage, true);
3045 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3046 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3047 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3048 evas_object_image_data_set(screenshotImage, pixels);
3050 return screenshotImage;
3053 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3055 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3056 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3057 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
3059 return impl->pageProxy->startInspectorServer(port);
3061 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3066 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3068 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3069 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3070 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
3072 return impl->pageProxy->stopInspectorServer();
3074 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3079 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3081 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3082 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3084 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3087 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3093 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3094 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3096 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3098 *x = scrollPosition.x();
3100 *y = scrollPosition.y();
3105 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3107 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3108 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3110 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3114 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3120 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3121 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3123 IntSize contentsSize = impl->pageProxy->contentsSize();
3124 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3125 contentsSize.scale(impl->pageClient->scaleFactor());
3128 if (width && contentsSize.width() > smartData->view.w)
3129 *width = contentsSize.width() - smartData->view.w;
3130 if (height && contentsSize.height() > smartData->view.h)
3131 *height = contentsSize.height() - smartData->view.h;
3135 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
3136 void ewkViewNotifyPopupReplyWaitingState(Evas_Object* ewkView, bool isWaiting)
3139 evas_object_smart_callback_call(ewkView, "popup,reply,wait,start", 0);
3141 evas_object_smart_callback_call(ewkView, "popup,reply,wait,finish", 0);
3145 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3147 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3148 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3149 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3151 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3153 impl->isWaitingForJavaScriptPopupReply = true;
3154 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3155 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3156 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3157 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3160 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3162 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3163 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3164 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3166 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3168 impl->isWaitingForJavaScriptPopupReply = true;
3169 int length = WKStringGetMaximumUTF8CStringSize(message);
3170 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3171 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3172 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3175 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3177 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3178 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3179 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3181 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3183 impl->isWaitingForJavaScriptPopupReply = true;
3184 int length = WKStringGetMaximumUTF8CStringSize(message);
3185 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3186 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3187 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3188 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3189 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3190 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3193 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3194 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3196 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3197 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3198 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3200 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3202 impl->isWaitingForJavaScriptPopupReply = true;
3203 int length = WKStringGetMaximumUTF8CStringSize(message);
3204 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3205 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3206 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3211 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3213 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3214 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3215 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3218 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3220 impl->openPanelListener = listener;
3222 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3223 Eina_List* acceptedMimeTypes = 0;
3224 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3225 size_t len = WKArrayGetSize(array.get());
3226 for (size_t i = 0; i < len; i++) {
3227 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3228 if (WKGetTypeID(item) != WKStringGetTypeID())
3230 WKStringRef mime = static_cast<WKStringRef>(item);
3231 int length = WKStringGetMaximumUTF8CStringSize(mime);
3232 char* buffer = new char[length];
3233 WKStringGetUTF8CString(mime, buffer, length);
3234 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3236 const char* capture = 0;
3237 #if ENABLE(MEDIA_CAPTURE)
3238 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3239 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3241 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3242 if (!acceptedMimeTypes)
3247 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3248 delete[] (char*)data;
3249 eina_list_free(acceptedMimeTypes);
3253 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3255 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3256 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3258 if (!impl->alertContext)
3259 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3260 impl->alertContext->javascriptAlertCallback = callback;
3261 impl->alertContext->ewkView = ewkView;
3262 impl->alertContext->userData = userData;
3265 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3267 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3268 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3270 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3271 impl->isWaitingForJavaScriptPopupReply = false;
3274 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3276 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3277 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3279 if (!impl->confirmContext)
3280 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3281 impl->confirmContext->javascriptConfirmCallback = callback;
3282 impl->confirmContext->ewkView = ewkView;
3283 impl->confirmContext->userData = userData;
3286 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3288 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3289 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3291 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3292 impl->isWaitingForJavaScriptPopupReply = false;
3295 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3297 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3298 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3300 if (!impl->promptContext)
3301 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3302 impl->promptContext->javascriptPromptCallback = callback;
3303 impl->promptContext->ewkView = ewkView;
3304 impl->promptContext->userData = userData;
3307 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3309 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3310 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3312 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3313 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3314 impl->isWaitingForJavaScriptPopupReply = false;
3317 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3318 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3320 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3321 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3323 if (!impl->beforeUnloadConfirmPanelContext)
3324 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3325 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3326 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3327 impl->beforeUnloadConfirmPanelContext->userData = userData;
3330 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3332 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3333 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3335 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3336 impl->isWaitingForJavaScriptPopupReply = false;
3340 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3342 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3343 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3345 if (!impl->openpanelContext)
3346 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3348 impl->openpanelContext->openPanelCallback = callback;
3349 impl->openpanelContext->ewkView = ewkView;
3350 impl->openpanelContext->userData = userData;
3353 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3355 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3356 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3358 if (!impl->openPanelListener)
3361 unsigned int size = eina_list_count(fileUrls);
3362 if ((result == EINA_FALSE) || (size == 0)) {
3363 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3364 impl->openPanelListener = 0;
3368 WKTypeRef* items = new WKTypeRef[size];
3372 KURL base(KURL(), "file://");
3373 EINA_LIST_FOREACH(fileUrls, list, data) {
3374 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3375 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3377 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3378 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3379 impl->openPanelListener = 0;
3381 eina_list_free(fileUrls);
3384 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3385 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3387 EINA_SAFETY_ON_NULL_RETURN(capable);
3388 EINA_SAFETY_ON_NULL_RETURN(context);
3390 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3392 ASSERT(webAppContext->webAppCapableCallback);
3394 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3396 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3398 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3400 delete webAppContext;
3403 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3405 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3406 EINA_SAFETY_ON_NULL_RETURN(context);
3408 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3410 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3411 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3413 ASSERT(webAppContext->webAppIconURLCallback);
3416 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3417 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3419 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3421 delete webAppContext;
3424 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3426 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3427 EINA_SAFETY_ON_NULL_RETURN(context);
3429 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3431 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3432 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3434 ASSERT(webAppContext->webAppIconURLsCallback);
3436 if (impl->webAppIconURLs) {
3438 EINA_LIST_FREE(impl->webAppIconURLs, data)
3439 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3442 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3443 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3444 for (size_t i = 0; i < iconURLCount; i++) {
3445 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3446 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3447 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3449 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3451 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3452 delete webAppContext;
3456 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3458 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3459 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3460 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3461 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3463 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3464 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3465 context->webAppCapableCallback = callback;
3466 context->ewkView = ewkView;
3467 context->userData = userData;
3469 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3477 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3479 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3480 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3481 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3482 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3484 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3485 context->webAppIconURLCallback = callback;
3486 context->ewkView = ewkView;
3487 context->userData = userData;
3489 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3497 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3499 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3500 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3501 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3502 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3504 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3505 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3506 context->webAppIconURLsCallback = callback;
3507 context->ewkView = ewkView;
3508 context->userData = userData;
3510 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3514 UNUSED_PARAM(ewkView);
3515 UNUSED_PARAM(callback);
3516 UNUSED_PARAM(userData);
3521 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3523 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3524 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3525 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3527 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3528 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3529 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3534 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3541 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3542 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3544 IntSize contentsSize = impl->pageProxy->contentsSize();
3547 *width = contentsSize.width();
3549 *height = contentsSize.height();
3554 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3556 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3557 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3558 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3559 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3561 IntSize contentsSize = impl->pageProxy->contentsSize();
3562 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3570 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3572 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3573 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3574 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3575 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3577 IntSize contentsSize = impl->pageProxy->contentsSize();
3578 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3586 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3588 EINA_SAFETY_ON_NULL_RETURN(context);
3589 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3591 if (!callbackContext->scriptExecuteCallback) {
3592 delete callbackContext;
3596 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3599 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3600 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3601 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3602 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3603 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3604 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3606 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3608 delete callbackContext;
3611 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3613 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3614 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3615 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3616 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3618 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3619 context->scriptExecuteCallback = callback;
3620 context->ewkView = ewkView;
3621 context->userData = user_data;
3622 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3623 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3628 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3629 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3631 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3634 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3636 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3638 delete storageContext;
3642 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3644 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3645 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3646 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3647 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3648 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3649 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3651 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3652 context->webStorageQuotaCallback = resultCallback;
3653 context->userData = userData;
3655 WKPageRef pageRef = toAPI(impl->page());
3656 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3664 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3666 #if ENABLE(TIZEN_WEB_STORAGE)
3667 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3668 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3669 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3671 TIZEN_LOGI("quota (%d)", quota);
3672 WKPageRef pageRef = toAPI(impl->page());
3673 WKPageSetWebStorageQuota(pageRef, quota);
3681 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3683 EINA_SAFETY_ON_NULL_RETURN(context);
3684 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3686 ASSERT(callbackContext->plainTextGetCallback);
3689 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3690 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3691 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3693 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3695 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3697 delete callbackContext;
3700 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3702 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3703 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3704 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3705 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3707 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3708 context->plainTextGetCallback = callback;
3709 context->ewkView = ewkView;
3710 context->userData = user_data;
3711 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3716 #if ENABLE(TIZEN_SUPPORT_MHTML)
3719 * Callback function used for ewk_view_mhtml_data_get().
3721 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3723 EINA_SAFETY_ON_NULL_RETURN(context);
3724 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3726 ASSERT(callbackContext->mhtmlDataGetCallback);
3728 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3730 delete callbackContext;
3733 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3735 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3736 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3737 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3739 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3740 context->mhtmlDataGetCallback = callback;
3741 context->ewkView = ewkView;
3742 context->userData = user_data;
3744 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3748 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3750 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3752 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3753 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3754 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3756 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3757 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3758 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3766 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3768 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3769 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3770 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3771 WebPageProxy* page = impl->page();
3772 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3774 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3777 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3782 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3784 #if ENABLE(TIZEN_NOTIFICATIONS)
3785 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3786 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3787 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3789 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3790 if (!eina_list_count(ewkNotifications))
3793 Eina_List* listIterator = 0;
3795 Vector<WKTypeRef> ids;
3796 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3797 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3798 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3800 impl->notifications = eina_list_remove(impl->notifications, notification);
3803 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3804 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3805 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3806 ewkNotificationDeleteNotificationList(ewkNotifications);
3814 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3815 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3817 Eina_List* popupItems = 0;
3818 size_t size = items.size();
3819 for (size_t i = 0; i < size; ++i)
3820 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3821 TIZEN_LOGI("size : %d", size);
3825 static void releasePopupMenuList(Eina_List* popupMenuItems)
3827 if (!popupMenuItems)
3831 EINA_LIST_FREE(popupMenuItems, item)
3832 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3836 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3838 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3839 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3840 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3842 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3845 if (!impl->popupMenuProxy)
3848 impl->popupMenuProxy = 0;
3850 if (smartData->api->popup_menu_hide)
3851 smartData->api->popup_menu_hide(smartData);
3852 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3853 ewk_view_touch_events_enabled_set(ewkView, true);
3855 releasePopupMenuList(impl->popupMenuItems);
3856 impl->popupMenuItems = 0;
3859 EINA_LIST_FREE(impl->popupMenuItems, item)
3860 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3866 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3868 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3869 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3870 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3872 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3874 if (!impl->popupMenuItems)
3878 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3881 impl->popupMenuProxy->valueChanged(selectedIndex);
3886 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3887 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3889 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3890 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3891 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3892 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3894 if (!impl->popupMenuProxy)
3897 if (!smartData->api->popup_menu_update)
3900 releasePopupMenuList(impl->popupMenuItems);
3901 impl->popupMenuItems = createPopupMenuList(items);
3903 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3904 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3908 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3909 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3911 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3912 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3913 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3915 Vector<int> selectedIndex;
3917 if (!impl->popupMenuItems)
3922 itr = eina_inarray_iterator_new(changeList);
3923 EINA_ITERATOR_FOREACH(itr, data)
3925 int* pData = static_cast<int*>(data);
3926 selectedIndex.append(*pData);
3928 eina_iterator_free(itr);
3930 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3935 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3937 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3938 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3939 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3940 TIZEN_LOGI("orientation : %d", orientation);
3942 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3945 if (impl->orientation == orientation)
3948 impl->orientation = orientation;
3950 impl->pageProxy->sendOrientationChangeEvent(orientation);
3954 void ewkViewFrameRendered(Evas_Object* ewkView)
3956 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3959 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3960 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3962 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3965 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3967 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3968 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3970 IntRect leftSelectionRect;
3971 IntRect rightSelectionRect;
3972 int selectionDirection = 1;
3973 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect, selectionDirection)) {
3986 AffineTransform contentToScreen = impl->transformToScene();
3987 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3988 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3990 leftRect->x = leftSelectionRect.x();
3991 leftRect->y = leftSelectionRect.y();
3992 leftRect->w = leftSelectionRect.width();
3993 leftRect->h = leftSelectionRect.height();
3995 rightRect->x = rightSelectionRect.x();
3996 rightRect->y = rightSelectionRect.y();
3997 rightRect->w = rightSelectionRect.width();
3998 rightRect->h = rightSelectionRect.height();
4003 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4005 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4006 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4008 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
4009 impl->selectedText = selectedString.data();
4011 return impl->selectedText;
4014 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4016 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4019 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4021 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4024 Eina_Bool ewk_view_text_selection_clear(Evas_Object* ewkView)
4026 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4027 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4029 bool isTextSelectionMode = impl->pageClient->isTextSelectionMode();
4030 impl->pageClient->setIsTextSelectionMode(false);
4031 return isTextSelectionMode;
4034 Eina_Bool ewk_view_text_selection_range_clear(Evas_Object* ewkView)
4036 return ewk_view_text_selection_clear(ewkView);
4038 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4040 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4041 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4043 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4044 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4045 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4047 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4051 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4052 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4054 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4055 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4056 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
4058 *x = drawingPosition.x();
4060 *y = drawingPosition.y();
4062 *w = impl->pageClient->visibleContentRect().width();
4064 *h = impl->pageClient->visibleContentRect().height();
4068 void ewk_view_current_target_input_element_value_set(Evas_Object* ewkView, const char* value)
4070 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4071 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4072 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4074 impl->pageProxy->setCurrentTargetInputElementValue(String::fromUTF8(value));
4075 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4078 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4080 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4081 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4082 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4084 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
4085 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4088 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4090 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4091 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4092 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4094 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
4095 return impl->inputValue;
4098 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4101 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4103 #if ENABLE(TIZEN_GESTURE)
4104 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4105 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4106 return impl->holdHorizontalPanning;
4112 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4114 #if ENABLE(TIZEN_GESTURE)
4115 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4116 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4117 impl->holdHorizontalPanning = hold;
4121 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4123 #if ENABLE(TIZEN_GESTURE)
4124 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4125 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4126 return impl->holdVerticalPanning;
4132 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4134 #if ENABLE(TIZEN_GESTURE)
4135 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4136 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4137 impl->holdVerticalPanning = hold;
4141 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4143 #if ENABLE(TIZEN_GESTURE)
4144 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4145 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4147 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4148 if (impl->focusRing() && wasHandled)
4149 impl->focusRing()->hide();
4150 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4152 if (impl->mouseEventsEnabled())
4155 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4156 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4157 if (type == WebEvent::TouchStart)
4158 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4159 else if (type == WebEvent::TouchMove)
4160 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4161 else if (type == WebEvent::TouchEnd)
4162 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4166 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4167 // The Pan and Flick will be enabled if Touch Start was not handled,
4168 // and Touch Move was not handled or did not occur.
4169 // Tap will be enabled if Touch Start and End was not handled
4170 // and Touch Move did not occur.
4171 // The gestures are disabled as a default.
4172 // o: handled, x: not handled
4173 // ------------------------------------------------------------
4174 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4175 // ------------------------------------------------------------
4176 // o | o or x | o or x || disable | disable
4177 // x | o | o or x || disable | disable
4178 // x | x | o or x || disable | enable
4179 // x |not occured | x || enable | enable
4180 // ------------------------------------------------------------
4181 if (type == WebEvent::TouchStart) {
4182 impl->gestureClient->setGestureEnabled(!wasHandled);
4183 impl->wasHandledTouchStart = wasHandled;
4185 // Initialize wasHandledTouchMove to true and notify that to the application
4186 // to prevent applications scrolling at the beginning of touch.
4187 impl->wasHandledTouchMove = true;
4188 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4189 } else if (type == WebEvent::TouchMove) {
4190 impl->gestureClient->setMovingEnabled(!wasHandled);
4192 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4193 if (impl->wasHandledTouchStart)
4196 // Notify the result of touchmove to applications when handled value is changed
4197 // in order to make applications to choose whether scrolling its scrollable objects or not.
4198 if (impl->wasHandledTouchMove != wasHandled)
4199 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4200 impl->wasHandledTouchMove = wasHandled;
4201 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4203 impl->gestureClient->setTapEnabled(!wasHandled);
4204 #if ENABLE(TIZEN_ISF_PORT)
4205 else if (impl->pageProxy->isViewVisible()) {
4206 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4207 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4208 if (hitTestResultData.isContentEditable && impl->inputMethodContext())
4209 impl->inputMethodContext()->updateTextInputStateByUserAction(true);
4216 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4217 void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
4219 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4220 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4222 EditorState editorState = impl->page()->editorState();
4223 Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
4224 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4225 ewkTextStyleDelete(textStyle);
4229 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4230 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4232 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4233 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4235 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4236 if (!smartData->api->orientation_lock) {
4241 return smartData->api->orientation_lock(smartData, willLockOrientation);
4244 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4246 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4247 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4249 TIZEN_LOGI("ewkView (%p)", ewkView);
4250 if (!smartData->api->orientation_unlock) {
4255 smartData->api->orientation_unlock(smartData);
4259 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4261 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4262 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4263 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4264 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4266 impl->orientationLock.callback = func;
4267 impl->orientationLock.data = data;
4271 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4272 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4274 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4275 TIZEN_LOGI("locked orientations : %d", orientations);
4277 if (impl->orientationLock.callback)
4278 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4283 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4285 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4286 TIZEN_LOGI("unlock is requested");
4288 if (impl->orientationLock.callback)
4289 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4293 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4294 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4296 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4298 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4299 const char *engine = ecore_evas_engine_name_get(ee);
4300 if (engine && !strcmp(engine, "opengl_x11"))
4306 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4308 #if ENABLE(TIZEN_GESTURE)
4309 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4310 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4312 impl->gestureClient->setZoomableArea(target, area);
4316 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4317 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4319 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4320 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4322 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4326 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4327 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4329 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4333 #if ENABLE(TIZEN_ICON_DATABASE)
4334 void ewkViewIconReceived(Evas_Object* ewkView)
4338 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4342 #endif // #if OS(TIZEN)
4344 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4346 #if ENABLE(TOUCH_EVENTS)
4347 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4348 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4349 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4351 #if ENABLE(TIZEN_FOCUS_UI)
4352 if (type == EWK_TOUCH_START)
4353 impl->page()->setFocusUIEnabled(false);
4356 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4357 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4358 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4359 IntPoint handlePoint(point->x, point->y);
4361 if (type == EWK_TOUCH_START)
4362 impl->pageClient->textSelectonHandleDown(handlePoint);
4363 else if (type == EWK_TOUCH_MOVE)
4364 impl->pageClient->textSelectonHandleMove(handlePoint);
4366 impl->pageClient->textSelectonHandleUp();
4368 if (impl->pageClient->isTextSelectionHandleDowned())
4373 #if ENABLE(TIZEN_GESTURE)
4374 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4375 // We don't want to process touch event when context menu is shown.
4376 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4377 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4378 && !impl->pageClient->isTextSelectionMode()
4383 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4384 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4388 if (type == EWK_TOUCH_START) {
4389 if (eina_list_count(points) == 1) {
4390 impl->gestureClient->reset();
4391 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4392 impl->touchDownPoint.x = point->x;
4393 impl->touchDownPoint.y = point->y;
4394 impl->exceedTouchMoveThreshold = false;
4396 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4397 if (eina_list_count(points) == 1) {
4398 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4399 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4400 int diffX = impl->touchDownPoint.x - point->x;
4401 int diffY = impl->touchDownPoint.y - point->y;
4402 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4403 impl->exceedTouchMoveThreshold = true;
4407 impl->exceedTouchMoveThreshold = true;
4410 #endif // #if ENABLE(TIZEN_GESTURE)
4412 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4413 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4414 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4422 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4424 #if ENABLE(TOUCH_EVENTS)
4425 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4426 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4428 impl->setTouchEventsEnabled(!!enabled);
4436 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4438 #if ENABLE(TOUCH_EVENTS)
4439 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4440 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4442 return impl->touchEventsEnabled();
4448 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4450 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4451 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4452 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4454 impl->mainFrameScrollbarVisibility = visible;
4455 impl->pageClient->updateVisibility();
4463 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4465 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4466 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4467 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4469 return impl->mainFrameScrollbarVisibility;
4475 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4477 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4478 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4479 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4480 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4482 String title = ewk_view_title_get(ewkView);
4483 String url = ewk_view_url_get(ewkView);
4484 String directoryPath(path);
4485 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4489 UNUSED_PARAM(ewkView);
4497 * Callback function used for ewk_view_page_contents_get().
4499 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4501 EINA_SAFETY_ON_NULL_RETURN(context);
4503 RefPtr<WebData> webData = toImpl(wkData);
4504 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4505 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4510 * Callback function used for ewk_view_page_contents_get().
4512 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4514 EINA_SAFETY_ON_NULL_RETURN(context);
4516 RefPtr<WebString> webString = toImpl(wkString);
4517 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4518 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4521 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4523 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4524 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4525 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4526 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4528 switch (context->type) {
4529 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4530 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4533 case EWK_PAGE_CONTENTS_TYPE_STRING:
4534 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4538 ASSERT_NOT_REACHED();
4545 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4547 #if ENABLE(TIZEN_GESTURE)
4548 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4549 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4551 return impl->gestureClient->scrollToWithAnimation(x, y);
4553 UNUSED_PARAM(ewkView);
4560 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4562 #if ENABLE(TIZEN_CSP)
4563 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4564 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4566 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4567 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4571 #if ENABLE(TIZEN_APPLICATION_CACHE)
4572 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4574 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4575 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4577 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4580 impl->isWaitingForApplicationCachePermission = true;
4581 if (impl->applicationCachePermissionOrigin)
4582 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4583 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4585 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4589 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4591 #if ENABLE(TIZEN_APPLICATION_CACHE)
4592 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4593 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4595 if (!impl->applicationCachePermissionContext)
4596 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4597 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4598 impl->applicationCachePermissionContext->userData = userData;
4600 UNUSED_PARAM(ewkView);
4601 UNUSED_PARAM(callback);
4602 UNUSED_PARAM(userData);
4606 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4608 #if ENABLE(TIZEN_APPLICATION_CACHE)
4609 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4610 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4612 TIZEN_LOGI("allow %d", allow);
4613 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4614 if (impl->applicationCachePermissionOrigin)
4615 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4616 impl->applicationCachePermissionOrigin = 0;
4617 impl->isWaitingForApplicationCachePermission = false;
4619 UNUSED_PARAM(ewkView);
4620 UNUSED_PARAM(allow);
4624 #if ENABLE(TIZEN_INDEXED_DATABASE)
4625 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4627 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4628 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4630 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4633 impl->isWaitingForExceededQuotaPopupReply = true;
4634 if (impl->exceededQuotaOrigin)
4635 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4636 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4638 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4640 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4644 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4646 #if ENABLE(TIZEN_INDEXED_DATABASE)
4647 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4648 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4650 if (!impl->exceededIndexedDatabaseQuotaContext)
4651 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4652 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4653 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4655 UNUSED_PARAM(ewkView);
4656 UNUSED_PARAM(callback);
4657 UNUSED_PARAM(userData);
4661 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4663 #if ENABLE(TIZEN_INDEXED_DATABASE)
4664 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4665 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4667 TIZEN_LOGI("allow %d", allow);
4668 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4669 if (impl->exceededQuotaOrigin)
4670 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4671 impl->exceededQuotaOrigin = 0;
4672 impl->isWaitingForExceededQuotaPopupReply = false;
4674 UNUSED_PARAM(ewkView);
4675 UNUSED_PARAM(allow);
4679 // EwkFindOptions should be matched up orders with WkFindOptions.
4680 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4681 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4682 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4683 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4684 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4685 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4686 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4687 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4689 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4691 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4692 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4693 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4695 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4700 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4702 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4703 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4705 impl->pageProxy->hideFindUI();
4710 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4712 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4713 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4714 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4716 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4721 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4723 #if ENABLE(TIZEN_SQL_DATABASE)
4724 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4725 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4727 if (!impl->exceededDatabaseQuotaContext)
4728 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4729 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4730 impl->exceededDatabaseQuotaContext->userData = userData;
4732 UNUSED_PARAM(ewkView);
4733 UNUSED_PARAM(callback);
4734 UNUSED_PARAM(userData);
4738 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4740 #if ENABLE(TIZEN_SQL_DATABASE)
4741 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4744 TIZEN_LOGI("allow %d", allow);
4745 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4746 if (impl->exceededQuotaOrigin)
4747 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4748 impl->exceededQuotaOrigin = 0;
4749 impl->isWaitingForExceededQuotaPopupReply = false;
4751 UNUSED_PARAM(ewkView);
4752 UNUSED_PARAM(allow);
4756 #if ENABLE(TIZEN_FILE_SYSTEM)
4757 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4759 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4760 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4762 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4765 impl->isWaitingForExceededQuotaPopupReply = true;
4766 if (impl->exceededQuotaOrigin)
4767 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4768 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4770 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4772 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4776 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4778 #if ENABLE(TIZEN_FILE_SYSTEM)
4779 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4780 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4782 if (!impl->exceededLocalFileSystemQuotaContext)
4783 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4784 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4785 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4787 UNUSED_PARAM(ewkView);
4788 UNUSED_PARAM(callback);
4789 UNUSED_PARAM(userData);
4793 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4795 #if ENABLE(TIZEN_FILE_SYSTEM)
4796 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4797 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4799 TIZEN_LOGI("allow %d", allow);
4800 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4801 if (impl->exceededQuotaOrigin)
4802 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4803 impl->exceededQuotaOrigin = 0;
4804 impl->isWaitingForExceededQuotaPopupReply = false;
4806 UNUSED_PARAM(ewkView);
4807 UNUSED_PARAM(result);
4811 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4813 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4814 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4815 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4818 if (angle == 0 || angle == 180) {
4819 width = WebCore::getDefaultScreenResolution().width();
4820 height = WebCore::getDefaultScreenResolution().height() + 100;
4822 if (angle == 90 || angle == 270) {
4823 width = WebCore::getDefaultScreenResolution().height();
4824 height = WebCore::getDefaultScreenResolution().width() + 100;
4827 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4828 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4829 ewk_view_suspend(ewkView);
4830 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4834 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4835 void ewkViewRotatePrepared(Evas_Object* ewkView)
4837 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4841 void ewk_view_use_settings_font(Evas_Object* ewkView)
4843 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4844 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4845 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4847 impl->pageProxy->useSettingsFont();
4851 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
4853 #if ENABLE(TIZEN_FULLSCREEN_API)
4856 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4857 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4859 if (!impl->pageProxy->fullScreenManager()->isFullScreen())
4862 impl->pageProxy->fullScreenManager()->requestExitFullScreen();
4864 UNUSED_PARAM(ewkView);
4868 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object* ewkView, Eina_Bool enabled)
4870 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4871 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4873 impl->pageProxy->setDrawsTransparentBackground(enabled);
4874 evas_object_image_alpha_set(smartData->image, enabled);
4879 Eina_Bool ewk_view_draws_transparent_background_get(Evas_Object* ewkView)
4881 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4882 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4884 return impl->pageProxy->drawsTransparentBackground();