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;
57 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
59 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
60 return InitSmartClassInterface(*api);
63 // TODO: Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context, Ewk_Page_Group *pageGroup)
65 Evas_Object* ewk_view_add_with_session_data(Evas* canvas, const char* data, unsigned length)
67 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
69 Evas_Object* ret = ewk_view_add(canvas);
71 WebView *webView = GetWebViewFromEvasObject(ret);
73 if (!webView || !data || !length)
76 if (webView->RestoreFromSessionData(data, length))
84 Evas_Object* ewk_view_add_with_context(Evas* e, Ewk_Context* context)
86 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
87 return CreateWebViewAsEvasObject(context, e);
90 Evas_Object* ewk_view_add(Evas* e)
92 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
93 // TODO: shouldn't this function create new EWebContext for each new EWebView?
94 // when using default context like that it makes unclear who should release
95 // default web context. It won't be released by destroyed eweb_view because
96 // ewk_context_default_get does AddRef
97 Ewk_Context* context = ewk_context_default_get();
98 return ewk_view_add_with_context(e, context);
101 Evas_Object* ewk_view_add_in_incognito_mode(Evas* e)
103 Ewk_Context* context = Ewk_Context::Create(true);
104 EINA_SAFETY_ON_NULL_RETURN_VAL(context, NULL);
105 return ewk_view_add_with_context(e, context);
108 Ewk_Context *ewk_view_context_get(const Evas_Object *view)
110 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
111 return static_cast<Ewk_Context*>(impl->GetWebContext());
114 Eina_Bool ewk_view_url_set(Evas_Object* view, const char* url)
116 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
117 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
122 const char* ewk_view_url_get(const Evas_Object* view)
124 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
125 return impl->GetURL();
129 Eina_Bool ewk_view_reload(Evas_Object *view)
131 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
137 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *view)
139 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
140 impl->ReloadIgnoringCache();
144 Eina_Bool ewk_view_stop(Evas_Object* view)
146 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
152 Ewk_Settings *ewk_view_settings_get(const Evas_Object *ewkView)
154 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,0);
155 return impl->GetSettings();
158 const char* ewk_view_title_get(const Evas_Object* view)
160 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
161 return impl->GetTitle();
164 double ewk_view_load_progress_get(const Evas_Object* view)
166 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
167 return impl->GetProgressValue();
170 Eina_Bool ewk_view_scale_set(const Evas_Object* view, double scale_factor, int x, int y)
172 // TODO: We should implement AC in order to work this API normally.
173 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
174 impl->SetScale(scale_factor, x, y);
178 double ewk_view_scale_get(const Evas_Object *view)
180 // TODO: We should implement AC in order to work this API normally.
181 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1);
182 return impl->GetScale();
185 Eina_Bool ewk_view_back(Evas_Object *view)
187 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
188 return impl->GoBack();
191 Eina_Bool ewk_view_forward(Evas_Object *view)
193 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
194 return impl->GoForward();
197 Eina_Bool ewk_view_back_possible(Evas_Object *view)
199 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
200 return impl->CanGoBack();
203 Eina_Bool ewk_view_forward_possible(Evas_Object *view)
205 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
206 return impl->CanGoForward();
209 Eina_Bool ewk_view_web_login_request(Evas_Object* ewkView)
211 LOG_EWK_API_MOCKUP();
215 Eina_Bool ewk_view_html_string_load(Evas_Object* view, const char* html, const char* base_uri, const char* unreachable_uri)
217 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
218 EINA_SAFETY_ON_NULL_RETURN_VAL(html, EINA_FALSE);
219 impl->LoadHTMLString(html, base_uri, unreachable_uri);
223 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
225 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
227 impl->SetMouseEventsEnabled(!!enabled);
232 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *view)
234 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
236 return impl->MouseEventsEnabled();
239 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
241 LOG_EWK_API_MOCKUP();
245 double ewk_view_text_zoom_get(const Evas_Object* view)
247 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, -1.0);
248 return impl->GetTextZoomFactor();
251 Eina_Bool ewk_view_text_zoom_set(Evas_Object* view, double text_zoom_level)
253 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
254 if (ewk_settings_text_zoom_enabled_get(ewk_view_settings_get(view))) {
255 impl->SetTextZoomFactor(text_zoom_level);
261 void ewk_view_not_found_error_page_load(Evas_Object* ewkView, const char* errorUrl)
263 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
264 impl->LoadNotFoundErrorPage(std::string(errorUrl));
267 void ewk_view_scale_range_get(Evas_Object* view, double* min_scale, double* max_scale)
269 if (!min_scale && !max_scale)
272 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
273 impl->GetPageScaleRange(min_scale, max_scale);
276 void ewk_view_suspend(Evas_Object* ewkView)
278 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
282 void ewk_view_resume(Evas_Object* ewkView)
284 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
288 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
290 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
291 EINA_SAFETY_ON_NULL_RETURN_VAL(url, EINA_FALSE);
292 content::NavigationController::LoadURLType loadtype;
294 case EWK_HTTP_METHOD_GET:
295 loadtype = content::NavigationController::LOAD_TYPE_DEFAULT;
297 case EWK_HTTP_METHOD_POST:
298 loadtype = content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
301 LOG(ERROR) << "Not supported HTTP Method.";
305 impl->UrlRequestSet(url, loadtype, headers, body);
309 Eina_Bool ewk_view_plain_text_set(Evas_Object* view, const char* plain_text)
311 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
312 EINA_SAFETY_ON_NULL_RETURN_VAL(plain_text, EINA_FALSE);
313 impl->LoadPlainTextString(plain_text);
317 Eina_Bool ewk_view_contents_set(Evas_Object* view, const char* contents, size_t contents_size, char* mime_type, char* encoding, char* base_uri)
319 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
320 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, EINA_FALSE);
321 impl->LoadData(contents, contents_size, mime_type, encoding, base_uri);
325 Eina_Bool ewk_view_html_contents_set(Evas_Object* view, const char* html, const char* base_uri)
327 return ewk_view_html_string_load(view, html, base_uri, NULL);
330 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State page_visibility_state, Eina_Bool initial_state)
332 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl,false);
333 switch (page_visibility_state) {
334 case EWK_PAGE_VISIBILITY_STATE_VISIBLE :
337 case EWK_PAGE_VISIBILITY_STATE_HIDDEN :
346 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
348 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
350 return impl->SetUserAgent(user_agent);
353 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
355 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
356 return impl->GetUserAgent();
359 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* application_name)
361 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
362 return impl->SetUserAgentAppName(application_name);
365 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
367 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
368 return eina_stringshare_add(impl->GetUserAgentAppName());
371 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
373 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
374 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
375 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
376 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
377 return impl->GetWebContext()->HTTPCustomHeaderAdd(name, value);
380 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
382 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
383 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
384 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
385 return impl->GetWebContext()->HTTPCustomHeaderRemove(name);
389 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
391 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
392 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->GetWebContext(),EINA_FALSE);
393 impl->GetWebContext()->HTTPCustomHeaderClear();
398 Eina_Bool ewk_view_visibility_set(const Evas_Object* view, Eina_Bool enable)
400 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
410 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)
412 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, NULL);
413 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
414 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
415 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
416 LOG(ERROR) << "We only support scale factor of 1.0."
417 << "Scaling option will be supported after hardware acceleration is enabled.";
420 return impl->GetSnapshot(view_area);
423 Eina_Bool ewk_view_screenshot_contents_get_async(const Evas_Object* view, Eina_Rectangle view_area,
424 float scale_factor, Evas* canvas, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data)
426 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
427 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
428 // Zoom level equality (<=0.001) is sufficient compared to high precision std::numeric_value::epsilon.
429 if (!content::ZoomValuesEqual(scale_factor, 1.0)) {
430 LOG(ERROR) << "We only support scale factor of 1.0."
431 << "Scaling option will be supported after hardware acceleration is enabled.";
434 return impl->GetSnapshotAsync(view_area, canvas, callback, user_data) ? EINA_TRUE : EINA_FALSE;
437 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
439 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
440 return impl->StartInspectorServer(port);
443 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
445 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
446 return impl->StopInspectorServer();
449 Evas_Object* ewk_view_cache_image_get(const Evas_Object* ewkView, const char* imageUrl, Evas* canvas)
451 LOG_EWK_API_MOCKUP();
455 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
459 if (EINA_TRUE == ewk_view_scroll_pos_get(ewkView, &x, &y)) {
460 ewk_view_scroll_set(ewkView, x + deltaX, y + deltaY);
464 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
466 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
467 EINA_SAFETY_ON_NULL_RETURN_VAL(x, EINA_FALSE);
468 EINA_SAFETY_ON_NULL_RETURN_VAL(y, EINA_FALSE);
469 return impl->GetScrollPosition(x, y);
472 Eina_Bool ewk_view_scroll_set(Evas_Object* view, int x, int y)
474 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
475 impl->SetScroll(x, y);
480 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* view, int* width, int* height)
486 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
487 impl->GetScrollSize(width,height);
491 void ewk_view_password_confirm_popup_callback_set(Evas_Object* view, Ewk_View_Password_Confirm_Popup_Callback callback, void* user_data)
493 LOG_EWK_API_MOCKUP();
496 void ewk_view_password_confirm_popup_reply(Evas_Object* ewkView, Ewk_Password_Popup_Option result)
498 LOG_EWK_API_MOCKUP();
501 void ewk_view_javascript_alert_callback_set(Evas_Object* view, Ewk_View_JavaScript_Alert_Callback callback, void* user_data)
503 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
505 impl->SetJavaScriptAlertCallback(callback, user_data);
508 void ewk_view_javascript_alert_reply(Evas_Object* view)
510 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
511 impl->JavaScriptAlertReply();
514 void ewk_view_javascript_confirm_callback_set(Evas_Object* view, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data)
516 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
518 impl->SetJavaScriptConfirmCallback(callback, user_data);
521 void ewk_view_javascript_confirm_reply(Evas_Object* view, Eina_Bool result)
523 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
524 impl->JavaScriptConfirmReply(result);
527 void ewk_view_javascript_prompt_callback_set(Evas_Object* view, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data)
529 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
531 impl->SetJavaScriptPromptCallback(callback, user_data);
534 void ewk_view_javascript_prompt_reply(Evas_Object* view, const char* result)
536 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
537 impl->JavaScriptPromptReply(result);
540 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
542 LOG_EWK_API_MOCKUP();
545 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
547 LOG_EWK_API_MOCKUP();
550 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
552 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
553 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
554 return impl->WebAppCapableGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
557 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
559 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
560 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
561 return impl->WebAppIconUrlGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
564 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
566 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
567 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
568 return impl->WebAppIconUrlsGet(callback, userData) ? EINA_TRUE : EINA_FALSE;
571 Eina_Bool ewk_view_command_execute(Evas_Object* view, const char* command, const char* value)
573 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
574 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
575 impl->ExecuteEditCommand(command, value);
579 Eina_Bool ewk_view_contents_size_get(Evas_Object* view, Evas_Coord* width, Evas_Coord* height)
586 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
587 Eina_Rectangle contents_size = impl->GetContentsSize();
590 *width = contents_size.w;
592 *height = contents_size.h;
597 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* view, int width, int height, const char* fileName)
599 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, EINA_FALSE);
600 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
601 return impl->SaveAsPdf(width, height, fileName);
604 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
606 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
607 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
608 // callback can be null, so do not test it for null
609 if (0 != strcmp(script, "")) //check for empty string
610 return impl->ExecuteJavaScript(script, callback, user_data);
615 Eina_Bool ewk_view_plain_text_get(Evas_Object* view, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
617 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
618 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
619 return (impl->PlainTextGet(callback, user_data));
622 Eina_Bool ewk_view_mhtml_data_get(Evas_Object *view, Ewk_View_MHTML_Data_Get_Callback callback, void *user_data)
624 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE);
625 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
626 return impl->GetMHTMLData(callback, user_data);
629 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hit_test_mode)
631 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
632 return impl->RequestHitTestDataAt(x, y,
633 static_cast<Ewk_Hit_Test_Mode>(hit_test_mode));
636 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)
638 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE);
639 return impl->AsyncRequestHitTestDataAt(x, y, static_cast<Ewk_Hit_Test_Mode>(hit_test_mode), callback, user_data);
642 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
644 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
645 return impl->GetBackForwardHistory();
648 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
653 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
655 LOG_EWK_API_MOCKUP();
659 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
661 LOG_EWK_API_MOCKUP();
666 * Sends the new orientation of the device.
668 * If orientation value is changed, orientationchanged event will occur.
670 * @param view object to receive orientation event.
671 * @param orientation the new orientation of the device. (degree)
673 * orientation will be 0 degrees when the device is oriented to natural position,
674 * 90 degrees when it's left side is at the top,
675 * -90 degrees when it's right side is at the top,
676 * 180 degrees when it is upside down.
678 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
680 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
681 impl->SetOrientation(orientation);
684 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
686 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
687 impl->SetOverrideEncoding(std::string(encoding));
690 Eina_Bool ewk_view_text_selection_range_get(const Evas_Object* view, Eina_Rectangle* left_rect, Eina_Rectangle* right_rect)
692 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
693 if (left_rect && right_rect && impl->GetSelectionRange(left_rect, right_rect)) {
695 evas_object_geometry_get(view, &x, &y, 0, 0);
705 Eina_Bool ewk_view_text_selection_clear(Evas_Object *view)
707 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
708 return impl->ClearSelection() ? EINA_TRUE : EINA_FALSE;
711 const char* ewk_view_text_selection_text_get(Evas_Object* view)
713 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, NULL);
714 return impl->GetSelectedText();
717 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
719 LOG_EWK_API_MOCKUP();
722 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
724 LOG_EWK_API_MOCKUP();
728 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
730 LOG_EWK_API_MOCKUP();
734 void ewk_view_vertical_panning_hold_set(Evas_Object* view, Eina_Bool hold)
736 LOG_EWK_API_MOCKUP();
737 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
738 // FIX ME: Currently the pan support is not present.
739 // In WK2 panning was implemented with evas directly, here its with chorme gesture reconignation
740 // So paning is not present yet
743 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
745 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
746 EINA_SAFETY_ON_NULL_RETURN(func);
747 impl->SetOrientationLockCallback(func, data);
751 void ewk_view_back_forward_list_clear(const Evas_Object *view)
753 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
754 impl->BackForwardListClear();
757 Eina_Bool ewk_view_feed_touch_event(Evas_Object *view, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers)
759 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
761 impl->HandleTouchEvents(type, points, modifiers);
766 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *view, Eina_Bool enabled)
768 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
770 impl->SetTouchEventsEnabled(!!enabled);
775 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *view)
777 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, false);
779 return impl->TouchEventsEnabled();
782 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* o)
784 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, NULL);
785 return static_cast<Ewk_Frame_Ref>(impl->GetMainFrame());
788 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
790 LOG_EWK_API_MOCKUP();
794 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
796 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
797 EINA_SAFETY_ON_NULL_RETURN(policy);
798 impl->SetContentSecurityPolicy(policy, type);
801 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
803 // Chromium does not support this feature hence the comment
804 LOG_EWK_API_MOCKUP("Not Supported by chromium");
807 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
809 // Chromium does not support this feature hence the comment
810 LOG_EWK_API_MOCKUP("Not Supported by chromium");
813 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
815 // Chromium does not support quota for Indexed DB only.
816 // IndexedDB uses temporary storage that is shared
817 // between other features.
818 LOG_EWK_API_MOCKUP("Not Supported by chromium");
821 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
823 // Chromium does not support quota for Indexed DB only.
824 // IndexedDB uses temporary storage that is shared
825 // between other features.
826 LOG_EWK_API_MOCKUP("Not Supported by chromium");
829 Eina_Bool ewk_view_text_find(Evas_Object *view, const char *text, Ewk_Find_Options options, unsigned int max_match_count)
831 // FIXME: We need to implement next options in Ewk_Find_Options struct. (refer to ewk_view.h)
832 // - EWK_FIND_OPTIONS_AT_WORD_STARTS
833 // - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
834 // - EWK_FIND_OPTIONS_WRAP_AROUND
835 // - EWK_FIND_OPTIONS_SHOW_OVERLAY
836 // - EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR
837 // - EWK_FIND_OPTIONS_SHOW_HIGHLIGHT (Currently there is no way to control this option. so it is always set)
839 // FIXME: Updating of max_match_count is not implemented.
841 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
842 EINA_SAFETY_ON_NULL_RETURN_VAL(text, EINA_FALSE);
843 impl->Find(text, options);
847 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *view)
849 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
854 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
856 // According to chromium source code:
857 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
858 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
859 // This API is impossible to implement right now
860 LOG_EWK_API_MOCKUP("Not Supported by chromium");
863 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
865 // According to chromium source code:
866 // src/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp line 67
867 // Chromium does not allow users to manually change the quota for an origin (for now, at least).
868 // This API is impossible to implement right now
869 LOG_EWK_API_MOCKUP("Not Supported by chromium");
872 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
874 LOG_EWK_API_MOCKUP();
877 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
879 LOG_EWK_API_MOCKUP();
882 void ewk_view_intercept_request_callback_set (Evas_Object* ewkView, Ewk_View_Intercept_Request_Callback callback, void* user_data)
884 LOG_EWK_API_MOCKUP();
887 void ewk_view_unfocus_allow_callback_set(Evas_Object* ewkView, Ewk_View_Unfocus_Allow_Callback callback, void* user_data)
889 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
890 impl->SetViewUnfocusAllowCallback(callback, user_data);
893 void ewk_view_geolocation_permission_callback_set(Evas_Object* ewk_view, Ewk_View_Geolocation_Permission_Callback callback, void* user_data)
895 EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
896 impl->SetViewGeolocationPermissionCallback(callback, user_data);
899 void ewk_view_use_settings_font(Evas_Object* ewkView)
901 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
902 impl->UseSettingsFont();
905 char* ewk_view_get_cookies_for_url(Evas_Object* view, const char* url)
907 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, 0);
908 EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
909 std::string cookiesForURL;
910 cookiesForURL = impl->GetWebContext()->cookieManager()->GetCookiesForURL(std::string(url));
911 if (cookiesForURL.empty())
913 return strndup(cookiesForURL.c_str(), cookiesForURL.length());
916 Eina_Bool ewk_view_fullscreen_exit(Evas_Object* view)
918 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
919 impl->ExitFullscreen();
923 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *view, Eina_Bool enabled)
925 EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
926 impl->SetDrawsTransparentBackground(enabled);
930 void ewk_view_browser_font_set(Evas_Object* ewkView)
932 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
933 impl->SetBrowserFont();
936 void ewk_view_session_data_get(Evas_Object* ewkView, const char** data, unsigned* length)
938 EINA_SAFETY_ON_NULL_RETURN(data);
939 EINA_SAFETY_ON_NULL_RETURN(length);
941 WebView* impl = GetWebViewFromEvasObject(ewkView);
948 impl->GetSessionData(data, length);
951 Eina_Bool ewk_view_mode_set(Evas_Object* ewkView, Ewk_View_Mode view_mode)
953 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
955 if (view_mode == EWK_VIEW_MODE_WINDOWED) {
956 impl->SetViewMode(blink::WebViewModeWindowed);
958 } else if (view_mode == EWK_VIEW_MODE_FULLSCREEN) {
959 impl->SetViewMode(blink::WebViewModeFullscreen);
966 Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const Eina_Bool enabled)
968 LOG_EWK_API_MOCKUP("for browser");
972 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
974 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
975 return impl->GetBackForwardList();
978 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
980 EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
981 impl->SetNotificationPermissionCallback(callback, user_data);
984 void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
986 #if defined(OS_TIZEN_TV) && !defined(EWK_BRINGUP)
987 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
988 impl->setDrawFocusRing(enable);
990 LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
994 #if defined(OS_TIZEN_TV)
995 double ewk_view_page_zoom_get(const Evas_Object* ewkView)
997 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1001 Eina_Bool ewk_view_page_zoom_set(Evas_Object* ewkView, double zoomFactor)
1003 LOG_EWK_API_MOCKUP("for Tizen TV Browser");
1007 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
1009 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1010 return CreateWebViewAsEvasObject(context, canvas, smart);
1012 #endif // OS_TIZEN_TV
1014 #if !defined(EWK_BRINGUP)
1015 void ewk_view_quota_permission_request_callback_set(Evas_Object* ewkView, Ewk_Quota_Permission_Request_Callback callback, void* user_data)
1017 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1018 impl->SetQuotaPermissionRequestCallback((tizen_webview::QuotaPermissionRequest_Cb)callback, user_data);
1021 void ewk_view_quota_permission_request_reply(const Ewk_Quota_Permission_Request* request, const Eina_Bool allow)
1023 EINA_SAFETY_ON_NULL_RETURN(request);
1024 Evas_Object* ewkView = request->getView();
1025 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1026 impl->QuotaRequestReply(request, allow == EINA_TRUE);
1029 void ewk_view_quota_permission_request_cancel(const Ewk_Quota_Permission_Request* request)
1031 EINA_SAFETY_ON_NULL_RETURN(request);
1032 Evas_Object* ewkView = request->getView();
1033 EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
1034 impl->QuotaRequestCancel(request);