2 * Copyright (C) 2009-2010 ProFUSION embedded systems
3 * Copyright (C) 2009-2014 Samsung Electronics. All rights reserved.
4 * Copyright (C) 2012 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
27 #if !defined(EWK_BRINGUP)
28 #include "webkit/common/webpreferences.h"
30 #include "content/public/common/web_preferences.h"
32 #include "content/public/browser/navigation_controller.h"
33 #include "cookie_manager.h"
34 #include "eweb_view.h"
35 #include "geolocation_permission_popup.h"
36 #include "notification_permission_popup.h"
37 #include "public/ewk_back_forward_list.h"
38 #include "public/ewk_context.h"
39 #include "public/ewk_enums.h"
40 #include "public/ewk_settings.h"
41 #include "private/ewk_context_private.h"
42 #include "private/ewk_frame_private.h"
43 #include "private/ewk_hit_test_private.h"
44 #include "private/ewk_notification_private.h"
45 #include "private/ewk_private.h"
46 #include "private/ewk_quota_permission_request_private.h"
47 #include "private/ewk_back_forward_list_private.h"
48 #include "private/ewk_history_private.h"
49 #include "private/ewk_view_private.h"
50 #include "third_party/WebKit/public/web/WebViewModeEnums.h"
51 #include "ui/events/gesture_detection/gesture_configuration.h"
52 #include "usermedia_permission_popup.h"
53 #include "web_contents_delegate_efl.h"
55 static Eina_Bool _ewk_view_default_user_media_permission(
56 Evas_Object*, Ewk_User_Media_Permission_Request*, void*);
58 static Eina_Bool _ewk_view_default_geolocation_permission(
59 Evas_Object*, Ewk_Geolocation_Permission_Request*, void*);
61 static Eina_Bool _ewk_view_default_notification_permission(
62 Evas_Object*, Ewk_Notification_Permission_Request*, void*);
64 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
66 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
67 return InitSmartClassInterface(*api);
70 // TODO: Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup)
72 Evas_Object* ewk_view_add_with_session_data(Evas* canvas, const char* data, unsigned length)
74 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
76 Evas_Object* ret = ewk_view_add(canvas);
78 EWebView *webView = GetWebViewFromEvasObject(ret);
80 if (!webView || !data || !length)
83 if (webView->RestoreFromSessionData(data, length))
91 Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
93 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
94 Evas_Object* ewk_view = CreateWebViewAsEvasObject(context, e);
97 ewk_view_user_media_permission_callback_set(ewk_view,
98 _ewk_view_default_user_media_permission, 0);
99 ewk_view_geolocation_permission_callback_set(ewk_view,
100 _ewk_view_default_geolocation_permission, 0);
101 ewk_view_notification_permission_callback_set(ewk_view,
102 _ewk_view_default_notification_permission, 0);
108 Evas_Object* ewk_view_add(Evas* e)
110 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
111 // TODO: shouldn't this function create new EWebContext for each new EWebView?
112 // when using default context like that it makes unclear who should release
113 // default web context. It won't be released by destroyed eweb_view because
114 // ewk_context_default_get does AddRef
115 Ewk_Context* context = ewk_context_default_get();
116 return ewk_view_add_with_context(e, context);
119 Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
121 Ewk_Context* context = Ewk_Context::Create(true);
122 EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
123 return ewk_view_add_with_context(e, context);
126 Ewk_Context *ewk_view_context_get(const Evas_Object *view)
128 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
129 return static_cast<Ewk_Context*>(impl->context());
132 Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url)
134 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
135 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
140 const char* ewk_view_url_get(const Evas_Object* view)
142 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
143 return impl->GetURL();
147 Eina_Bool ewk_view_reload(Evas_Object *view)
149 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
155 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
157 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
158 impl->ReloadIgnoringCache();
162 Eina_Bool ewk_view_stop(Evas_Object* view)
164 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
170 Ewk_Settings *ewk_view_settings_get(const Evas_Object *ewkView)
172 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,0);
173 return impl->GetSettings();
176 const char* ewk_view_title_get(const Evas_Object* view)
178 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
179 return impl->GetTitle();
182 double ewk_view_load_progress_get(const Evas_Object* view)
184 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
185 return impl->GetProgressValue();
188 Eina_Bool ewk_view_scale_set(const Evas_Object* view, double scale_factor, int x, int y)
190 // TODO: We should implement AC in order to work this API normally.
191 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
192 impl->SetScale(scale_factor, x, y);
196 double ewk_view_scale_get(const Evas_Object *view)
198 // TODO: We should implement AC in order to work this API normally.
199 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
200 return impl->GetScale();
203 Eina_Bool ewk_view_back(Evas_Object *view)
205 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
206 return impl->GoBack();
209 Eina_Bool ewk_view_forward(Evas_Object *view)
211 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
212 return impl->GoForward();
215 Eina_Bool ewk_view_back_possible(Evas_Object *view)
217 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
218 return impl->CanGoBack();
221 Eina_Bool ewk_view_forward_possible(Evas_Object *view)
223 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
224 return impl->CanGoForward();
227 Eina_Bool ewk_view_web_login_request(Evas_Object* ewkView)
229 LOG_EWK_API_MOCKUP();
233 Eina_Bool ewk_view_html_string_load(Evas_Object* view, const char* html, const char* base_uri, const char* unreachable_uri)
235 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
236 EINA_SAFETY_ON_NULL_RETURN_VAL(html, EINA_FALSE);
237 impl->LoadHTMLString(html, base_uri, unreachable_uri);
241 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
243 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
245 impl->SetMouseEventsEnabled(!!enabled);
250 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *view)
252 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
254 return impl->MouseEventsEnabled();
257 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
259 LOG_EWK_API_MOCKUP();
263 double ewk_view_text_zoom_get(const Evas_Object* view)
265 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1.0);
266 return impl->GetTextZoomFactor();
269 Eina_Bool ewk_view_text_zoom_set(Evas_Object* view, double text_zoom_level)
271 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
272 if (ewk_settings_text_zoom_enabled_get(ewk_view_settings_get(view))) {
273 impl->SetTextZoomFactor(text_zoom_level);
279 void ewk_view_not_found_error_page_load(Evas_Object* ewkView, const char* errorUrl)
281 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
282 impl->LoadNotFoundErrorPage(std::string(errorUrl));
285 void ewk_view_scale_range_get(Evas_Object* view, double* min_scale, double* max_scale)
287 if (!min_scale && !max_scale)
290 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
291 impl->GetPageScaleRange(min_scale, max_scale);
294 void ewk_view_suspend(Evas_Object* ewkView)
296 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
300 void ewk_view_resume(Evas_Object* ewkView)
302 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
306 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
308 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
309 EINA_SAFETY_ON_NULL_RETURN_VAL(url, EINA_FALSE);
310 content::NavigationController::LoadURLType loadtype;
312 case EWK_HTTP_METHOD_GET:
313 loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
315 case EWK_HTTP_METHOD_POST:
316 loadtype = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
319 LOG(ERROR) << "Not supported HTTP Method.";
323 impl->UrlRequestSet(url, loadtype, headers, body);
327 Eina_Bool ewk_view_plain_text_set(Evas_Object* view, const char* plain_text)
329 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
330 EINA_SAFETY_ON_NULL_RETURN_VAL(plain_text, EINA_FALSE);
331 impl->LoadPlainTextString(plain_text);
335 Eina_Bool ewk_view_contents_set(Evas_Object* view, const char* contents, size_t contents_size, char* mime_type, char* encoding, char* base_uri)
337 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
338 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, EINA_FALSE);
339 impl->LoadData(contents, contents_size, mime_type, encoding, base_uri);
343 Eina_Bool ewk_view_html_contents_set(Evas_Object* view, const char* html, const char* base_uri)
345 return ewk_view_html_string_load(view, html, base_uri, NULL);
348 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
350 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,false);
351 switch (page_visibility_state) {
352 case EWK_PAGE_VISIBILITY_STATE_VISIBLE :
355 case EWK_PAGE_VISIBILITY_STATE_HIDDEN :
364 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
366 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
368 return impl->SetUserAgent(user_agent);
371 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
373 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
374 return impl->GetUserAgent();
377 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* application_name)
379 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
380 return impl->SetUserAgentAppName(application_name);
383 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
385 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
386 return eina_stringshare_add(impl->GetUserAgentAppName());
389 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
391 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
392 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
393 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
394 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
395 return impl->context()->HTTPCustomHeaderAdd(name, value);
398 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
400 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
401 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
402 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
403 return impl->context()->HTTPCustomHeaderRemove(name);
407 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
409 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
410 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
411 impl->context()->HTTPCustomHeaderClear();
416 Eina_Bool ewk_view_visibility_set(const Evas_Object* view, Eina_Bool enable)
418 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
428 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)
430 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
431 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
432 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
433 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
434 LOG(ERROR) << "We only support scale factor of 1.0."
435 << "Scaling option will be supported after hardware acceleration is enabled.";
438 return impl->GetSnapshot(view_area);
441 Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
442 float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
444 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
445 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
446 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
447 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
448 LOG(ERROR) << "We only support scale factor of 1.0."
449 << "Scaling option will be supported after hardware acceleration is enabled.";
452 return impl->GetSnapshotAsync(view_area, callback, user_data) ? EINA_TRUE : EINA_FALSE;
455 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
457 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
458 return impl->StartInspectorServer(port);
461 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
463 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
464 return impl->StopInspectorServer();
467 Evas_Object* ewk_view_cache_image_get(const Evas_Object* ewkView, const char* imageUrl, Evas* canvas)
469 LOG_EWK_API_MOCKUP();
473 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
477 if (EINA_TRUE == ewk_view_scroll_pos_get(ewkView, &x, &y)) {
478 ewk_view_scroll_set(ewkView, x + deltaX, y + deltaY);
482 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
484 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
485 EINA_SAFETY_ON_NULL_RETURN_VAL(x, EINA_FALSE);
486 EINA_SAFETY_ON_NULL_RETURN_VAL(y, EINA_FALSE);
487 return impl->GetScrollPosition(x, y);
490 Eina_Bool ewk_view_scroll_set(Evas_Object* view, int x, int y)
492 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
493 impl->SetScroll(x, y);
498 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* view, int* width, int* height)
504 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
505 impl->GetScrollSize(width,height);
509 void ewk_view_password_confirm_popup_callback_set(Evas_Object* view, Ewk_View_Password_Confirm_Popup_Callback callback, void* user_data)
511 LOG_EWK_API_MOCKUP();
514 void ewk_view_password_confirm_popup_reply(Evas_Object* ewkView, Ewk_Password_Popup_Option result)
516 LOG_EWK_API_MOCKUP();
519 void ewk_view_javascript_alert_callback_set(Evas_Object* view, Ewk_View_JavaScript_Alert_Callback callback, void* user_data)
521 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
523 impl->SetJavaScriptAlertCallback(callback, user_data);
526 void ewk_view_javascript_alert_reply(Evas_Object* view)
528 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
529 impl->JavaScriptAlertReply();
532 void ewk_view_javascript_confirm_callback_set(Evas_Object* view, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data)
534 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
536 impl->SetJavaScriptConfirmCallback(callback, user_data);
539 void ewk_view_javascript_confirm_reply(Evas_Object* view, Eina_Bool result)
541 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
542 impl->JavaScriptConfirmReply(result);
545 void ewk_view_javascript_prompt_callback_set(Evas_Object* view, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data)
547 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
549 impl->SetJavaScriptPromptCallback(callback, user_data);
552 void ewk_view_javascript_prompt_reply(Evas_Object* view, const char* result)
554 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
555 impl->JavaScriptPromptReply(result);
558 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
560 LOG_EWK_API_MOCKUP();
563 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
565 LOG_EWK_API_MOCKUP();
568 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
570 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
571 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
572 return impl->WebAppCapableGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
575 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
577 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
578 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
579 return impl->WebAppIconUrlGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
582 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
584 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
585 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
586 return impl->WebAppIconUrlsGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
589 Eina_Bool ewk_view_command_execute(Evas_Object* view, const char* command, const char* value)
591 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
592 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
593 impl->ExecuteEditCommand(command, value);
597 Eina_Bool ewk_view_contents_size_get(Evas_Object* view, Evas_Coord* width, Evas_Coord* height)
604 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
605 Eina_Rectangle contents_size = impl->GetContentsSize();
608 *width = contents_size.w;
610 *height = contents_size.h;
615 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* view, int width, int height, const char* fileName)
617 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, EINA_FALSE);
618 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
619 return impl->SaveAsPdf(width, height, fileName);
622 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
624 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
625 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
626 // callback can be null, so do not test it for null
627 if (0 != strcmp(script, "")) //check for empty string
628 return impl->ExecuteJavaScript(script, callback, user_data);
633 Eina_Bool ewk_view_plain_text_get(Evas_Object* view, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
635 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
636 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
637 return (impl->PlainTextGet(callback, user_data));
640 Eina_Bool ewk_view_mhtml_data_get(Evas_Object *view, Ewk_View_MHTML_Data_Get_Callback callback, void *user_data)
642 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
643 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
644 return impl->GetMHTMLData(callback, user_data);
647 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
649 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
650 return impl->RequestHitTestDataAt(x, y,
651 static_cast<Ewk_Hit_Test_Mode>(hit_test_mode));
654 Eina_Bool ewk_view_hit_test_request(Evas_Object* o, int x, int y, int hit_test_mode, Ewk_View_Hit_Test_Request_Callback callback, void* user_data)
656 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
657 return impl->AsyncRequestHitTestDataAt(x, y, static_cast<Ewk_Hit_Test_Mode>(hit_test_mode), callback, user_data);
660 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
662 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
663 return impl->GetBackForwardHistory();
666 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
671 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
673 LOG_EWK_API_MOCKUP();
677 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
679 LOG_EWK_API_MOCKUP();
684 * Sends the new orientation of the device.
686 * If orientation value is changed, orientationchanged event will occur.
688 * @param view object to receive orientation event.
689 * @param orientation the new orientation of the device. (degree)
691 * orientation will be 0 degrees when the device is oriented to natural position,
692 * 90 degrees when it's left side is at the top,
693 * -90 degrees when it's right side is at the top,
694 * 180 degrees when it is upside down.
696 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
698 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
699 impl->SetOrientation(orientation);
702 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
704 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
705 impl->SetOverrideEncoding(std::string(encoding));
708 Eina_Bool ewk_view_text_selection_range_get(const Evas_Object* view, Eina_Rectangle* left_rect, Eina_Rectangle* right_rect)
710 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
711 if (left_rect && right_rect && impl->GetSelectionRange(left_rect, right_rect)) {
713 evas_object_geometry_get(view, &x, &y, 0, 0);
723 Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
725 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
726 return impl->ClearSelection();
729 const char* ewk_view_text_selection_text_get(Evas_Object* view)
731 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
732 return impl->GetSelectedText();
735 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
737 LOG_EWK_API_MOCKUP();
740 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
742 LOG_EWK_API_MOCKUP();
746 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
748 LOG_EWK_API_MOCKUP();
752 void ewk_view_vertical_panning_hold_set(Evas_Object* view, Eina_Bool hold)
754 LOG_EWK_API_MOCKUP();
755 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
756 // FIX ME: Currently the pan support is not present.
757 // In WK2 panning was implemented with evas directly, here its with chorme gesture reconignation
758 // So paning is not present yet
761 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
763 LOG_EWK_API_MOCKUP("This API is deprecated, to use orientation lock/unlock "
764 "API please use functions lock_orientation/unlock_orientation provided "
765 "by Ewk_View_Smart_Class.");
769 void ewk_view_back_forward_list_clear(const Evas_Object *view)
771 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
772 impl->BackForwardListClear();
775 Eina_Bool ewk_view_feed_touch_event(Evas_Object *view, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers)
777 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
779 impl->HandleTouchEvents(type, points, modifiers);
784 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
786 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
788 impl->SetTouchEventsEnabled(!!enabled);
793 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *view)
795 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
797 return impl->TouchEventsEnabled();
800 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* o)
802 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, NULL);
803 return static_cast<Ewk_Frame_Ref>(impl->GetMainFrame());
806 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
808 LOG_EWK_API_MOCKUP();
812 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
814 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
815 EINA_SAFETY_ON_NULL_RETURN(policy);
816 impl->SetContentSecurityPolicy(policy, type);
819 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
821 // Chromium does not support this feature hence the comment
822 LOG_EWK_API_MOCKUP("Not Supported by chromium");
825 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
827 // Chromium does not support this feature hence the comment
828 LOG_EWK_API_MOCKUP("Not Supported by chromium");
831 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
833 // Chromium does not support quota for Indexed DB only.
834 // IndexedDB uses temporary storage that is shared
835 // between other features.
836 LOG_EWK_API_MOCKUP("Not Supported by chromium");
839 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
841 // Chromium does not support quota for Indexed DB only.
842 // IndexedDB uses temporary storage that is shared
843 // between other features.
844 LOG_EWK_API_MOCKUP("Not Supported by chromium");
847 Eina_Bool ewk_view_text_find(Evas_Object *view, const char *text, Ewk_Find_Options options, unsigned int max_match_count)
849 // FIXME: We need to implement next options in Ewk_Find_Options struct. (refer to ewk_view.h)
850 // - EWK_FIND_OPTIONS_AT_WORD_STARTS
851 // - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
852 // - EWK_FIND_OPTIONS_WRAP_AROUND
853 // - EWK_FIND_OPTIONS_SHOW_OVERLAY
854 // - EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR
855 // - EWK_FIND_OPTIONS_SHOW_HIGHLIGHT (Currently there is no way to control this option. so it is always set)
857 // FIXME: Updating of max_match_count is not implemented.
859 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
860 EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
861 impl->Find(text, options);
865 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *view)
867 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
872 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
874 // According to chromium source code:
875 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
876 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
877 // This API is impossible to implement right now
878 LOG_EWK_API_MOCKUP("Not Supported by chromium");
881 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
883 // According to chromium source code:
884 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
885 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
886 // This API is impossible to implement right now
887 LOG_EWK_API_MOCKUP("Not Supported by chromium");
890 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
892 LOG_EWK_API_MOCKUP();
895 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
897 LOG_EWK_API_MOCKUP();
900 void ewk_view_intercept_request_callback_set (Evas_Object* ewkView, Ewk_View_Intercept_Request_Callback callback, void* user_data)
902 LOG_EWK_API_MOCKUP();
905 void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
907 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
908 impl->SetViewUnfocusAllowCallback(callback, user_data);
911 void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
913 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
914 impl->SetViewGeolocationPermissionCallback(callback, user_data);
917 static Eina_Bool _ewk_view_default_geolocation_permission(
918 Evas_Object* ewk_view,
919 Ewk_Geolocation_Permission_Request* request,
922 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
924 std::string value = std::string(ewk_security_origin_host_get(
925 ewk_geolocation_permission_request_origin_get(request)));
926 std::string message = std::string(
927 "Web Page (%s) is requesting permission to access your location.");
928 std::string replace_str = std::string("(%s)");
930 size_t pos = message.find(replace_str.c_str());
931 if (pos != std::string::npos)
932 message.replace(pos, replace_str.length(), value.c_str());
934 // add for suspending
935 ewk_geolocation_permission_request_suspend(request);
937 GeolocationPermissionPopup* popup = new GeolocationPermissionPopup(request,
938 ewk_geolocation_permission_request_origin_get(request), message);
940 impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
945 void ewk_view_user_media_permission_callback_set(Evas_Object* ewk_view,
946 Ewk_View_User_Media_Permission_Callback callback,
949 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
950 impl->SetViewUserMediaPermissionCallback(callback, user_data);
953 static Eina_Bool _ewk_view_default_user_media_permission(
954 Evas_Object* ewk_view,
955 Ewk_User_Media_Permission_Request* user_media_permission_request,
958 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
960 std::string value = std::string(ewk_security_origin_host_get(
961 ewk_user_media_permission_request_origin_get(
962 user_media_permission_request)));
964 std::string message = std::string(dgettext(
966 "IDS_WEBVIEW_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_USE_YOUR_CAMERA"));
968 std::string replace_str = std::string("%1$s");
969 size_t pos = message.find(replace_str.c_str());
970 if (pos != std::string::npos)
971 message.replace(pos, replace_str.length(), value.c_str());
973 replace_str = std::string("(%2$s)");
974 pos = message.find(replace_str.c_str());
975 if (pos != std::string::npos)
976 message.replace(pos, replace_str.length(), "");
978 // add for suspending
979 ewk_user_media_permission_request_suspend(user_media_permission_request);
981 UserMediaPermissionPopup* popup = new UserMediaPermissionPopup(
982 user_media_permission_request,
983 ewk_user_media_permission_request_origin_get(
984 user_media_permission_request), message);
986 impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
991 void ewk_view_use_settings_font(Evas_Object* ewkView)
993 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
994 impl->UseSettingsFont();
997 char* ewk_view_get_cookies_for_url(Evas_Object* view, const char* url)
999 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
1000 EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
1001 std::string cookiesForURL;
1002 cookiesForURL = impl->context()->cookieManager()->GetCookiesForURL(std::string(url));
1003 if (cookiesForURL.empty())
1005 return strndup(cookiesForURL.c_str(), cookiesForURL.length());
1008 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* view)
1010 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
1011 impl->ExitFullscreen();
1015 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *view, Eina_Bool enabled)
1017 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
1018 impl->SetDrawsTransparentBackground(enabled);
1022 void ewk_view_browser_font_set(Evas_Object* ewkView)
1024 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1025 impl->SetBrowserFont();
1028 void ewk_view_session_data_get(Evas_Object* ewkView, const char** data, unsigned* length)
1030 EINA_SAFETY_ON_NULL_RETURN(data);
1031 EINA_SAFETY_ON_NULL_RETURN(length);
1033 EWebView* impl = GetWebViewFromEvasObject(ewkView);
1040 impl->GetSessionData(data, length);
1043 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode view_mode)
1045 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
1047 if (view_mode == EWK_VIEW_MODE_WINDOWED) {
1048 impl->SetViewMode(blink::WebViewModeWindowed);
1050 } else if (view_mode == EWK_VIEW_MODE_FULLSCREEN) {
1051 impl->SetViewMode(blink::WebViewModeFullscreen);
1058 Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const Eina_Bool enabled)
1060 LOG_EWK_API_MOCKUP("for browser");
1064 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1066 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
1067 return impl->GetBackForwardList();
1070 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
1072 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
1073 impl->SetNotificationPermissionCallback(callback, user_data);
1076 static Eina_Bool _ewk_view_default_notification_permission(
1077 Evas_Object* ewk_view,
1078 Ewk_Notification_Permission_Request* request,
1081 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
1083 std::string value = std::string(ewk_security_origin_host_get(
1084 ewk_notification_permission_request_origin_get(request)));
1085 std::string message = std::string(
1086 "Web Page (%s) is requesting permission to show notifications.");
1087 std::string replace_str = std::string("(%s)");
1089 size_t pos = message.find(replace_str.c_str());
1090 if (pos != std::string::npos)
1091 message.replace(pos, replace_str.length(), value.c_str());
1093 // add for suspending
1094 ewk_notification_permission_request_suspend(request);
1096 NotificationPermissionPopup* popup = new NotificationPermissionPopup(request,
1097 ewk_notification_permission_request_origin_get(request), message);
1099 impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
1104 void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
1106 #if defined(OS_TIZEN_TV) && !defined(EWK_BRINGUP)
1107 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1108 impl->setDrawFocusRing(enable);
1110 LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
1114 double ewk_view_page_zoom_get(const Evas_Object* ewkView)
1116 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1120 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
1122 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1126 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
1128 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1129 return CreateWebViewAsEvasObject(context, canvas, smart);
1132 void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
1134 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1135 impl->SetQuotaPermissionRequestCallback(callback, user_data);
1138 void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
1140 EINA_SAFETY_ON_NULL_RETURN(request);
1141 Evas_Object* ewkView = request->getView();
1142 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1143 impl->QuotaRequestReply(request, allow == EINA_TRUE);
1146 void ewk_view_quota_permission_request_cancel(const Ewk_Quota_Permission_Request* request)
1148 EINA_SAFETY_ON_NULL_RETURN(request);
1149 Evas_Object* ewkView = request->getView();
1150 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1151 impl->QuotaRequestCancel(request);