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 <tizen_webview/public/tw_webview.h>
28 #include "content/public/browser/navigation_controller.h"
29 #include "ui/events/gesture_detection/gesture_configuration.h"
30 #if !defined(EWK_BRINGUP)
31 #include "webkit/common/webpreferences.h"
33 #include "content/public/common/web_preferences.h"
35 #include "eweb_view.h"
36 #include "cookie_manager.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 #if !defined(EWK_BRINGUP)
47 #include "private/ewk_quota_permission_request_private.h"
49 #include "private/ewk_back_forward_list_private.h"
50 #include "private/ewk_history_private.h"
51 #include "private/ewk_view_private.h"
52 #include "third_party/WebKit/public/web/WebViewModeEnums.h"
53 #include "web_contents_delegate_efl.h"
55 using tizen_webview::WebView;
56 using tizen_webview::WebContext;
58 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
60 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
61 return InitSmartClassInterface(*api);
64 // TODO: Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup)
66 Evas_Object* ewk_view_add_with_session_data(Evas* canvas, const char* data, unsigned length)
68 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
70 Evas_Object* ret = ewk_view_add(canvas);
72 WebView *webView = GetWebViewFromEvasObject(ret);
74 if (!webView || !data || !length)
77 if (webView->RestoreFromSessionData(data, length))
85 Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
87 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
88 return CreateWebViewAsEvasObject(context, e);
91 Evas_Object* ewk_view_add(Evas* e)
93 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
94 // TODO: shouldn't this function create new EWebContext for each new EWebView?
95 // when using default context like that it makes unclear who should release
96 // default web context. It won't be released by destroyed eweb_view because
97 // ewk_context_default_get does AddRef
98 Ewk_Context* context = ewk_context_default_get();
99 return ewk_view_add_with_context(e, context);
102 Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
104 Ewk_Context* context = static_cast<Ewk_Context*>(WebContext::Create(true));
105 EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
106 return ewk_view_add_with_context(e, context);
109 Ewk_Context *ewk_view_context_get(const Evas_Object *view)
111 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
112 return static_cast<Ewk_Context*>(impl->GetWebContext());
115 Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url)
117 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
118 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
123 const char* ewk_view_url_get(const Evas_Object* view)
125 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
126 return impl->GetURL();
130 Eina_Bool ewk_view_reload(Evas_Object *view)
132 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
138 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
140 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
141 impl->ReloadIgnoringCache();
145 Eina_Bool ewk_view_stop(Evas_Object* view)
147 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
153 Ewk_Settings *ewk_view_settings_get(const Evas_Object *ewkView)
155 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,0);
156 return impl->GetSettings();
159 const char* ewk_view_title_get(const Evas_Object* view)
161 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
162 return impl->GetTitle();
165 double ewk_view_load_progress_get(const Evas_Object* view)
167 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
168 return impl->GetProgressValue();
171 Eina_Bool ewk_view_scale_set(const Evas_Object* view, double scale_factor, int x, int y)
173 // TODO: We should implement AC in order to work this API normally.
174 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
175 impl->SetScale(scale_factor, x, y);
179 double ewk_view_scale_get(const Evas_Object *view)
181 // TODO: We should implement AC in order to work this API normally.
182 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
183 return impl->GetScale();
186 Eina_Bool ewk_view_back(Evas_Object *view)
188 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
189 return impl->GoBack();
192 Eina_Bool ewk_view_forward(Evas_Object *view)
194 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
195 return impl->GoForward();
198 Eina_Bool ewk_view_back_possible(Evas_Object *view)
200 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
201 return impl->CanGoBack();
204 Eina_Bool ewk_view_forward_possible(Evas_Object *view)
206 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
207 return impl->CanGoForward();
210 Eina_Bool ewk_view_web_login_request(Evas_Object* ewkView)
212 LOG_EWK_API_MOCKUP();
216 Eina_Bool ewk_view_html_string_load(Evas_Object* view, const char* html, const char* base_uri, const char* unreachable_uri)
218 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
219 EINA_SAFETY_ON_NULL_RETURN_VAL(html, EINA_FALSE);
220 impl->LoadHTMLString(html, base_uri, unreachable_uri);
224 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
226 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
228 impl->SetMouseEventsEnabled(!!enabled);
233 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *view)
235 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
237 return impl->MouseEventsEnabled();
240 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
242 LOG_EWK_API_MOCKUP();
246 double ewk_view_text_zoom_get(const Evas_Object* view)
248 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1.0);
249 return impl->GetTextZoomFactor();
252 Eina_Bool ewk_view_text_zoom_set(Evas_Object* view, double text_zoom_level)
254 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
255 if (ewk_settings_text_zoom_enabled_get(ewk_view_settings_get(view))) {
256 impl->SetTextZoomFactor(text_zoom_level);
262 void ewk_view_not_found_error_page_load(Evas_Object* ewkView, const char* errorUrl)
264 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
265 impl->LoadNotFoundErrorPage(std::string(errorUrl));
268 void ewk_view_scale_range_get(Evas_Object* view, double* min_scale, double* max_scale)
270 if (!min_scale && !max_scale)
273 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
274 impl->GetPageScaleRange(min_scale, max_scale);
277 void ewk_view_suspend(Evas_Object* ewkView)
279 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
283 void ewk_view_resume(Evas_Object* ewkView)
285 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
289 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
291 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
292 EINA_SAFETY_ON_NULL_RETURN_VAL(url, EINA_FALSE);
293 content::NavigationController::LoadURLType loadtype;
295 case EWK_HTTP_METHOD_GET:
296 loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
298 case EWK_HTTP_METHOD_POST:
299 loadtype = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
302 LOG(ERROR) << "Not supported HTTP Method.";
306 impl->UrlRequestSet(url, loadtype, headers, body);
310 Eina_Bool ewk_view_plain_text_set(Evas_Object* view, const char* plain_text)
312 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
313 EINA_SAFETY_ON_NULL_RETURN_VAL(plain_text, EINA_FALSE);
314 impl->LoadPlainTextString(plain_text);
318 Eina_Bool ewk_view_contents_set(Evas_Object* view, const char* contents, size_t contents_size, char* mime_type, char* encoding, char* base_uri)
320 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
321 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, EINA_FALSE);
322 impl->LoadData(contents, contents_size, mime_type, encoding, base_uri);
326 Eina_Bool ewk_view_html_contents_set(Evas_Object* view, const char* html, const char* base_uri)
328 return ewk_view_html_string_load(view, html, base_uri, NULL);
331 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
333 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,false);
334 switch (page_visibility_state) {
335 case EWK_PAGE_VISIBILITY_STATE_VISIBLE :
338 case EWK_PAGE_VISIBILITY_STATE_HIDDEN :
347 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
349 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
351 return impl->SetUserAgent(user_agent);
354 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
356 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
357 return impl->GetUserAgent();
360 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* application_name)
362 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
363 return impl->SetUserAgentAppName(application_name);
366 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
368 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
369 return eina_stringshare_add(impl->GetUserAgentAppName());
372 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
374 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
375 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
376 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
377 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
378 return impl->GetWebContext()->HTTPCustomHeaderAdd(name, value);
381 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
383 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
384 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
385 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
386 return impl->GetWebContext()->HTTPCustomHeaderRemove(name);
390 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
392 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
393 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
394 impl->GetWebContext()->HTTPCustomHeaderClear();
399 Eina_Bool ewk_view_visibility_set(const Evas_Object* view, Eina_Bool enable)
401 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
411 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)
413 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
414 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
415 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
416 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
417 LOG(ERROR) << "We only support scale factor of 1.0."
418 << "Scaling option will be supported after hardware acceleration is enabled.";
421 return impl->GetSnapshot(view_area);
424 Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
425 float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
427 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
428 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
429 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
430 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
431 LOG(ERROR) << "We only support scale factor of 1.0."
432 << "Scaling option will be supported after hardware acceleration is enabled.";
435 return impl->GetSnapshotAsync(view_area, canvas, callback, user_data) ? EINA_TRUE : EINA_FALSE;
438 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
440 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
441 return impl->StartInspectorServer(port);
444 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
446 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
447 return impl->StopInspectorServer();
450 Evas_Object* ewk_view_cache_image_get(const Evas_Object* ewkView, const char* imageUrl, Evas* canvas)
452 LOG_EWK_API_MOCKUP();
456 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
460 if (EINA_TRUE == ewk_view_scroll_pos_get(ewkView, &x, &y)) {
461 ewk_view_scroll_set(ewkView, x + deltaX, y + deltaY);
465 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
467 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
468 EINA_SAFETY_ON_NULL_RETURN_VAL(x, EINA_FALSE);
469 EINA_SAFETY_ON_NULL_RETURN_VAL(y, EINA_FALSE);
470 return impl->GetScrollPosition(x, y);
473 Eina_Bool ewk_view_scroll_set(Evas_Object* view, int x, int y)
475 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
476 impl->SetScroll(x, y);
481 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* view, int* width, int* height)
487 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
488 impl->GetScrollSize(width,height);
492 void ewk_view_password_confirm_popup_callback_set(Evas_Object* view, Ewk_View_Password_Confirm_Popup_Callback callback, void* user_data)
494 LOG_EWK_API_MOCKUP();
497 void ewk_view_password_confirm_popup_reply(Evas_Object* ewkView, Ewk_Password_Popup_Option result)
499 LOG_EWK_API_MOCKUP();
502 void ewk_view_javascript_alert_callback_set(Evas_Object* view, Ewk_View_JavaScript_Alert_Callback callback, void* user_data)
504 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
506 impl->SetJavaScriptAlertCallback(callback, user_data);
509 void ewk_view_javascript_alert_reply(Evas_Object* view)
511 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
512 impl->JavaScriptAlertReply();
515 void ewk_view_javascript_confirm_callback_set(Evas_Object* view, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data)
517 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
519 impl->SetJavaScriptConfirmCallback(callback, user_data);
522 void ewk_view_javascript_confirm_reply(Evas_Object* view, Eina_Bool result)
524 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
525 impl->JavaScriptConfirmReply(result);
528 void ewk_view_javascript_prompt_callback_set(Evas_Object* view, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data)
530 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
532 impl->SetJavaScriptPromptCallback(callback, user_data);
535 void ewk_view_javascript_prompt_reply(Evas_Object* view, const char* result)
537 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
538 impl->JavaScriptPromptReply(result);
541 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
543 LOG_EWK_API_MOCKUP();
546 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
548 LOG_EWK_API_MOCKUP();
551 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
553 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
554 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
555 return impl->WebAppCapableGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
558 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
560 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
561 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
562 return impl->WebAppIconUrlGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
565 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
567 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
568 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
569 return impl->WebAppIconUrlsGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
572 Eina_Bool ewk_view_command_execute(Evas_Object* view, const char* command, const char* value)
574 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
575 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
576 impl->ExecuteEditCommand(command, value);
580 Eina_Bool ewk_view_contents_size_get(Evas_Object* view, Evas_Coord* width, Evas_Coord* height)
587 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
588 Eina_Rectangle contents_size = impl->GetContentsSize();
591 *width = contents_size.w;
593 *height = contents_size.h;
598 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* view, int width, int height, const char* fileName)
600 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, EINA_FALSE);
601 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
602 return impl->SaveAsPdf(width, height, fileName);
605 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
607 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
608 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
609 // callback can be null, so do not test it for null
610 if (0 != strcmp(script, "")) //check for empty string
611 return impl->ExecuteJavaScript(script, callback, user_data);
616 Eina_Bool ewk_view_plain_text_get(Evas_Object* view, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
618 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
619 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
620 return (impl->PlainTextGet(callback, user_data));
623 Eina_Bool ewk_view_mhtml_data_get(Evas_Object *view, Ewk_View_MHTML_Data_Get_Callback callback, void *user_data)
625 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
626 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
627 return impl->GetMHTMLData(callback, user_data);
630 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
632 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
633 return impl->RequestHitTestDataAt(x, y,
634 static_cast<Ewk_Hit_Test_Mode>(hit_test_mode));
637 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)
639 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
640 return impl->AsyncRequestHitTestDataAt(x, y, static_cast<Ewk_Hit_Test_Mode>(hit_test_mode), callback, user_data);
643 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
645 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
646 return impl->GetBackForwardHistory();
649 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
654 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
656 LOG_EWK_API_MOCKUP();
660 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
662 LOG_EWK_API_MOCKUP();
667 * Sends the new orientation of the device.
669 * If orientation value is changed, orientationchanged event will occur.
671 * @param view object to receive orientation event.
672 * @param orientation the new orientation of the device. (degree)
674 * orientation will be 0 degrees when the device is oriented to natural position,
675 * 90 degrees when it's left side is at the top,
676 * -90 degrees when it's right side is at the top,
677 * 180 degrees when it is upside down.
679 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
681 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
682 impl->SetOrientation(orientation);
685 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
687 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
688 impl->SetOverrideEncoding(std::string(encoding));
691 Eina_Bool ewk_view_text_selection_range_get(const Evas_Object* view, Eina_Rectangle* left_rect, Eina_Rectangle* right_rect)
693 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
694 if (left_rect && right_rect && impl->GetSelectionRange(left_rect, right_rect)) {
696 evas_object_geometry_get(view, &x, &y, 0, 0);
706 Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
708 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
709 return impl->ClearSelection() ? EINA_TRUE : EINA_FALSE;
712 const char* ewk_view_text_selection_text_get(Evas_Object* view)
714 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
715 return impl->GetSelectedText();
718 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
720 LOG_EWK_API_MOCKUP();
723 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
725 LOG_EWK_API_MOCKUP();
729 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
731 LOG_EWK_API_MOCKUP();
735 void ewk_view_vertical_panning_hold_set(Evas_Object* view, Eina_Bool hold)
737 LOG_EWK_API_MOCKUP();
738 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
739 // FIX ME: Currently the pan support is not present.
740 // In WK2 panning was implemented with evas directly, here its with chorme gesture reconignation
741 // So paning is not present yet
744 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
746 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
747 EINA_SAFETY_ON_NULL_RETURN(func);
748 impl->SetOrientationLockCallback(func, data);
752 void ewk_view_back_forward_list_clear(const Evas_Object *view)
754 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
755 impl->BackForwardListClear();
758 Eina_Bool ewk_view_feed_touch_event(Evas_Object *view, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers)
760 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
762 impl->HandleTouchEvents(type, points, modifiers);
767 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
769 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
771 impl->SetTouchEventsEnabled(!!enabled);
776 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *view)
778 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
780 return impl->TouchEventsEnabled();
783 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* o)
785 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, NULL);
786 return static_cast<Ewk_Frame_Ref>(impl->GetMainFrame());
789 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
791 LOG_EWK_API_MOCKUP();
795 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
797 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
798 EINA_SAFETY_ON_NULL_RETURN(policy);
799 impl->SetContentSecurityPolicy(policy, type);
802 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
804 // Chromium does not support this feature hence the comment
805 LOG_EWK_API_MOCKUP("Not Supported by chromium");
808 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
810 // Chromium does not support this feature hence the comment
811 LOG_EWK_API_MOCKUP("Not Supported by chromium");
814 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
816 // Chromium does not support quota for Indexed DB only.
817 // IndexedDB uses temporary storage that is shared
818 // between other features.
819 LOG_EWK_API_MOCKUP("Not Supported by chromium");
822 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
824 // Chromium does not support quota for Indexed DB only.
825 // IndexedDB uses temporary storage that is shared
826 // between other features.
827 LOG_EWK_API_MOCKUP("Not Supported by chromium");
830 Eina_Bool ewk_view_text_find(Evas_Object *view, const char *text, Ewk_Find_Options options, unsigned int max_match_count)
832 // FIXME: We need to implement next options in Ewk_Find_Options struct. (refer to ewk_view.h)
833 // - EWK_FIND_OPTIONS_AT_WORD_STARTS
834 // - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
835 // - EWK_FIND_OPTIONS_WRAP_AROUND
836 // - EWK_FIND_OPTIONS_SHOW_OVERLAY
837 // - EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR
838 // - EWK_FIND_OPTIONS_SHOW_HIGHLIGHT (Currently there is no way to control this option. so it is always set)
840 // FIXME: Updating of max_match_count is not implemented.
842 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
843 EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
844 impl->Find(text, options);
848 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *view)
850 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
855 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
857 // According to chromium source code:
858 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
859 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
860 // This API is impossible to implement right now
861 LOG_EWK_API_MOCKUP("Not Supported by chromium");
864 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
866 // According to chromium source code:
867 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
868 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
869 // This API is impossible to implement right now
870 LOG_EWK_API_MOCKUP("Not Supported by chromium");
873 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
875 LOG_EWK_API_MOCKUP();
878 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
880 LOG_EWK_API_MOCKUP();
883 void ewk_view_intercept_request_callback_set (Evas_Object* ewkView, Ewk_View_Intercept_Request_Callback callback, void* user_data)
885 LOG_EWK_API_MOCKUP();
888 void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
890 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
891 impl->SetViewUnfocusAllowCallback(callback, user_data);
894 void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
896 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
897 impl->SetViewGeolocationPermissionCallback(callback, user_data);
900 void ewk_view_use_settings_font(Evas_Object* ewkView)
902 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
903 impl->UseSettingsFont();
906 char* ewk_view_get_cookies_for_url(Evas_Object* view, const char* url)
908 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
909 EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
910 std::string cookiesForURL;
911 cookiesForURL = impl->GetWebContext()->cookieManager()->GetCookiesForURL(std::string(url));
912 if (cookiesForURL.empty())
914 return strndup(cookiesForURL.c_str(), cookiesForURL.length());
917 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* view)
919 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
920 impl->ExitFullscreen();
924 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *view, Eina_Bool enabled)
926 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
927 impl->SetDrawsTransparentBackground(enabled);
931 void ewk_view_browser_font_set(Evas_Object* ewkView)
933 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
934 impl->SetBrowserFont();
937 void ewk_view_session_data_get(Evas_Object* ewkView, const char** data, unsigned* length)
939 EINA_SAFETY_ON_NULL_RETURN(data);
940 EINA_SAFETY_ON_NULL_RETURN(length);
942 WebView* impl = GetWebViewFromEvasObject(ewkView);
949 impl->GetSessionData(data, length);
952 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode view_mode)
954 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
956 if (view_mode == EWK_VIEW_MODE_WINDOWED) {
957 impl->SetViewMode(blink::WebViewModeWindowed);
959 } else if (view_mode == EWK_VIEW_MODE_FULLSCREEN) {
960 impl->SetViewMode(blink::WebViewModeFullscreen);
967 Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const Eina_Bool enabled)
969 LOG_EWK_API_MOCKUP("for browser");
973 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
975 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
976 return impl->GetBackForwardList();
979 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
981 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
982 impl->SetNotificationPermissionCallback(callback, user_data);
985 void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
987 #if defined(OS_TIZEN_TV) && !defined(EWK_BRINGUP)
988 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
989 impl->setDrawFocusRing(enable);
991 LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
995 #if defined(OS_TIZEN_TV)
996 double ewk_view_page_zoom_get(const Evas_Object* ewkView)
998 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1002 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
1004 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1008 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
1010 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1011 return CreateWebViewAsEvasObject(context, canvas, smart);
1013 #endif // OS_TIZEN_TV
1015 #if !defined(EWK_BRINGUP)
1016 void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
1018 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1019 impl->SetQuotaPermissionRequestCallback((tizen_webview::QuotaPermissionRequest_Cb)callback, user_data);
1022 void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
1024 EINA_SAFETY_ON_NULL_RETURN(request);
1025 Evas_Object* ewkView = request->getView();
1026 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1027 impl->QuotaRequestReply(request, allow == EINA_TRUE);
1030 void ewk_view_quota_permission_request_cancel(const Ewk_Quota_Permission_Request* request)
1032 EINA_SAFETY_ON_NULL_RETURN(request);
1033 Evas_Object* ewkView = request->getView();
1034 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1035 impl->QuotaRequestCancel(request);