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) // FIXME: m67 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 // FIXME: removed on m63
51 //#include "third_party/blink/public/web/WebViewModeEnums.h"
52 #include "ui/events/gesture_detection/gesture_configuration.h"
54 #include "usermedia_permission_popup.h"
55 #include "web_contents_delegate_efl.h"
57 static Eina_Bool _ewk_view_default_user_media_permission(
58 Evas_Object*, Ewk_User_Media_Permission_Request*, void*);
60 static Eina_Bool _ewk_view_default_geolocation_permission(
61 Evas_Object*, Ewk_Geolocation_Permission_Request*, void*);
63 static Eina_Bool _ewk_view_default_notification_permission(
64 Evas_Object*, Ewk_Notification_Permission_Request*, void*);
66 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
68 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
69 return InitSmartClassInterface(*api);
72 // TODO: Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup)
74 Evas_Object* ewk_view_add_with_session_data(Evas* canvas, const char* data, unsigned length)
76 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
78 Evas_Object* ret = ewk_view_add(canvas);
80 EWebView *webView = GetWebViewFromEvasObject(ret);
82 if (!webView || !data || !length)
85 if (webView->RestoreFromSessionData(data, length))
93 Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
95 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
96 Evas_Object* ewk_view = CreateWebViewAsEvasObject(context, e);
99 ewk_view_user_media_permission_callback_set(ewk_view,
100 _ewk_view_default_user_media_permission, 0);
101 ewk_view_geolocation_permission_callback_set(ewk_view,
102 _ewk_view_default_geolocation_permission, 0);
103 ewk_view_notification_permission_callback_set(ewk_view,
104 _ewk_view_default_notification_permission, 0);
110 Evas_Object* ewk_view_add(Evas* e)
112 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
113 // TODO: shouldn't this function create new EWebContext for each new EWebView?
114 // when using default context like that it makes unclear who should release
115 // default web context. It won't be released by destroyed eweb_view because
116 // ewk_context_default_get does AddRef
117 Ewk_Context* context = ewk_context_default_get();
118 return ewk_view_add_with_context(e, context);
121 Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
123 Ewk_Context* context = Ewk_Context::Create(true);
124 EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
125 return ewk_view_add_with_context(e, context);
128 Ewk_Context *ewk_view_context_get(const Evas_Object *view)
130 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
131 return static_cast<Ewk_Context*>(impl->context());
134 Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url_string)
136 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
137 EINA_SAFETY_ON_NULL_RETURN_VAL(url_string, false);
138 GURL url(url_string);
143 const char* ewk_view_url_get(const Evas_Object* view)
145 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
146 return impl->GetURL().possibly_invalid_spec().c_str();
150 Eina_Bool ewk_view_reload(Evas_Object *view)
152 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
158 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
160 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
161 impl->ReloadBypassingCache();
165 Eina_Bool ewk_view_stop(Evas_Object* view)
167 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
173 Ewk_Settings *ewk_view_settings_get(const Evas_Object *ewkView)
175 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,0);
176 return impl->GetSettings();
179 const char* ewk_view_title_get(const Evas_Object* view)
181 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
182 return impl->GetTitle();
185 double ewk_view_load_progress_get(const Evas_Object* view)
187 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
188 return impl->GetProgressValue();
191 Eina_Bool ewk_view_scale_set(const Evas_Object* view, double scale_factor, int x, int y)
193 // TODO: We should implement AC in order to work this API normally.
194 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
195 impl->SetScale(scale_factor, x, y);
199 double ewk_view_scale_get(const Evas_Object *view)
201 // TODO: We should implement AC in order to work this API normally.
202 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
203 return impl->GetScale();
206 Eina_Bool ewk_view_back(Evas_Object *view)
208 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
209 return impl->GoBack();
212 Eina_Bool ewk_view_forward(Evas_Object *view)
214 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
215 return impl->GoForward();
218 Eina_Bool ewk_view_back_possible(Evas_Object *view)
220 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
221 return impl->CanGoBack();
224 Eina_Bool ewk_view_forward_possible(Evas_Object *view)
226 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
227 return impl->CanGoForward();
230 Eina_Bool ewk_view_web_login_request(Evas_Object* ewkView)
232 LOG_EWK_API_MOCKUP();
236 Eina_Bool ewk_view_html_string_load(Evas_Object* view, const char* html, const char* base_uri, const char* unreachable_uri)
238 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
239 EINA_SAFETY_ON_NULL_RETURN_VAL(html, EINA_FALSE);
240 impl->LoadHTMLString(html, base_uri, unreachable_uri);
244 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
246 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
248 impl->SetMouseEventsEnabled(!!enabled);
253 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *view)
255 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
257 return impl->MouseEventsEnabled();
260 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
262 LOG_EWK_API_MOCKUP();
266 double ewk_view_text_zoom_get(const Evas_Object* view)
268 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1.0);
269 return impl->GetTextZoomFactor();
272 Eina_Bool ewk_view_text_zoom_set(Evas_Object* view, double text_zoom_level)
274 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
275 if (ewk_settings_text_zoom_enabled_get(ewk_view_settings_get(view))) {
276 impl->SetTextZoomFactor(text_zoom_level);
282 void ewk_view_not_found_error_page_load(Evas_Object* ewkView, const char* errorUrl)
284 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
285 impl->LoadNotFoundErrorPage(std::string(errorUrl));
288 void ewk_view_scale_range_get(Evas_Object* view, double* min_scale, double* max_scale)
290 if (!min_scale && !max_scale)
293 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
294 impl->GetPageScaleRange(min_scale, max_scale);
297 void ewk_view_suspend(Evas_Object* ewkView)
299 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
303 void ewk_view_resume(Evas_Object* ewkView)
305 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
309 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
311 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
312 EINA_SAFETY_ON_NULL_RETURN_VAL(url, EINA_FALSE);
313 content::NavigationController::LoadURLType loadtype;
315 case EWK_HTTP_METHOD_GET:
316 loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
318 case EWK_HTTP_METHOD_POST:
319 loadtype = content::NavigationController::LOAD_TYPE_HTTP_POST;
322 LOG(ERROR) << "Not supported HTTP Method.";
326 impl->UrlRequestSet(url, loadtype, headers, body);
330 Eina_Bool ewk_view_plain_text_set(Evas_Object* view, const char* plain_text)
332 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
333 EINA_SAFETY_ON_NULL_RETURN_VAL(plain_text, EINA_FALSE);
334 impl->LoadPlainTextString(plain_text);
338 Eina_Bool ewk_view_contents_set(Evas_Object* view, const char* contents, size_t contents_size, char* mime_type, char* encoding, char* base_uri)
340 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
341 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, EINA_FALSE);
342 impl->LoadData(contents, contents_size, mime_type, encoding, base_uri);
346 Eina_Bool ewk_view_html_contents_set(Evas_Object* view, const char* html, const char* base_uri)
348 return ewk_view_html_string_load(view, html, base_uri, NULL);
351 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
353 // TODO: Should we send initial_state to |Page::setVisibilityState()|?.
354 // isInitialState parameter seems be true only in the constructor of WebViewImpl.
355 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
357 // TODO: We should able to set 'prerender' or 'unloaded' as visibility state.
358 // http://www.w3.org/TR/page-visibility/#dom-document-visibilitystate
359 switch (page_visibility_state) {
360 case EWK_PAGE_VISIBILITY_STATE_VISIBLE:
363 case EWK_PAGE_VISIBILITY_STATE_HIDDEN:
372 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
374 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
376 return impl->SetUserAgent(user_agent);
379 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
381 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
382 return impl->GetUserAgent();
385 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* application_name)
387 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
388 return impl->SetUserAgentAppName(application_name);
391 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
393 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
394 return eina_stringshare_add(impl->GetUserAgentAppName());
397 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
399 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
400 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
401 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
402 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
403 return impl->context()->HTTPCustomHeaderAdd(name, value);
406 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
408 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
409 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
410 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
411 return impl->context()->HTTPCustomHeaderRemove(name);
415 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
417 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
418 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context(),EINA_FALSE);
419 impl->context()->HTTPCustomHeaderClear();
424 Eina_Bool ewk_view_visibility_set(const Evas_Object* view, Eina_Bool enable)
426 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
436 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)
438 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
439 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
440 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
441 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
442 LOG(ERROR) << "We only support scale factor of 1.0."
443 << "Scaling option will be supported after hardware acceleration is enabled.";
446 return impl->GetSnapshot(view_area);
449 Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
450 float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
452 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
453 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
454 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
455 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
456 LOG(ERROR) << "We only support scale factor of 1.0."
457 << "Scaling option will be supported after hardware acceleration is enabled.";
460 return impl->GetSnapshotAsync(view_area, callback, user_data) ? EINA_TRUE : EINA_FALSE;
463 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
465 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
466 return impl->StartInspectorServer(port);
469 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
471 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
472 return impl->StopInspectorServer();
475 Evas_Object* ewk_view_cache_image_get(const Evas_Object* ewkView, const char* imageUrl, Evas* canvas)
477 LOG_EWK_API_MOCKUP();
481 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
485 if (EINA_TRUE == ewk_view_scroll_pos_get(ewkView, &x, &y)) {
486 ewk_view_scroll_set(ewkView, x + deltaX, y + deltaY);
490 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
492 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
493 EINA_SAFETY_ON_NULL_RETURN_VAL(x, EINA_FALSE);
494 EINA_SAFETY_ON_NULL_RETURN_VAL(y, EINA_FALSE);
495 return impl->GetScrollPosition(x, y);
498 Eina_Bool ewk_view_scroll_set(Evas_Object* view, int x, int y)
500 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
501 impl->SetScroll(x, y);
506 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* view, int* width, int* height)
512 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
513 impl->GetScrollSize(width,height);
517 void ewk_view_password_confirm_popup_callback_set(Evas_Object* view, Ewk_View_Password_Confirm_Popup_Callback callback, void* user_data)
519 LOG_EWK_API_MOCKUP();
522 void ewk_view_password_confirm_popup_reply(Evas_Object* ewkView, Ewk_Password_Popup_Option result)
524 LOG_EWK_API_MOCKUP();
527 void ewk_view_javascript_alert_callback_set(Evas_Object* view, Ewk_View_JavaScript_Alert_Callback callback, void* user_data)
529 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
531 impl->SetJavaScriptAlertCallback(callback, user_data);
534 void ewk_view_javascript_alert_reply(Evas_Object* view)
536 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
537 impl->JavaScriptAlertReply();
540 void ewk_view_javascript_confirm_callback_set(Evas_Object* view, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data)
542 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
544 impl->SetJavaScriptConfirmCallback(callback, user_data);
547 void ewk_view_javascript_confirm_reply(Evas_Object* view, Eina_Bool result)
549 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
550 impl->JavaScriptConfirmReply(result);
553 void ewk_view_javascript_prompt_callback_set(Evas_Object* view, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data)
555 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
557 impl->SetJavaScriptPromptCallback(callback, user_data);
560 void ewk_view_javascript_prompt_reply(Evas_Object* view, const char* result)
562 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
563 impl->JavaScriptPromptReply(result);
566 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
568 LOG_EWK_API_MOCKUP();
571 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
573 LOG_EWK_API_MOCKUP();
576 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
578 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
579 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
580 return impl->WebAppCapableGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
583 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
585 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
586 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
587 return impl->WebAppIconUrlGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
590 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
592 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
593 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
594 return impl->WebAppIconUrlsGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
597 Eina_Bool ewk_view_command_execute(Evas_Object* view, const char* command, const char* value)
599 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
600 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
601 impl->ExecuteEditCommand(command, value);
605 Eina_Bool ewk_view_contents_size_get(Evas_Object* view, Evas_Coord* width, Evas_Coord* height)
612 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
613 Eina_Rectangle contents_size = impl->GetContentsSize();
616 *width = contents_size.w;
618 *height = contents_size.h;
623 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* view, int width, int height, const char* fileName)
625 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, EINA_FALSE);
626 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
627 return impl->SaveAsPdf(width, height, fileName);
630 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
632 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
633 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
634 // callback can be null, so do not test it for null
635 if (0 != strcmp(script, "")) //check for empty string
636 return impl->ExecuteJavaScript(script, callback, user_data);
641 Eina_Bool ewk_view_plain_text_get(Evas_Object* view, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
643 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
644 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
645 return (impl->PlainTextGet(callback, user_data));
648 Eina_Bool ewk_view_mhtml_data_get(Evas_Object *view, Ewk_View_MHTML_Data_Get_Callback callback, void *user_data)
650 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
651 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
652 return impl->GetMHTMLData(callback, user_data);
655 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
657 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
658 return impl->RequestHitTestDataAt(x, y,
659 static_cast<Ewk_Hit_Test_Mode>(hit_test_mode));
662 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)
664 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
665 return impl->AsyncRequestHitTestDataAt(x, y, static_cast<Ewk_Hit_Test_Mode>(hit_test_mode), callback, user_data);
668 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
670 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
671 return impl->GetBackForwardHistory();
674 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
679 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
681 LOG_EWK_API_MOCKUP();
685 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
687 LOG_EWK_API_MOCKUP();
692 * Sends the new orientation of the device.
694 * If orientation value is changed, orientationchanged event will occur.
696 * @param view object to receive orientation event.
697 * @param orientation the new orientation of the device. (degree)
699 * orientation will be 0 degrees when the device is oriented to natural position,
700 * 90 degrees when it's left side is at the top,
701 * -90 degrees when it's right side is at the top,
702 * 180 degrees when it is upside down.
704 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
706 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
707 impl->SetOrientation(orientation);
710 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
712 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
713 impl->SetOverrideEncoding(std::string(encoding));
716 Eina_Bool ewk_view_text_selection_range_get(const Evas_Object* view, Eina_Rectangle* left_rect, Eina_Rectangle* right_rect)
718 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
719 if (left_rect && right_rect && impl->GetSelectionRange(left_rect, right_rect)) {
721 evas_object_geometry_get(view, &x, &y, 0, 0);
731 Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
733 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
734 return impl->ClearSelection();
737 const char* ewk_view_text_selection_text_get(Evas_Object* view)
739 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
740 return impl->GetSelectedText();
743 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
745 LOG_EWK_API_MOCKUP();
748 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
750 LOG_EWK_API_MOCKUP();
754 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
756 LOG_EWK_API_MOCKUP();
760 void ewk_view_vertical_panning_hold_set(Evas_Object* view, Eina_Bool hold)
762 LOG_EWK_API_MOCKUP();
763 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
764 // FIX ME: Currently the pan support is not present.
765 // In WK2 panning was implemented with evas directly, here its with chorme gesture reconignation
766 // So paning is not present yet
769 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
771 LOG_EWK_API_MOCKUP("This API is deprecated, to use orientation lock/unlock "
772 "API please use functions lock_orientation/unlock_orientation provided "
773 "by Ewk_View_Smart_Class.");
777 void ewk_view_back_forward_list_clear(const Evas_Object *view)
779 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
780 impl->BackForwardListClear();
783 Eina_Bool ewk_view_feed_touch_event(Evas_Object *view, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers)
785 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
787 impl->HandleTouchEvents(type, points, modifiers);
792 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
794 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
796 impl->SetTouchEventsEnabled(!!enabled);
801 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *view)
803 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
805 return impl->TouchEventsEnabled();
808 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* o)
810 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, NULL);
811 return static_cast<Ewk_Frame_Ref>(impl->GetMainFrame());
814 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
816 LOG_EWK_API_MOCKUP();
820 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
822 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
823 EINA_SAFETY_ON_NULL_RETURN(policy);
824 impl->SetContentSecurityPolicy(policy, type);
827 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
829 // Chromium does not support this feature hence the comment
830 LOG_EWK_API_MOCKUP("Not Supported by chromium");
833 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
835 // Chromium does not support this feature hence the comment
836 LOG_EWK_API_MOCKUP("Not Supported by chromium");
839 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
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 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
849 // Chromium does not support quota for Indexed DB only.
850 // IndexedDB uses temporary storage that is shared
851 // between other features.
852 LOG_EWK_API_MOCKUP("Not Supported by chromium");
855 Eina_Bool ewk_view_text_find(Evas_Object *view, const char *text, Ewk_Find_Options options, unsigned int max_match_count)
857 // FIXME: We need to implement next options in Ewk_Find_Options struct. (refer to ewk_view.h)
858 // - EWK_FIND_OPTIONS_AT_WORD_STARTS
859 // - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
860 // - EWK_FIND_OPTIONS_WRAP_AROUND
861 // - EWK_FIND_OPTIONS_SHOW_OVERLAY
862 // - EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR
863 // - EWK_FIND_OPTIONS_SHOW_HIGHLIGHT (Currently there is no way to control this option. so it is always set)
865 // FIXME: Updating of max_match_count is not implemented.
867 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
868 EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
869 impl->Find(text, options);
873 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *view)
875 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
880 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
882 // According to chromium source code:
883 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
884 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
885 // This API is impossible to implement right now
886 LOG_EWK_API_MOCKUP("Not Supported by chromium");
889 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
891 // According to chromium source code:
892 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
893 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
894 // This API is impossible to implement right now
895 LOG_EWK_API_MOCKUP("Not Supported by chromium");
898 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
900 LOG_EWK_API_MOCKUP();
903 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
905 LOG_EWK_API_MOCKUP();
908 void ewk_view_intercept_request_callback_set (Evas_Object* ewkView, Ewk_View_Intercept_Request_Callback callback, void* user_data)
910 LOG_EWK_API_MOCKUP();
913 void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
915 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
916 impl->SetViewUnfocusAllowCallback(callback, user_data);
919 void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
921 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
922 impl->SetViewGeolocationPermissionCallback(callback, user_data);
925 static Eina_Bool _ewk_view_default_geolocation_permission(
926 Evas_Object* ewk_view,
927 Ewk_Geolocation_Permission_Request* request,
930 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
932 std::string value = std::string(ewk_security_origin_host_get(
933 ewk_geolocation_permission_request_origin_get(request)));
934 std::string message = std::string(
935 "Web Page (%s) is requesting permission to access your location.");
936 std::string replace_str = std::string("(%s)");
938 size_t pos = message.find(replace_str.c_str());
939 if (pos != std::string::npos)
940 message.replace(pos, replace_str.length(), value.c_str());
942 // add for suspending
943 ewk_geolocation_permission_request_suspend(request);
945 GeolocationPermissionPopup* popup = new GeolocationPermissionPopup(request,
946 ewk_geolocation_permission_request_origin_get(request), message);
948 impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
953 void ewk_view_user_media_permission_callback_set(Evas_Object* ewk_view,
954 Ewk_View_User_Media_Permission_Callback callback,
957 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
958 impl->SetViewUserMediaPermissionCallback(callback, user_data);
961 static Eina_Bool _ewk_view_default_user_media_permission(
962 Evas_Object* ewk_view,
963 Ewk_User_Media_Permission_Request* user_media_permission_request,
966 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
968 std::string value = std::string(ewk_security_origin_host_get(
969 ewk_user_media_permission_request_origin_get(
970 user_media_permission_request)));
972 std::string message = std::string(dgettext(
974 "IDS_WEBVIEW_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_USE_YOUR_CAMERA"));
976 std::string replace_str = std::string("%1$s");
977 size_t pos = message.find(replace_str.c_str());
978 if (pos != std::string::npos)
979 message.replace(pos, replace_str.length(), value.c_str());
981 replace_str = std::string("(%2$s)");
982 pos = message.find(replace_str.c_str());
983 if (pos != std::string::npos)
984 message.replace(pos, replace_str.length(), "");
986 // add for suspending
987 ewk_user_media_permission_request_suspend(user_media_permission_request);
989 UserMediaPermissionPopup* popup = new UserMediaPermissionPopup(
990 user_media_permission_request,
991 ewk_user_media_permission_request_origin_get(
992 user_media_permission_request), message);
994 impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
999 void ewk_view_use_settings_font(Evas_Object* ewkView)
1001 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1002 impl->UseSettingsFont();
1005 char* ewk_view_get_cookies_for_url(Evas_Object* view, const char* url)
1007 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
1008 EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
1009 std::string cookiesForURL;
1010 cookiesForURL = impl->context()->cookieManager()->GetCookiesForURL(std::string(url));
1011 if (cookiesForURL.empty())
1013 return strndup(cookiesForURL.c_str(), cookiesForURL.length());
1016 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* view)
1018 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
1019 impl->ExitFullscreen();
1023 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *view, Eina_Bool enabled)
1025 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
1026 impl->SetDrawsTransparentBackground(enabled);
1030 void ewk_view_browser_font_set(Evas_Object* ewkView)
1032 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1033 impl->SetBrowserFont();
1036 void ewk_view_session_data_get(Evas_Object* ewkView, const char** data, unsigned* length)
1038 EINA_SAFETY_ON_NULL_RETURN(data);
1039 EINA_SAFETY_ON_NULL_RETURN(length);
1041 EWebView* impl = GetWebViewFromEvasObject(ewkView);
1048 impl->GetSessionData(data, length);
1051 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode view_mode)
1053 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
1055 if (view_mode == EWK_VIEW_MODE_WINDOWED) {
1056 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
1057 impl->SetViewMode(blink::WebViewModeWindowed);
1060 } else if (view_mode == EWK_VIEW_MODE_FULLSCREEN) {
1061 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
1062 impl->SetViewMode(blink::WebViewModeFullscreen);
1070 Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const Eina_Bool enabled)
1072 LOG_EWK_API_MOCKUP("for browser");
1076 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1078 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
1079 return impl->GetBackForwardList();
1082 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
1084 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
1085 impl->SetNotificationPermissionCallback(callback, user_data);
1088 static Eina_Bool _ewk_view_default_notification_permission(
1089 Evas_Object* ewk_view,
1090 Ewk_Notification_Permission_Request* request,
1093 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE);
1095 std::string value = std::string(ewk_security_origin_host_get(
1096 ewk_notification_permission_request_origin_get(request)));
1097 std::string message = std::string(
1098 "Web Page (%s) is requesting permission to show notifications.");
1099 std::string replace_str = std::string("(%s)");
1101 size_t pos = message.find(replace_str.c_str());
1102 if (pos != std::string::npos)
1103 message.replace(pos, replace_str.length(), value.c_str());
1105 // add for suspending
1106 ewk_notification_permission_request_suspend(request);
1108 NotificationPermissionPopup* popup = new NotificationPermissionPopup(request,
1109 ewk_notification_permission_request_origin_get(request), message);
1111 impl->GetPermissionPopupManager()->AddPermissionRequest(popup);
1116 void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
1118 LOG_EWK_API_MOCKUP("This API is deprecated");
1121 double ewk_view_page_zoom_get(const Evas_Object* ewkView)
1123 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1.0);
1124 return impl->GetPageZoomFactor();
1127 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
1129 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
1130 impl->SetPageZoomFactor(zoomFactor);
1134 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
1136 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1137 return CreateWebViewAsEvasObject(context, canvas, smart);
1140 void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
1142 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1143 impl->SetQuotaPermissionRequestCallback(callback, user_data);
1146 void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
1148 EINA_SAFETY_ON_NULL_RETURN(request);
1149 Evas_Object* ewkView = request->getView();
1150 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1151 impl->QuotaRequestReply(request, allow == EINA_TRUE);
1154 void ewk_view_quota_permission_request_cancel(const Ewk_Quota_Permission_Request* request)
1156 EINA_SAFETY_ON_NULL_RETURN(request);
1157 Evas_Object* ewkView = request->getView();
1158 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1159 impl->QuotaRequestCancel(request);