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.
26 #include <content/public/browser/navigation_controller.h>
27 #include <tizen_webview/public/tw_webview.h>
29 // TODO: remove dependency
30 #include <ui/events/gesture_detection/gesture_configuration.h>
31 #if !defined(EWK_BRINGUP)
32 #include <webkit/common/webpreferences.h>
34 #include <content/public/common/web_preferences.h>
36 #include <../impl/eweb_view.h>
37 #include <../impl/web_contents_delegate_efl.h>
38 #include <../impl/cookie_manager.h>
40 #include "public/ewk_back_forward_list.h"
41 #include "public/ewk_context.h"
42 #include "public/ewk_enums.h"
43 #include "public/ewk_settings.h"
44 #include "private/ewk_context_private.h"
45 #include "private/ewk_frame_private.h"
46 #include "private/ewk_hit_test_private.h"
47 #include "private/ewk_notification_private.h"
48 #include "private/ewk_private.h"
49 #if !defined(EWK_BRINGUP)
50 #include "private/ewk_quota_permission_request_private.h"
52 #include "private/chromium_glue.h"
53 #include "private/ewk_back_forward_list_private.h"
54 #include "private/ewk_history_private.h"
55 #include "private/ewk_view_private.h"
57 using tizen_webview::WebView;
58 using tizen_webview::WebContext;
60 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
62 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
63 return InitSmartClassInterface(*api);
66 // TODO: Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup)
68 Evas_Object* ewk_view_add_with_session_data(Evas* canvas, const char* data, unsigned length)
70 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
72 Evas_Object* ret = ewk_view_add(canvas);
74 WebView *webView = GetWebViewFromEvasObject(ret);
76 if (!webView || !data || !length)
79 if (webView->RestoreFromSessionData(data, length))
87 Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
89 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
90 return CreateWebViewAsEvasObject(context, e);
93 Evas_Object* ewk_view_add(Evas* e)
95 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
96 // TODO: shouldn't this function create new EWebContext for each new EWebView?
97 // when using default context like that it makes unclear who should release
98 // default web context. It won't be released by destroyed eweb_view because
99 // ewk_context_default_get does AddRef
100 Ewk_Context* context = ewk_context_default_get();
101 return ewk_view_add_with_context(e, context);
104 Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
106 Ewk_Context* context = static_cast<Ewk_Context*>(WebContext::Create(true));
107 EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
108 return ewk_view_add_with_context(e, context);
111 Ewk_Context *ewk_view_context_get(const Evas_Object *view)
113 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
114 return static_cast<Ewk_Context*>(impl->GetWebContext());
117 Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url)
119 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
120 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
125 const char* ewk_view_url_get(const Evas_Object* view)
127 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
128 return impl->GetURL();
132 Eina_Bool ewk_view_reload(Evas_Object *view)
134 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
140 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
142 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
143 impl->ReloadIgnoringCache();
147 Eina_Bool ewk_view_stop(Evas_Object* view)
149 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
155 Ewk_Settings *ewk_view_settings_get(const Evas_Object *ewkView)
157 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,0);
158 return impl->GetSettings();
161 const char* ewk_view_title_get(const Evas_Object* view)
163 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
164 return impl->GetTitle();
167 double ewk_view_load_progress_get(const Evas_Object* view)
169 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
170 return impl->GetProgressValue();
173 Eina_Bool ewk_view_scale_set(const Evas_Object* view, double scale_factor, int x, int y)
175 // TODO: We should implement AC in order to work this API normally.
176 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
177 impl->SetScale(scale_factor, x, y);
181 double ewk_view_scale_get(const Evas_Object *view)
183 // TODO: We should implement AC in order to work this API normally.
184 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
185 return impl->GetScale();
188 Eina_Bool ewk_view_back(Evas_Object *view)
190 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
191 return impl->GoBack();
194 Eina_Bool ewk_view_forward(Evas_Object *view)
196 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
197 return impl->GoForward();
200 Eina_Bool ewk_view_back_possible(Evas_Object *view)
202 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
203 return impl->CanGoBack();
206 Eina_Bool ewk_view_forward_possible(Evas_Object *view)
208 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
209 return impl->CanGoForward();
212 Eina_Bool ewk_view_web_login_request(Evas_Object* ewkView)
214 LOG_EWK_API_MOCKUP();
218 Eina_Bool ewk_view_html_string_load(Evas_Object* view, const char* html, const char* base_uri, const char* unreachable_uri)
220 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
221 EINA_SAFETY_ON_NULL_RETURN_VAL(html, EINA_FALSE);
222 impl->LoadHTMLString(html, base_uri, unreachable_uri);
226 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
228 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
230 impl->SetMouseEventsEnabled(!!enabled);
235 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *view)
237 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
239 return impl->MouseEventsEnabled();
242 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
244 LOG_EWK_API_MOCKUP();
248 double ewk_view_text_zoom_get(const Evas_Object* view)
250 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1.0);
251 return impl->GetTextZoomFactor();
254 Eina_Bool ewk_view_text_zoom_set(Evas_Object* view, double text_zoom_level)
256 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
257 if (ewk_settings_text_zoom_enabled_get(ewk_view_settings_get(view))) {
258 impl->SetTextZoomFactor(text_zoom_level);
264 void ewk_view_not_found_error_page_load(Evas_Object* ewkView, const char* errorUrl)
266 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
267 impl->LoadNotFoundErrorPage(std::string(errorUrl));
270 void ewk_view_scale_range_get(Evas_Object* view, double* min_scale, double* max_scale)
272 if (!min_scale && !max_scale)
275 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
276 impl->GetPageScaleRange(min_scale, max_scale);
279 void ewk_view_suspend(Evas_Object* ewkView)
281 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
285 void ewk_view_resume(Evas_Object* ewkView)
287 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
291 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
293 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
294 EINA_SAFETY_ON_NULL_RETURN_VAL(url, EINA_FALSE);
295 content::NavigationController::LoadURLType loadtype;
297 case EWK_HTTP_METHOD_GET:
298 loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
300 case EWK_HTTP_METHOD_POST:
301 loadtype = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
304 LOG(ERROR) << "Not supported HTTP Method.";
308 impl->UrlRequestSet(url, loadtype, headers, body);
312 Eina_Bool ewk_view_plain_text_set(Evas_Object* view, const char* plain_text)
314 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
315 EINA_SAFETY_ON_NULL_RETURN_VAL(plain_text, EINA_FALSE);
316 impl->LoadPlainTextString(plain_text);
320 Eina_Bool ewk_view_contents_set(Evas_Object* view, const char* contents, size_t contents_size, char* mime_type, char* encoding, char* base_uri)
322 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
323 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, EINA_FALSE);
324 impl->LoadData(contents, contents_size, mime_type, encoding, base_uri);
328 Eina_Bool ewk_view_html_contents_set(Evas_Object* view, const char* html, const char* base_uri)
330 return ewk_view_html_string_load(view, html, base_uri, NULL);
333 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
335 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,false);
336 switch (page_visibility_state) {
337 case EWK_PAGE_VISIBILITY_STATE_VISIBLE :
340 case EWK_PAGE_VISIBILITY_STATE_HIDDEN :
349 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
351 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
353 return impl->SetUserAgent(user_agent);
356 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
358 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
359 return impl->GetUserAgent();
362 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* application_name)
364 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
365 return impl->SetUserAgentAppName(application_name);
368 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
370 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
371 return eina_stringshare_add(impl->GetUserAgentAppName());
374 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
376 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
377 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
378 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
379 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
380 return impl->GetWebContext()->HTTPCustomHeaderAdd(name, value);
383 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
385 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
386 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
387 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
388 return impl->GetWebContext()->HTTPCustomHeaderRemove(name);
392 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
394 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
395 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
396 impl->GetWebContext()->HTTPCustomHeaderClear();
401 Eina_Bool ewk_view_visibility_set(const Evas_Object* view, Eina_Bool enable)
403 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
413 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)
415 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
416 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
417 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
418 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
419 LOG(ERROR) << "We only support scale factor of 1.0."
420 << "Scaling option will be supported after hardware acceleration is enabled.";
423 return impl->GetSnapshot(view_area);
426 Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
427 float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
429 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, NULL);
430 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
431 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
432 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
433 LOG(ERROR) << "We only support scale factor of 1.0."
434 << "Scaling option will be supported after hardware acceleration is enabled.";
437 return impl->GetSnapshotAsync(view_area, canvas, callback, user_data) ? EINA_TRUE : EINA_FALSE;
440 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
442 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
443 return impl->StartInspectorServer(port);
446 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
448 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
449 return impl->StopInspectorServer();
452 Evas_Object* ewk_view_cache_image_get(const Evas_Object* ewkView, const char* imageUrl, Evas* canvas)
454 LOG_EWK_API_MOCKUP();
458 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
462 if (EINA_TRUE == ewk_view_scroll_pos_get(ewkView, &x, &y)) {
463 ewk_view_scroll_set(ewkView, x + deltaX, y + deltaY);
467 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
469 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
470 EINA_SAFETY_ON_NULL_RETURN_VAL(x, EINA_FALSE);
471 EINA_SAFETY_ON_NULL_RETURN_VAL(y, EINA_FALSE);
472 return impl->GetScrollPosition(x, y);
475 Eina_Bool ewk_view_scroll_set(Evas_Object* view, int x, int y)
477 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
478 impl->SetScroll(x, y);
483 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* view, int* width, int* height)
489 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
490 impl->GetScrollSize(width,height);
494 void ewk_view_password_confirm_popup_callback_set(Evas_Object* view, Ewk_View_Password_Confirm_Popup_Callback callback, void* user_data)
496 LOG_EWK_API_MOCKUP();
499 void ewk_view_password_confirm_popup_reply(Evas_Object* ewkView, Ewk_Password_Popup_Option result)
501 LOG_EWK_API_MOCKUP();
504 void ewk_view_javascript_alert_callback_set(Evas_Object* view, Ewk_View_JavaScript_Alert_Callback callback, void* user_data)
506 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
508 impl->SetJavaScriptAlertCallback(callback, user_data);
511 void ewk_view_javascript_alert_reply(Evas_Object* view)
513 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
514 impl->JavaScriptAlertReply();
517 void ewk_view_javascript_confirm_callback_set(Evas_Object* view, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data)
519 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
521 impl->SetJavaScriptConfirmCallback(callback, user_data);
524 void ewk_view_javascript_confirm_reply(Evas_Object* view, Eina_Bool result)
526 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
527 impl->JavaScriptConfirmReply(result);
530 void ewk_view_javascript_prompt_callback_set(Evas_Object* view, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data)
532 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
534 impl->SetJavaScriptPromptCallback(callback, user_data);
537 void ewk_view_javascript_prompt_reply(Evas_Object* view, const char* result)
539 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
540 impl->JavaScriptPromptReply(result);
543 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
545 LOG_EWK_API_MOCKUP();
548 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
550 LOG_EWK_API_MOCKUP();
553 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
555 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
556 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
557 return impl->WebAppCapableGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
560 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
562 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
563 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
564 return impl->WebAppIconUrlGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
567 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
569 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
570 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
571 return impl->WebAppIconUrlsGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
574 Eina_Bool ewk_view_command_execute(Evas_Object* view, const char* command, const char* value)
576 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
577 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
578 impl->ExecuteEditCommand(command, value);
582 Eina_Bool ewk_view_contents_size_get(Evas_Object* view, Evas_Coord* width, Evas_Coord* height)
589 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
590 Eina_Rectangle contents_size = impl->GetContentsSize();
593 *width = contents_size.w;
595 *height = contents_size.h;
600 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* view, int width, int height, const char* fileName)
602 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, EINA_FALSE);
603 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
604 return impl->SaveAsPdf(width, height, fileName);
607 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
609 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
610 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
611 // callback can be null, so do not test it for null
612 if (0 != strcmp(script, "")) //check for empty string
613 return impl->ExecuteJavaScript(script, callback, user_data);
618 Eina_Bool ewk_view_plain_text_get(Evas_Object* view, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
620 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
621 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
622 return (impl->PlainTextGet(callback, user_data));
625 Eina_Bool ewk_view_mhtml_data_get(Evas_Object *view, Ewk_View_MHTML_Data_Get_Callback callback, void *user_data)
627 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
628 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
629 return impl->GetMHTMLData(callback, user_data);
632 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
634 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
635 return chromium_glue::from(impl->RequestHitTestDataAt(x, y,
636 chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode))));
639 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)
641 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
642 return impl->AsyncRequestHitTestDataAt(x, y, chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode)), chromium_glue::to(callback), user_data);
645 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
647 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
648 return chromium_glue::from(impl->GetBackForwardHistory());
651 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
653 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
655 #if !defined(EWK_BRINGUP)
656 #warning "[M38] Fix and re-enable notifications (edit efl_integration/public/ewk_view.cc)"
657 // copied from deleted NotificationControllerEfl::RemoveClosedNotifications()
658 if (!eina_list_count(notification_list))
661 assert(impl->GetWebContext());
662 assert(impl->GetWebContext()->browser_context());
663 assert(impl->GetWebContext()->browser_context()->GetNotificationController());
664 scoped_refptr<content::NotificationControllerEfl> controller =
665 impl->GetWebContext()->browser_context()->GetNotificationController();
667 Eina_List* notification_iterator = NULL;
668 void* notification_data = NULL;
669 EINA_LIST_FOREACH(notification_list, notification_iterator, notification_data) {
670 Ewk_Notification* notification =
671 static_cast<Ewk_Notification*>(notification_data);
674 controller->DeleteNotification(notification->GetID(), true);
683 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
685 LOG_EWK_API_MOCKUP();
689 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
691 LOG_EWK_API_MOCKUP();
696 * Sends the new orientation of the device.
698 * If orientation value is changed, orientationchanged event will occur.
700 * @param view object to receive orientation event.
701 * @param orientation the new orientation of the device. (degree)
703 * orientation will be 0 degrees when the device is oriented to natural position,
704 * 90 degrees when it's left side is at the top,
705 * -90 degrees when it's right side is at the top,
706 * 180 degrees when it is upside down.
708 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
710 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
711 impl->SetOrientation(orientation);
714 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
716 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
717 impl->SetOverrideEncoding(std::string(encoding));
720 Eina_Bool ewk_view_text_selection_range_get(const Evas_Object* view, Eina_Rectangle* left_rect, Eina_Rectangle* right_rect)
722 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
723 if (left_rect && right_rect && impl->GetSelectionRange(left_rect, right_rect)) {
725 evas_object_geometry_get(view, &x, &y, 0, 0);
735 Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
737 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
738 return impl->ClearSelection() ? EINA_TRUE : EINA_FALSE;
741 const char* ewk_view_text_selection_text_get(Evas_Object* view)
743 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
744 return impl->GetSelectedText();
747 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
749 LOG_EWK_API_MOCKUP();
752 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
754 LOG_EWK_API_MOCKUP();
758 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
760 LOG_EWK_API_MOCKUP();
764 void ewk_view_vertical_panning_hold_set(Evas_Object* view, Eina_Bool hold)
766 LOG_EWK_API_MOCKUP();
767 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
768 // FIX ME: Currently the pan support is not present.
769 // In WK2 panning was implemented with evas directly, here its with chorme gesture reconignation
770 // So paning is not present yet
773 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
775 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
776 EINA_SAFETY_ON_NULL_RETURN(func);
777 impl->SetOrientationLockCallback(func, data);
781 void ewk_view_back_forward_list_clear(const Evas_Object *view)
783 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
784 impl->BackForwardListClear();
787 Eina_Bool ewk_view_feed_touch_event(Evas_Object *view, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers)
789 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
791 impl->HandleTouchEvents(chromium_glue::to(type), points, modifiers);
796 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
798 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
800 impl->SetTouchEventsEnabled(!!enabled);
805 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *view)
807 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
809 return impl->TouchEventsEnabled();
812 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* o)
814 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, NULL);
815 return static_cast<Ewk_Frame_Ref>(impl->GetMainFrame());
818 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
820 LOG_EWK_API_MOCKUP();
824 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
826 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
827 EINA_SAFETY_ON_NULL_RETURN(policy);
828 impl->SetContentSecurityPolicy(policy, chromium_glue::to(type));
831 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
833 // Chromium does not support this feature hence the comment
834 LOG_EWK_API_MOCKUP("Not Supported by chromium");
837 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
839 // Chromium does not support this feature hence the comment
840 LOG_EWK_API_MOCKUP("Not Supported by chromium");
843 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
845 // Chromium does not support quota for Indexed DB only.
846 // IndexedDB uses temporary storage that is shared
847 // between other features.
848 LOG_EWK_API_MOCKUP("Not Supported by chromium");
851 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
853 // Chromium does not support quota for Indexed DB only.
854 // IndexedDB uses temporary storage that is shared
855 // between other features.
856 LOG_EWK_API_MOCKUP("Not Supported by chromium");
859 Eina_Bool ewk_view_text_find(Evas_Object *view, const char *text, Ewk_Find_Options options, unsigned int max_match_count)
861 // FIXME: We need to implement next options in Ewk_Find_Options struct. (refer to ewk_view.h)
862 // - EWK_FIND_OPTIONS_AT_WORD_STARTS
863 // - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
864 // - EWK_FIND_OPTIONS_WRAP_AROUND
865 // - EWK_FIND_OPTIONS_SHOW_OVERLAY
866 // - EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR
867 // - EWK_FIND_OPTIONS_SHOW_HIGHLIGHT (Currently there is no way to control this option. so it is always set)
869 // FIXME: Updating of max_match_count is not implemented.
871 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
872 EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
873 impl->Find(text, chromium_glue::to(options));
877 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *view)
879 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
884 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
886 // According to chromium source code:
887 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
888 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
889 // This API is impossible to implement right now
890 LOG_EWK_API_MOCKUP("Not Supported by chromium");
893 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
895 // According to chromium source code:
896 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
897 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
898 // This API is impossible to implement right now
899 LOG_EWK_API_MOCKUP("Not Supported by chromium");
902 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
904 LOG_EWK_API_MOCKUP();
907 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
909 LOG_EWK_API_MOCKUP();
912 void ewk_view_intercept_request_callback_set (Evas_Object* ewkView, Ewk_View_Intercept_Request_Callback callback, void* user_data)
914 LOG_EWK_API_MOCKUP();
917 void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
919 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
920 impl->SetViewUnfocusAllowCallback(
921 reinterpret_cast<tizen_webview::View_Unfocus_Allow_Callback>
922 (callback), user_data);
925 void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
927 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
928 impl->SetViewGeolocationPermissionCallback(
929 reinterpret_cast<tizen_webview::View_Geolocation_Permission_Callback>(callback), user_data);
932 void ewk_view_use_settings_font(Evas_Object* ewkView)
934 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
935 impl->UseSettingsFont();
938 char* ewk_view_get_cookies_for_url(Evas_Object* view, const char* url)
940 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
941 EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
942 std::string cookiesForURL;
943 cookiesForURL = impl->GetWebContext()->cookieManager()->GetCookiesForURL(std::string(url));
944 if (cookiesForURL.empty())
946 return strndup(cookiesForURL.c_str(), cookiesForURL.length());
949 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* view)
951 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
952 impl->ExitFullscreen();
956 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *view, Eina_Bool enabled)
958 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
959 impl->SetDrawsTransparentBackground(enabled);
963 void ewk_view_browser_font_set(Evas_Object* ewkView)
965 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
966 impl->SetBrowserFont();
969 void ewk_view_session_data_get(Evas_Object* ewkView, const char** data, unsigned* length)
971 EINA_SAFETY_ON_NULL_RETURN(data);
972 EINA_SAFETY_ON_NULL_RETURN(length);
974 WebView* impl = GetWebViewFromEvasObject(ewkView);
981 impl->GetSessionData(data, length);
984 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode view_mode)
986 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
988 if (view_mode == EWK_VIEW_MODE_WINDOWED || view_mode == EWK_VIEW_MODE_FULLSCREEN) {
989 tizen_webview::View_Mode tizen_webview_view_mode;
990 tizen_webview_view_mode = chromium_glue::to(view_mode);
991 impl->SetViewMode(tizen_webview_view_mode);
998 Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const Eina_Bool enabled)
1000 LOG_EWK_API_MOCKUP("for browser");
1004 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1006 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
1007 return chromium_glue::from(impl->GetBackForwardList());
1010 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
1012 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
1013 impl->SetNotificationPermissionCallback(reinterpret_cast<tizen_webview::View_Notification_Permission_Callback>(callback), user_data);
1016 void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
1018 #if defined(OS_TIZEN_TV) && !defined(EWK_BRINGUP)
1019 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1020 impl->setDrawFocusRing(enable);
1022 LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
1026 #if defined(OS_TIZEN_TV)
1027 double ewk_view_page_zoom_get(const Evas_Object* ewkView)
1029 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1033 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
1035 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1039 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
1041 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1042 return CreateWebViewAsEvasObject(context, canvas, smart);
1044 #endif // OS_TIZEN_TV
1046 #if !defined(EWK_BRINGUP)
1047 void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
1049 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1050 impl->SetQuotaPermissionRequestCallback((tizen_webview::QuotaPermissionRequest_Cb)callback, user_data);
1053 void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
1055 EINA_SAFETY_ON_NULL_RETURN(request);
1056 Evas_Object* ewkView = request->getView();
1057 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1058 impl->QuotaRequestReply(request, allow == EINA_TRUE);
1061 void ewk_view_quota_permission_request_cancel(const Ewk_Quota_Permission_Request* request)
1063 EINA_SAFETY_ON_NULL_RETURN(request);
1064 Evas_Object* ewkView = request->getView();
1065 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1066 impl->QuotaRequestCancel(request);