diff --git a/packages/webview_flutter/CHANGELOG.md b/packages/webview_flutter/CHANGELOG.md index d3720af7f..74b93b9f9 100644 --- a/packages/webview_flutter/CHANGELOG.md +++ b/packages/webview_flutter/CHANGELOG.md @@ -2,6 +2,7 @@ * Omit obvious local variable types. * Reformat with a line length of 100. +* Use wrapper API. ## 0.11.0 diff --git a/packages/webview_flutter/tizen/inc/ftpw_webview_flutter.h b/packages/webview_flutter/tizen/inc/ftpw_webview_flutter.h new file mode 100644 index 000000000..5f5649149 --- /dev/null +++ b/packages/webview_flutter/tizen/inc/ftpw_webview_flutter.h @@ -0,0 +1,287 @@ +// Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef FLUTTER_TIZEN_PLUGINS_WRAPPER_WEBVIEW_FLUTTER_H_ +#define FLUTTER_TIZEN_PLUGINS_WRAPPER_WEBVIEW_FLUTTER_H_ + +#include + +typedef enum { + EWK_TOUCH_START, + EWK_TOUCH_MOVE, + EWK_TOUCH_END, +} Ewk_Touch_Event_Type; + +typedef struct _Ewk_Touch_Point Ewk_Touch_Point; + +typedef enum { + EWK_MOUSE_BUTTON_LEFT = 1, + EWK_MOUSE_BUTTON_MIDDLE = 2, + EWK_MOUSE_BUTTON_RIGHT = 3 +} Ewk_Mouse_Button_Type; + +struct _Ewk_Touch_Point { + int id; + int x; + int y; + int state; +}; + +typedef unsigned char (*Ewk_View_JavaScript_Alert_Callback)( + void *o, const char *alert_text, void *user_data); +typedef unsigned char (*Ewk_View_JavaScript_Confirm_Callback)( + void *o, const char *message, void *user_data); +typedef unsigned char (*Ewk_View_JavaScript_Prompt_Callback)( + void *o, const char *message, const char *default_value, void *user_data); + +typedef enum { + EWK_CONSOLE_MESSAGE_LEVEL_NULL, + EWK_CONSOLE_MESSAGE_LEVEL_LOG, + EWK_CONSOLE_MESSAGE_LEVEL_WARNING, + EWK_CONSOLE_MESSAGE_LEVEL_ERROR, + EWK_CONSOLE_MESSAGE_LEVEL_DEBUG, + EWK_CONSOLE_MESSAGE_LEVEL_INFO, +} Ewk_Console_Message_Level; + +typedef enum { + WV_HTTP_METHOD_GET, + WV_HTTP_METHOD_POST = 2, +} wv_http_method_e; + +typedef enum { + WV_TOUCH_EVENT_START, + WV_TOUCH_EVENT_MOVE, + WV_TOUCH_EVENT_END, +} wv_touch_event_type_e; + +typedef enum { + WV_TOUCH_POINT_STATE_DOWN, + WV_TOUCH_POINT_STATE_UP, + WV_TOUCH_POINT_STATE_MOVE, +} wv_touch_point_state_e; + +typedef enum { + WV_MODIFIER_NONE = 0, + WV_MODIFIER_SHIFT = 1 << 0, + WV_MODIFIER_CONTROL = 1 << 1, + WV_MODIFIER_ALT = 1 << 2, + WV_MODIFIER_SUPER = 1 << 3, + WV_MODIFIER_HYPER = 1 << 4, + WV_MODIFIER_CAPS_LOCK = 1 << 5, + WV_MODIFIER_NUM_LOCK = 1 << 6 +} wv_modifier_e; + +typedef enum { + WV_MOUSE_BUTTON_LEFT = 1, + WV_MOUSE_BUTTON_MIDDLE = 2, + WV_MOUSE_BUTTON_RIGHT = 3 +} wv_mouse_button_type_e; + +typedef enum { + WV_CONSOLE_MESSAGE_LEVEL_NULL, + WV_CONSOLE_MESSAGE_LEVEL_LOG, + WV_CONSOLE_MESSAGE_LEVEL_WARNING, + WV_CONSOLE_MESSAGE_LEVEL_ERROR, + WV_CONSOLE_MESSAGE_LEVEL_DEBUG, + WV_CONSOLE_MESSAGE_LEVEL_INFO +} wv_console_message_level_e; + +typedef struct { + int id; + int x; + int y; + wv_touch_point_state_e state; +} wv_touch_point_s; + +typedef struct { + const char *key_name; + const char *key; + const char *string; + const char *compose; + unsigned int timestamp; + wv_modifier_e modifiers; + int event_flags; + unsigned int key_code; +} wv_key_event_s; + +typedef struct { + const char *name; + void *body; +} wv_script_message_s; + +typedef void (*wv_view_cb)(void *obj, void *event_info, void *user_data); +typedef void (*wv_view_script_execute_cb)(void *view, const char *result_value, + void *user_data); +typedef void (*wv_view_script_message_cb)(void *view, + wv_script_message_s message); +typedef bool (*wv_view_javascript_alert_cb)(void *view, const char *alert_text, + void *user_data); +typedef bool (*wv_view_javascript_confirm_cb)(void *view, const char *message, + void *user_data); +typedef bool (*wv_view_javascript_prompt_cb)(void *view, const char *message, + const char *default_value, + void *user_data); + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char ftpw_webview_flutter_ewk_view_bg_color_set(void *obj, int r, + int g, int b, int a); +unsigned char ftpw_webview_flutter_ewk_view_touch_events_enabled_set( + void *view, unsigned char enabled); +unsigned char ftpw_webview_flutter_ewk_view_feed_touch_event( + void *obj, Ewk_Touch_Event_Type type, const void *points, + const void *modifiers); +unsigned char ftpw_webview_flutter_ewk_view_mouse_events_enabled_set( + void *view, unsigned char enabled); +unsigned char ftpw_webview_flutter_ewk_view_feed_mouse_down( + void *obj, Ewk_Mouse_Button_Type button, int x, int y); +unsigned char ftpw_webview_flutter_ewk_view_feed_mouse_up( + void *obj, Ewk_Mouse_Button_Type button, int x, int y); +unsigned char ftpw_webview_flutter_ewk_view_feed_mouse_wheel( + void *obj, unsigned char y_direction, int step, int x, int y); +unsigned char ftpw_webview_flutter_ewk_view_send_key_event( + void *obj, void *key_event, unsigned char is_press); +void ftpw_webview_flutter_ewk_view_offscreen_rendering_enabled_set( + void *obj, unsigned char enabled); +void ftpw_webview_flutter_ewk_view_ime_window_set(void *obj, void *window); +unsigned char ftpw_webview_flutter_ewk_view_key_events_enabled_set( + void *obj, unsigned char enabled); +unsigned char ftpw_webview_flutter_ewk_view_set_support_video_hole( + void *obj, void *window, unsigned char enabled, unsigned char boo); +void ftpw_webview_flutter_ewk_view_javascript_alert_callback_set( + void *o, Ewk_View_JavaScript_Alert_Callback callback, void *user_data); +void ftpw_webview_flutter_ewk_view_javascript_confirm_callback_set( + void *o, Ewk_View_JavaScript_Confirm_Callback callback, void *user_data); +void ftpw_webview_flutter_ewk_view_javascript_prompt_callback_set( + void *o, Ewk_View_JavaScript_Prompt_Callback callback, void *user_data); +void ftpw_webview_flutter_ewk_view_javascript_alert_reply(void *o); +void ftpw_webview_flutter_ewk_view_javascript_confirm_reply( + void *o, unsigned char result); +void ftpw_webview_flutter_ewk_view_javascript_prompt_reply(void *o, + const char *result); +unsigned char ftpw_webview_flutter_ewk_view_main_frame_scrollbar_visible_set( + void *obj, unsigned char enabled); +void ftpw_webview_flutter_ewk_set_arguments(int argc, char **argv); +int ftpw_webview_flutter_ewk_set_version_policy(int preference); +void ftpw_webview_flutter_ewk_settings_ime_panel_enabled_set( + void *settings, unsigned char enabled); +void ftpw_webview_flutter_ewk_settings_force_zoom_set(void *settings, + unsigned char enable); +Ewk_Console_Message_Level ftpw_webview_flutter_ewk_console_message_level_get( + const void *message); +const char *ftpw_webview_flutter_ewk_console_message_text_get( + const void *message); +int ftpw_webview_flutter_wv_init(void); +int ftpw_webview_flutter_wv_shutdown(void); +int ftpw_webview_flutter_wv_set_arguments(int argc, const char **argv); +void *ftpw_webview_flutter_wv_view_create(void); +void ftpw_webview_flutter_wv_view_destroy(void *view); +void ftpw_webview_flutter_wv_view_resize(void *view, int w, int h); +bool ftpw_webview_flutter_wv_view_focus_set(void *view, int focused); +bool ftpw_webview_flutter_wv_view_url_set(void *view, const char *url); +const char *ftpw_webview_flutter_wv_view_url_get(void *view); +bool ftpw_webview_flutter_wv_view_url_request_set(void *view, const char *url, + wv_http_method_e method, + void *headers, + const char *body); +bool ftpw_webview_flutter_wv_view_html_string_load(void *view, const char *html, + const char *base_url, + const char *unreachable_url); +bool ftpw_webview_flutter_wv_view_back_possible(void *view); +bool ftpw_webview_flutter_wv_view_forward_possible(void *view); +bool ftpw_webview_flutter_wv_view_back(void *view); +bool ftpw_webview_flutter_wv_view_forward(void *view); +bool ftpw_webview_flutter_wv_view_reload(void *view); +bool ftpw_webview_flutter_wv_view_stop(void *view); +void ftpw_webview_flutter_wv_view_suspend(void *view); +void ftpw_webview_flutter_wv_view_resume(void *view); +const char *ftpw_webview_flutter_wv_view_title_get(void *view); +bool ftpw_webview_flutter_wv_view_user_agent_set(void *view, + const char *user_agent); +const char *ftpw_webview_flutter_wv_view_user_agent_get(void *view); +bool ftpw_webview_flutter_wv_view_scroll_set(void *view, int x, int y); +void ftpw_webview_flutter_wv_view_scroll_by(void *view, int dx, int dy); +bool ftpw_webview_flutter_wv_view_scroll_pos_get(void *view, int *x, int *y); +bool ftpw_webview_flutter_wv_view_script_execute( + void *view, const char *script, wv_view_script_execute_cb callback, + void *user_data); +bool ftpw_webview_flutter_wv_view_bg_color_set(void *view, int r, int g, int b, + int a); +void *ftpw_webview_flutter_wv_view_context_get(void *view); +void *ftpw_webview_flutter_wv_view_settings_get(void *view); +int ftpw_webview_flutter_wv_view_feed_touch_event( + void *view, wv_touch_event_type_e event_type, void *points, + wv_modifier_e modifiers); +int ftpw_webview_flutter_wv_view_feed_mouse_down(void *view, + wv_mouse_button_type_e button, + int x, int y); +int ftpw_webview_flutter_wv_view_feed_mouse_up(void *view, + wv_mouse_button_type_e button, + int x, int y); +int ftpw_webview_flutter_wv_view_feed_mouse_wheel(void *view, bool y_direction, + int step, int x, int y); +int ftpw_webview_flutter_wv_view_send_key_event(void *view, + const wv_key_event_s *key_event, + int is_press); +int ftpw_webview_flutter_wv_view_touch_events_enabled_set(void *view, + int enabled); +bool ftpw_webview_flutter_wv_view_mouse_events_enabled_set(void *view, + bool enabled); +bool ftpw_webview_flutter_wv_view_key_events_enabled_set(void *view, + bool enabled); +void ftpw_webview_flutter_wv_view_ime_window_set(void *view, void *window); +int ftpw_webview_flutter_wv_view_add_cb(void *view, const char *event, + wv_view_cb func, const void *user_data); +int ftpw_webview_flutter_wv_view_remove_full_cb(void *view, const char *event, + wv_view_cb func, + const void *user_data); +int ftpw_webview_flutter_wv_view_javascript_alert_callback_set( + void *view, wv_view_javascript_alert_cb callback, void *user_data); +int ftpw_webview_flutter_wv_view_javascript_confirm_callback_set( + void *view, wv_view_javascript_confirm_cb callback, void *user_data); +int ftpw_webview_flutter_wv_view_javascript_prompt_callback_set( + void *view, wv_view_javascript_prompt_cb callback, void *user_data); +void ftpw_webview_flutter_wv_view_javascript_alert_reply(void *view); +void ftpw_webview_flutter_wv_view_javascript_confirm_reply(void *view, + bool result); +void ftpw_webview_flutter_wv_view_javascript_prompt_reply(void *view, + const char *result); +bool ftpw_webview_flutter_wv_view_javascript_message_handler_add( + void *view, wv_view_script_message_cb callback, const char *name); +bool ftpw_webview_flutter_wv_view_set_support_video_hole(void *view, + void *window, + bool enable, + bool is_video_window); +bool ftpw_webview_flutter_wv_view_main_frame_scrollbar_visible_set( + void *view, bool visible); +void *ftpw_webview_flutter_wv_context_cookie_manager_get(void *context); +int ftpw_webview_flutter_wv_context_cache_model_set(void *context); +int ftpw_webview_flutter_wv_context_web_storage_delete_all(void *context); +int ftpw_webview_flutter_wv_context_cache_clear(void *context); +int ftpw_webview_flutter_wv_cookie_manager_accept_policy_set(void *manager); +int ftpw_webview_flutter_wv_cookie_manager_cookies_clear(void *manager); +bool ftpw_webview_flutter_wv_settings_javascript_enabled_set(void *settings, + bool enable); +void ftpw_webview_flutter_wv_settings_ime_panel_enabled_set(void *settings, + bool enable); +bool ftpw_webview_flutter_wv_settings_force_zoom_set(void *settings, + bool enable); +int ftpw_webview_flutter_wv_error_code_get(void *error); +const char *ftpw_webview_flutter_wv_error_description_get(void *error); +const char *ftpw_webview_flutter_wv_error_url_get(void *error); +int ftpw_webview_flutter_wv_policy_decision_use(void *policy_decision); +const char *ftpw_webview_flutter_wv_policy_decision_url_get( + void *policy_decision); +int ftpw_webview_flutter_wv_policy_decision_response_status_code_get( + void *policy_decision); +wv_console_message_level_e ftpw_webview_flutter_wv_console_message_level_get( + void *message); +const char *ftpw_webview_flutter_wv_console_message_text_get(void *message); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packages/webview_flutter/tizen/lib/aarch64/libftpw_webview_flutter.so b/packages/webview_flutter/tizen/lib/aarch64/libftpw_webview_flutter.so new file mode 100755 index 000000000..d034714a9 Binary files /dev/null and b/packages/webview_flutter/tizen/lib/aarch64/libftpw_webview_flutter.so differ diff --git a/packages/webview_flutter/tizen/lib/armel/libftpw_webview_flutter.so b/packages/webview_flutter/tizen/lib/armel/libftpw_webview_flutter.so new file mode 100755 index 000000000..2b4827a9d Binary files /dev/null and b/packages/webview_flutter/tizen/lib/armel/libftpw_webview_flutter.so differ diff --git a/packages/webview_flutter/tizen/lib/i586/libftpw_webview_flutter.so b/packages/webview_flutter/tizen/lib/i586/libftpw_webview_flutter.so new file mode 100755 index 000000000..333851e0d Binary files /dev/null and b/packages/webview_flutter/tizen/lib/i586/libftpw_webview_flutter.so differ diff --git a/packages/webview_flutter/tizen/lib/x86_64/libftpw_webview_flutter.so b/packages/webview_flutter/tizen/lib/x86_64/libftpw_webview_flutter.so new file mode 100755 index 000000000..8f4fe2ec3 Binary files /dev/null and b/packages/webview_flutter/tizen/lib/x86_64/libftpw_webview_flutter.so differ diff --git a/packages/webview_flutter/tizen/project_def.prop b/packages/webview_flutter/tizen/project_def.prop index ab6475aa6..517d59e7d 100644 --- a/packages/webview_flutter/tizen/project_def.prop +++ b/packages/webview_flutter/tizen/project_def.prop @@ -18,3 +18,7 @@ USER_CPP_UNDEFS = USER_INC_DIRS = inc src USER_INC_FILES = USER_CPP_INC_FILES = + +# User libraries +USER_LIB_DIRS += lib/${BUILD_ARCH} +USER_LIBS += ftpw_webview_flutter diff --git a/packages/webview_flutter/tizen/src/ewk_internal_api_binding.cc b/packages/webview_flutter/tizen/src/ewk_internal_api_binding.cc deleted file mode 100644 index 74768ed9f..000000000 --- a/packages/webview_flutter/tizen/src/ewk_internal_api_binding.cc +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ewk_internal_api_binding.h" - -#include - -EwkInternalApiBinding::EwkInternalApiBinding() { - handle_ = dlopen("libchromium-ewk.so", RTLD_LAZY); -} - -EwkInternalApiBinding::~EwkInternalApiBinding() { - if (handle_) { - dlclose(handle_); - } -} - -bool EwkInternalApiBinding::Initialize() { - if (initialize_result_.has_value()) { - return *initialize_result_; - } - - if (!handle_) { - initialize_result_ = false; - return false; - } - - // ewk_view - view.BgColorSet = reinterpret_cast( - dlsym(handle_, "ewk_view_bg_color_set")); - view.TouchEventsEnabledSet = - reinterpret_cast( - dlsym(handle_, "ewk_view_touch_events_enabled_set")); - view.FeedTouchEvent = reinterpret_cast( - dlsym(handle_, "ewk_view_feed_touch_event")); - view.MouseEventsEnabledSet = - reinterpret_cast( - dlsym(handle_, "ewk_view_mouse_events_enabled_set")); - view.FeedMouseDown = reinterpret_cast( - dlsym(handle_, "ewk_view_feed_mouse_down")); - view.FeedMouseUp = reinterpret_cast( - dlsym(handle_, "ewk_view_feed_mouse_up")); - view.FeedMouseMove = reinterpret_cast( - dlsym(handle_, "ewk_view_feed_mouse_move")); - view.FeedMouseWheel = reinterpret_cast( - dlsym(handle_, "ewk_view_feed_mouse_wheel")); - view.SendKeyEvent = reinterpret_cast( - dlsym(handle_, "ewk_view_send_key_event")); - view.OffscreenRenderingEnabledSet = - reinterpret_cast( - dlsym(handle_, "ewk_view_offscreen_rendering_enabled_set")); - view.ImeWindowSet = reinterpret_cast( - dlsym(handle_, "ewk_view_ime_window_set")); - view.KeyEventsEnabledSet = reinterpret_cast( - dlsym(handle_, "ewk_view_key_events_enabled_set")); - view.SetSupportVideoHole = reinterpret_cast( - dlsym(handle_, "ewk_view_set_support_video_hole")); - - view.OnJavaScriptAlert = - reinterpret_cast( - dlsym(handle_, "ewk_view_javascript_alert_callback_set")); - view.OnJavaScriptConfirm = - reinterpret_cast( - dlsym(handle_, "ewk_view_javascript_confirm_callback_set")); - view.OnJavaScriptPrompt = - reinterpret_cast( - dlsym(handle_, "ewk_view_javascript_prompt_callback_set")); - - view.JavaScriptAlertReply = - reinterpret_cast( - dlsym(handle_, "ewk_view_javascript_alert_reply")); - view.JavaScriptConfirmReply = - reinterpret_cast( - dlsym(handle_, "ewk_view_javascript_confirm_reply")); - view.JavaScriptPromptReply = - reinterpret_cast( - dlsym(handle_, "ewk_view_javascript_prompt_reply")); - - view.MainFrameScrollbarVisibleSet = - reinterpret_cast( - dlsym(handle_, "ewk_view_main_frame_scrollbar_visible_set")); - - // ewk_main - main.SetArguments = reinterpret_cast( - dlsym(handle_, "ewk_set_arguments")); - - main.SetVersionPolicy = reinterpret_cast( - dlsym(handle_, "ewk_set_version_policy")); - - // ewk_settings - settings.ImePanelEnabledSet = - reinterpret_cast( - dlsym(handle_, "ewk_settings_ime_panel_enabled_set")); - settings.ForceZoomSet = reinterpret_cast( - dlsym(handle_, "ewk_settings_force_zoom_set")); - - // ewk_console_message - console_message.LevelGet = reinterpret_cast( - dlsym(handle_, "ewk_console_message_level_get")); - console_message.TextGet = reinterpret_cast( - dlsym(handle_, "ewk_console_message_text_get")); - console_message.LineGet = reinterpret_cast( - dlsym(handle_, "ewk_console_message_line_get")); - console_message.SourceGet = reinterpret_cast( - dlsym(handle_, "ewk_console_message_source_get")); - - initialize_result_ = - view.BgColorSet && view.TouchEventsEnabledSet && view.FeedTouchEvent && - view.MouseEventsEnabledSet && view.FeedMouseDown && view.FeedMouseUp && - view.FeedMouseMove && view.FeedMouseWheel && view.SendKeyEvent && - view.OffscreenRenderingEnabledSet && view.ImeWindowSet && - view.KeyEventsEnabledSet && view.SetSupportVideoHole && - view.OnJavaScriptAlert && view.OnJavaScriptConfirm && - view.OnJavaScriptPrompt && view.JavaScriptAlertReply && - view.JavaScriptConfirmReply && view.JavaScriptPromptReply && - view.MainFrameScrollbarVisibleSet && main.SetArguments && - main.SetVersionPolicy && settings.ImePanelEnabledSet && - settings.ForceZoomSet && console_message.LevelGet && - console_message.TextGet && console_message.LineGet && - console_message.SourceGet; - return *initialize_result_; -} diff --git a/packages/webview_flutter/tizen/src/ewk_internal_api_binding.h b/packages/webview_flutter/tizen/src/ewk_internal_api_binding.h deleted file mode 100644 index 37b02f15f..000000000 --- a/packages/webview_flutter/tizen/src/ewk_internal_api_binding.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_PLUGIN_EWK_INTERNAL_API_BINDING_H_ -#define FLUTTER_PLUGIN_EWK_INTERNAL_API_BINDING_H_ - -#include - -#include - -typedef enum { - EWK_TOUCH_START, - EWK_TOUCH_MOVE, - EWK_TOUCH_END, - EWK_TOUCH_CANCEL -} Ewk_Touch_Event_Type; - -typedef struct _Ewk_Touch_Point Ewk_Touch_Point; - -typedef enum { - EWK_MOUSE_BUTTON_LEFT = 1, - EWK_MOUSE_BUTTON_MIDDLE = 2, - EWK_MOUSE_BUTTON_RIGHT = 3 -} Ewk_Mouse_Button_Type; - -struct _Ewk_Touch_Point { - int id; - int x; - int y; - Evas_Touch_Point_State state; -}; - -typedef Eina_Bool (*Ewk_View_JavaScript_Alert_Callback)(Evas_Object* o, - const char* alert_text, - void* user_data); -typedef Eina_Bool (*Ewk_View_JavaScript_Confirm_Callback)(Evas_Object* o, - const char* message, - void* user_data); -typedef Eina_Bool (*Ewk_View_JavaScript_Prompt_Callback)( - Evas_Object* o, const char* message, const char* default_value, - void* user_data); -typedef void (*Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback)( - Evas_Object* o, Eina_Bool visible, void* user_data); - -typedef Eina_Bool (*EwkViewBgColorSetFnPtr)(Evas_Object* obj, int r, int g, - int b, int a); -typedef Eina_Bool (*EwkViewTouchEventsEnabledSetFnPtr)(Evas_Object* view, - Eina_Bool enabled); -typedef Eina_Bool (*EwkViewFeedTouchEventFnPtr)(Evas_Object* obj, - Ewk_Touch_Event_Type type, - const Eina_List* points, - const Evas_Modifier* modifiers); -typedef Eina_Bool (*EwkViewMouseEventsEnabledSetFnPtr)(Evas_Object* view, - Eina_Bool enabled); -typedef Eina_Bool (*EwkViewFeedMouseDownFnPtr)(Evas_Object* obj, - Ewk_Mouse_Button_Type button, - int x, int y); -typedef Eina_Bool (*EwkViewFeedMouseUpFnPtr)(Evas_Object* obj, - Ewk_Mouse_Button_Type button, - int x, int y); -typedef Eina_Bool (*EwkViewFeedMouseMoveFnPtr)(Evas_Object* obj, int x, int y); -typedef Eina_Bool (*EwkViewFeedMouseWheelFnPtr)(Evas_Object* obj, - Eina_Bool y_direction, int step, - int x, int y); -typedef Eina_Bool (*EwkViewSendKeyEventFnPtr)(Evas_Object* obj, void* key_event, - Eina_Bool is_press); -typedef void (*EwkViewOffscreenRenderingEnabledSetFnPtr)(Evas_Object* obj, - Eina_Bool enabled); -typedef void (*EwkViewImeWindowSetFnPtr)(Evas_Object* obj, void* window); -typedef Eina_Bool (*EwkViewKeyEventsEnabledSetFnPtr)(Evas_Object* obj, - Eina_Bool enabled); -typedef Eina_Bool (*EwkViewSetSupportVideoHoleFnPtr)(Evas_Object* obj, - void* window, - Eina_Bool enabled, - Eina_Bool boo); -typedef void (*EwkViewJavaScriptAlertCallbackSetFnPtr)( - Evas_Object* o, Ewk_View_JavaScript_Alert_Callback callback, - void* user_data); -typedef void (*EwkViewJavaScriptConfirmCallbackSetFnPtr)( - Evas_Object* o, Ewk_View_JavaScript_Confirm_Callback callback, - void* user_data); -typedef void (*EwkViewJavaScriptPromptCallbackSetFnPtr)( - Evas_Object* o, Ewk_View_JavaScript_Prompt_Callback callback, - void* user_data); -typedef void (*EwkViewJavaScriptAlertReplyFnPtr)(Evas_Object* o); -typedef void (*EwkViewJavaScriptConfirmReplyFnPtr)(Evas_Object* o, - Eina_Bool result); -typedef void (*EwkViewJavaScriptPromptReplyFnPtr)(Evas_Object* o, - const char* result); -typedef Eina_Bool (*EwkViewMainFrameScrollbarVisibleSetFnPtr)( - Evas_Object* obj, Eina_Bool enabled); - -typedef struct { - EwkViewBgColorSetFnPtr BgColorSet = nullptr; - EwkViewTouchEventsEnabledSetFnPtr TouchEventsEnabledSet = nullptr; - EwkViewFeedTouchEventFnPtr FeedTouchEvent = nullptr; - EwkViewMouseEventsEnabledSetFnPtr MouseEventsEnabledSet = nullptr; - EwkViewFeedMouseDownFnPtr FeedMouseDown = nullptr; - EwkViewFeedMouseUpFnPtr FeedMouseUp = nullptr; - EwkViewFeedMouseMoveFnPtr FeedMouseMove = nullptr; - EwkViewFeedMouseWheelFnPtr FeedMouseWheel = nullptr; - EwkViewSendKeyEventFnPtr SendKeyEvent = nullptr; - EwkViewOffscreenRenderingEnabledSetFnPtr OffscreenRenderingEnabledSet = - nullptr; - EwkViewImeWindowSetFnPtr ImeWindowSet = nullptr; - EwkViewKeyEventsEnabledSetFnPtr KeyEventsEnabledSet = nullptr; - EwkViewSetSupportVideoHoleFnPtr SetSupportVideoHole = nullptr; - EwkViewJavaScriptAlertCallbackSetFnPtr OnJavaScriptAlert = nullptr; - EwkViewJavaScriptConfirmCallbackSetFnPtr OnJavaScriptConfirm = nullptr; - EwkViewJavaScriptPromptCallbackSetFnPtr OnJavaScriptPrompt = nullptr; - EwkViewJavaScriptAlertReplyFnPtr JavaScriptAlertReply = nullptr; - EwkViewJavaScriptConfirmReplyFnPtr JavaScriptConfirmReply = nullptr; - EwkViewJavaScriptPromptReplyFnPtr JavaScriptPromptReply = nullptr; - EwkViewMainFrameScrollbarVisibleSetFnPtr MainFrameScrollbarVisibleSet = - nullptr; -} EwkViewProcTable; - -typedef void (*EwkSetArgumentsFnPtr)(int argc, char** argv); -typedef int (*EwkSetVersionPolicyFnPtr)(int preference); - -typedef struct { - EwkSetArgumentsFnPtr SetArguments = nullptr; - EwkSetVersionPolicyFnPtr SetVersionPolicy = nullptr; -} EwkMainProcTable; - -typedef struct Ewk_Settings Ewk_Settings; -typedef void (*EwkSettingsImePanelEnabledSetFnPtr)(Ewk_Settings* settings, - Eina_Bool enabled); -typedef void (*EwkSettingsForceZoomSetFnPtr)(Ewk_Settings* settings, - Eina_Bool enable); - -typedef struct { - EwkSettingsImePanelEnabledSetFnPtr ImePanelEnabledSet = nullptr; - EwkSettingsForceZoomSetFnPtr ForceZoomSet = nullptr; -} EwkSettingsProcTable; - -typedef struct _Ewk_Console_Message Ewk_Console_Message; - -typedef enum { - EWK_CONSOLE_MESSAGE_LEVEL_NULL, - EWK_CONSOLE_MESSAGE_LEVEL_LOG, - EWK_CONSOLE_MESSAGE_LEVEL_WARNING, - EWK_CONSOLE_MESSAGE_LEVEL_ERROR, - EWK_CONSOLE_MESSAGE_LEVEL_DEBUG, - EWK_CONSOLE_MESSAGE_LEVEL_INFO, -} Ewk_Console_Message_Level; - -typedef Ewk_Console_Message_Level (*EwkConsoleMessageLevelGetFnPtr)( - const Ewk_Console_Message* message); -typedef Eina_Stringshare* (*EwkConsoleMessageTextGetFnPtr)( - const Ewk_Console_Message* message); -typedef unsigned (*EwkConsoleMessageLineGetFnPtr)( - const Ewk_Console_Message* message); -typedef Eina_Stringshare* (*EwkConsoleMessageSourceGetFnPtr)( - const Ewk_Console_Message* message); - -typedef struct { - EwkConsoleMessageLevelGetFnPtr LevelGet = nullptr; - EwkConsoleMessageTextGetFnPtr TextGet = nullptr; - EwkConsoleMessageLineGetFnPtr LineGet = nullptr; - EwkConsoleMessageSourceGetFnPtr SourceGet = nullptr; -} EwkConsoleMessageProcTable; - -class EwkInternalApiBinding { - public: - static EwkInternalApiBinding& GetInstance() { - static EwkInternalApiBinding instance = EwkInternalApiBinding(); - return instance; - } - - ~EwkInternalApiBinding(); - - EwkInternalApiBinding(const EwkInternalApiBinding&) = delete; - EwkInternalApiBinding& operator=(const EwkInternalApiBinding&) = delete; - - // Resolves every symbol, and returns true only if all of them were found. - // Safe to call more than once — the first result is cached. - bool Initialize(); - - EwkViewProcTable view; - EwkMainProcTable main; - EwkSettingsProcTable settings; - EwkConsoleMessageProcTable console_message; - - private: - EwkInternalApiBinding(); - - void* handle_ = nullptr; - std::optional initialize_result_; -}; - -#endif // FLUTTER_PLUGIN_EWK_INTERNAL_API_BINDING_H_ diff --git a/packages/webview_flutter/tizen/src/ewk_webview_backend.cc b/packages/webview_flutter/tizen/src/ewk_webview_backend.cc index 95c825740..ce782641a 100644 --- a/packages/webview_flutter/tizen/src/ewk_webview_backend.cc +++ b/packages/webview_flutter/tizen/src/ewk_webview_backend.cc @@ -96,7 +96,7 @@ bool EwkWebViewBackend::Create(double width, double height, void* window, if (engine_policy) { LOG_INFO("Upgrade web engine used."); - EwkInternalApiBinding::GetInstance().main.SetVersionPolicy(1); + ftpw_webview_flutter_ewk_set_version_policy(1); } char* chromium_argv[] = { @@ -106,8 +106,7 @@ bool EwkWebViewBackend::Create(double width, double height, void* window, const_cast("--no-zygote"), }; int chromium_argc = sizeof(chromium_argv) / sizeof(chromium_argv[0]); - EwkInternalApiBinding::GetInstance().main.SetArguments(chromium_argc, - chromium_argv); + ftpw_webview_flutter_ewk_set_arguments(chromium_argc, chromium_argv); Ecore_Evas* evas = GetOffscreenHost(); if (!evas) { @@ -120,8 +119,7 @@ bool EwkWebViewBackend::Create(double width, double height, void* window, } ecore_evas_focus_set(evas, true); ewk_view_focus_set(view_, true); - EwkInternalApiBinding::GetInstance().view.OffscreenRenderingEnabledSet(view_, - true); + ftpw_webview_flutter_ewk_view_offscreen_rendering_enabled_set(view_, true); Ewk_Context* context = ewk_view_context_get(view_); Ewk_Cookie_Manager* cookie_manager = ewk_context_cookie_manager_get(context); @@ -131,30 +129,30 @@ bool EwkWebViewBackend::Create(double width, double height, void* window, } ewk_context_cache_model_set(context, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER); - EwkInternalApiBinding::GetInstance().settings.ImePanelEnabledSet( + ftpw_webview_flutter_ewk_settings_ime_panel_enabled_set( ewk_view_settings_get(view_), true); - EwkInternalApiBinding::GetInstance().settings.ForceZoomSet( - ewk_view_settings_get(view_), true); - EwkInternalApiBinding::GetInstance().view.ImeWindowSet(view_, window_); - EwkInternalApiBinding::GetInstance().view.KeyEventsEnabledSet(view_, true); + ftpw_webview_flutter_ewk_settings_force_zoom_set(ewk_view_settings_get(view_), + true); + ftpw_webview_flutter_ewk_view_ime_window_set(view_, window_); + ftpw_webview_flutter_ewk_view_key_events_enabled_set(view_, true); #ifdef WEBVIEW_TIZEN_TOUCH_EVENTS_ENABLED - EwkInternalApiBinding::GetInstance().view.TouchEventsEnabledSet(view_, true); - EwkInternalApiBinding::GetInstance().view.MouseEventsEnabledSet(view_, false); + ftpw_webview_flutter_ewk_view_touch_events_enabled_set(view_, true); + ftpw_webview_flutter_ewk_view_mouse_events_enabled_set(view_, false); #else - EwkInternalApiBinding::GetInstance().view.TouchEventsEnabledSet(view_, false); - EwkInternalApiBinding::GetInstance().view.MouseEventsEnabledSet(view_, true); + ftpw_webview_flutter_ewk_view_touch_events_enabled_set(view_, false); + ftpw_webview_flutter_ewk_view_mouse_events_enabled_set(view_, true); #endif - EwkInternalApiBinding::GetInstance().view.OnJavaScriptAlert( + ftpw_webview_flutter_ewk_view_javascript_alert_callback_set( view_, &EwkWebViewBackend::OnJavaScriptAlertDialog, this); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptConfirm( + ftpw_webview_flutter_ewk_view_javascript_confirm_callback_set( view_, &EwkWebViewBackend::OnJavaScriptConfirmDialog, this); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptPrompt( + ftpw_webview_flutter_ewk_view_javascript_prompt_callback_set( view_, &EwkWebViewBackend::OnJavaScriptPromptDialog, this); #ifdef TV_PROFILE - EwkInternalApiBinding::GetInstance().view.SetSupportVideoHole(view_, window_, - true, false); + ftpw_webview_flutter_ewk_view_set_support_video_hole(view_, window_, true, + false); #endif evas_object_smart_callback_add(view_, "offscreen,frame,rendered", @@ -211,11 +209,11 @@ std::function EwkWebViewBackend::PrepareTeardown( evas_object_smart_callback_del(instance, "url,changed", &EwkWebViewBackend::OnUrlChange); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptAlert( + ftpw_webview_flutter_ewk_view_javascript_alert_callback_set( instance, nullptr, nullptr); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptConfirm( + ftpw_webview_flutter_ewk_view_javascript_confirm_callback_set( instance, nullptr, nullptr); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptPrompt( + ftpw_webview_flutter_ewk_view_javascript_prompt_callback_set( instance, nullptr, nullptr); evas_object_data_del(instance, kEwkInstance); @@ -272,8 +270,8 @@ void EwkWebViewBackend::SendTouchEvent(int event_type, double x, double y) { point->state = state; points = eina_list_append(points, point); - EwkInternalApiBinding::GetInstance().view.FeedTouchEvent( - view_, mouse_event_type, points, 0); + ftpw_webview_flutter_ewk_view_feed_touch_event(view_, mouse_event_type, + points, 0); eina_list_free(points); } @@ -298,16 +296,16 @@ void EwkWebViewBackend::SendMouseEvent(int event_type, int button_type, if (event_type == 0) { mouse_button_type_ = mouse_button_type; - EwkInternalApiBinding::GetInstance().view.FeedMouseDown( - view_, mouse_button_type_, px, py); + ftpw_webview_flutter_ewk_view_feed_mouse_down(view_, mouse_button_type_, px, + py); } else if (event_type == 1) { if (dy != 0) { - EwkInternalApiBinding::GetInstance().view.FeedMouseWheel( - view_, true, dy > 0 ? 1 : -1, px, py); + ftpw_webview_flutter_ewk_view_feed_mouse_wheel(view_, true, + dy > 0 ? 1 : -1, px, py); } } else if (event_type == 2) { - EwkInternalApiBinding::GetInstance().view.FeedMouseUp( - view_, mouse_button_type_, px, py); + ftpw_webview_flutter_ewk_view_feed_mouse_up(view_, mouse_button_type_, px, + py); mouse_button_type_ = mouse_button_type; } else { LOG_WARN("Unknown mouse event type: %d", event_type); @@ -341,16 +339,14 @@ bool EwkWebViewBackend::SendKey(const char* key, const char* string, down_event.string = string; down_event.modifiers = evas_modifiers; down_event.locks = evas_locks; - EwkInternalApiBinding::GetInstance().view.SendKeyEvent(view_, &down_event, - is_down); + ftpw_webview_flutter_ewk_view_send_key_event(view_, &down_event, is_down); } else { Evas_Event_Key_Up up_event = {}; up_event.key = key; up_event.modifiers = evas_modifiers; up_event.locks = evas_locks; up_event.string = string; - EwkInternalApiBinding::GetInstance().view.SendKeyEvent(view_, &up_event, - is_down); + ftpw_webview_flutter_ewk_view_send_key_event(view_, &up_event, is_down); } return true; } @@ -480,7 +476,7 @@ void EwkWebViewBackend::GetScrollPosition(int32_t* x, int32_t* y) { } void EwkWebViewBackend::SetBackgroundColor(int r, int g, int b, int a) { - EwkInternalApiBinding::GetInstance().view.BgColorSet(view_, r, g, b, a); + ftpw_webview_flutter_ewk_view_bg_color_set(view_, r, g, b, a); } void EwkWebViewBackend::SetUserAgent(const std::string& user_agent) { @@ -492,27 +488,25 @@ std::string EwkWebViewBackend::GetUserAgent() { } void EwkWebViewBackend::EnableZoom(bool enabled) { - EwkInternalApiBinding::GetInstance().settings.ForceZoomSet( - ewk_view_settings_get(view_), enabled); + ftpw_webview_flutter_ewk_settings_force_zoom_set(ewk_view_settings_get(view_), + enabled); } void EwkWebViewBackend::JavaScriptAlertReply() { - EwkInternalApiBinding::GetInstance().view.JavaScriptAlertReply(view_); + ftpw_webview_flutter_ewk_view_javascript_alert_reply(view_); } void EwkWebViewBackend::JavaScriptConfirmReply(bool result) { - EwkInternalApiBinding::GetInstance().view.JavaScriptConfirmReply(view_, - result); + ftpw_webview_flutter_ewk_view_javascript_confirm_reply(view_, result); } void EwkWebViewBackend::JavaScriptPromptReply(const std::string& result) { - EwkInternalApiBinding::GetInstance().view.JavaScriptPromptReply( - view_, result.c_str()); + ftpw_webview_flutter_ewk_view_javascript_prompt_reply(view_, result.c_str()); } void EwkWebViewBackend::SetScrollbarVisible(bool visible) { scrollbar_enabled_ = visible; - EwkInternalApiBinding::GetInstance().view.MainFrameScrollbarVisibleSet( + ftpw_webview_flutter_ewk_view_main_frame_scrollbar_visible_set( view_, scrollbar_enabled_); } @@ -537,7 +531,7 @@ void EwkWebViewBackend::OnFrameRendered(void* data, Evas_Object* obj, void EwkWebViewBackend::OnLoadStarted(void* data, Evas_Object* obj, void* event_info) { EwkWebViewBackend* backend = static_cast(data); - EwkInternalApiBinding::GetInstance().view.MainFrameScrollbarVisibleSet( + ftpw_webview_flutter_ewk_view_main_frame_scrollbar_visible_set( backend->view_, backend->scrollbar_enabled_); backend->delegate_->OnLoadStarted( std::string(ewk_view_url_get(backend->view_))); @@ -570,13 +564,12 @@ void EwkWebViewBackend::OnLoadError(void* data, Evas_Object* obj, void EwkWebViewBackend::OnConsoleMessage(void* data, Evas_Object* obj, void* event_info) { EwkWebViewBackend* backend = static_cast(data); - Ewk_Console_Message* message = static_cast(event_info); Ewk_Console_Message_Level log_level = - EwkInternalApiBinding::GetInstance().console_message.LevelGet(message); - std::string text = - EwkInternalApiBinding::GetInstance().console_message.TextGet(message); + ftpw_webview_flutter_ewk_console_message_level_get(event_info); + const char* text = + ftpw_webview_flutter_ewk_console_message_text_get(event_info); backend->delegate_->OnConsoleMessage(ConvertLogLevelToString(log_level), - text); + text ? text : ""); } void EwkWebViewBackend::OnNavigationPolicy(void* data, Evas_Object* obj, @@ -639,7 +632,7 @@ void EwkWebViewBackend::OnJavaScriptMessage(Evas_Object* obj, } } -Eina_Bool EwkWebViewBackend::OnJavaScriptAlertDialog(Evas_Object* o, +Eina_Bool EwkWebViewBackend::OnJavaScriptAlertDialog(void* o, const char* message, void* data) { EwkWebViewBackend* backend = static_cast(data); @@ -648,7 +641,7 @@ Eina_Bool EwkWebViewBackend::OnJavaScriptAlertDialog(Evas_Object* o, return true; } -Eina_Bool EwkWebViewBackend::OnJavaScriptConfirmDialog(Evas_Object* o, +Eina_Bool EwkWebViewBackend::OnJavaScriptConfirmDialog(void* o, const char* message, void* data) { EwkWebViewBackend* backend = static_cast(data); @@ -657,7 +650,7 @@ Eina_Bool EwkWebViewBackend::OnJavaScriptConfirmDialog(Evas_Object* o, return true; } -Eina_Bool EwkWebViewBackend::OnJavaScriptPromptDialog(Evas_Object* o, +Eina_Bool EwkWebViewBackend::OnJavaScriptPromptDialog(void* o, const char* message, const char* default_text, void* data) { diff --git a/packages/webview_flutter/tizen/src/ewk_webview_backend.h b/packages/webview_flutter/tizen/src/ewk_webview_backend.h index 56b0dc644..8d141ffcf 100644 --- a/packages/webview_flutter/tizen/src/ewk_webview_backend.h +++ b/packages/webview_flutter/tizen/src/ewk_webview_backend.h @@ -15,7 +15,7 @@ #include #include -#include "ewk_internal_api_binding.h" +#include "ftpw_webview_flutter.h" #include "webview_backend.h" typedef struct _Ecore_Evas Ecore_Evas; @@ -96,11 +96,11 @@ class EwkWebViewBackend : public WebViewBackend { static void OnEvaluateJavaScript(Evas_Object* obj, const char* result_value, void* user_data); static void OnJavaScriptMessage(Evas_Object* obj, Ewk_Script_Message message); - static Eina_Bool OnJavaScriptAlertDialog(Evas_Object* o, const char* message, + static Eina_Bool OnJavaScriptAlertDialog(void* o, const char* message, void* data); - static Eina_Bool OnJavaScriptConfirmDialog(Evas_Object* o, - const char* message, void* data); - static Eina_Bool OnJavaScriptPromptDialog(Evas_Object* o, const char* message, + static Eina_Bool OnJavaScriptConfirmDialog(void* o, const char* message, + void* data); + static Eina_Bool OnJavaScriptPromptDialog(void* o, const char* message, const char* default_text, void* data); diff --git a/packages/webview_flutter/tizen/src/webview_backend_factory.cc b/packages/webview_flutter/tizen/src/webview_backend_factory.cc index 361d6579a..6db166967 100644 --- a/packages/webview_flutter/tizen/src/webview_backend_factory.cc +++ b/packages/webview_flutter/tizen/src/webview_backend_factory.cc @@ -7,10 +7,8 @@ #include #include -#include "ewk_internal_api_binding.h" #include "ewk_webview_backend.h" #include "log.h" -#include "wv_internal_api_binding.h" #include "wv_webview_backend.h" namespace { @@ -55,26 +53,14 @@ std::unique_ptr WebViewBackendFactory::Create( LOG_ERROR("WV engine is not initialized; cannot create WebView."); return nullptr; } - if (!WvInternalApiBinding::GetInstance().Initialize()) { - LOG_ERROR("Failed to initialize WV APIs."); - return nullptr; - } return std::make_unique(delegate); } - if (!EwkInternalApiBinding::GetInstance().Initialize()) { - LOG_ERROR("Failed to initialize EWK internal APIs."); - return nullptr; - } return std::make_unique(delegate); } void WebViewBackendFactory::InitializeEngine() { BackendKind kind = kSelectedBackend; if (kind != BackendKind::kEwk) { - if (!WvInternalApiBinding::GetInstance().Initialize()) { - LOG_ERROR("Failed to initialize WV APIs; engine not started."); - return; - } if (!WvWebViewBackend::GlobalInitialize(kind == BackendKind::kWvStandalone)) { LOG_ERROR("wv_init() failed; engine not started."); diff --git a/packages/webview_flutter/tizen/src/wv_internal_api_binding.cc b/packages/webview_flutter/tizen/src/wv_internal_api_binding.cc deleted file mode 100644 index ecaf5154e..000000000 --- a/packages/webview_flutter/tizen/src/wv_internal_api_binding.cc +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "wv_internal_api_binding.h" - -#include - -WvInternalApiBinding::WvInternalApiBinding() { - // The wv_* dispatcher lives in the same library as the ewk_* one. - handle_ = dlopen("libchromium-ewk.so", RTLD_LAZY); -} - -WvInternalApiBinding::~WvInternalApiBinding() { - if (handle_) { - dlclose(handle_); - } -} - -bool WvInternalApiBinding::Initialize() { - if (initialize_result_.has_value()) { - return *initialize_result_; - } - - if (!handle_) { - initialize_result_ = false; - return false; - } - - // wv_main - main.Init = reinterpret_cast(dlsym(handle_, "wv_init")); - main.Shutdown = - reinterpret_cast(dlsym(handle_, "wv_shutdown")); - main.SetArguments = - reinterpret_cast(dlsym(handle_, "wv_set_arguments")); - - // wv_view - view.Create = - reinterpret_cast(dlsym(handle_, "wv_view_create")); - view.Destroy = - reinterpret_cast(dlsym(handle_, "wv_view_destroy")); - view.Resize = - reinterpret_cast(dlsym(handle_, "wv_view_resize")); - view.FocusSet = reinterpret_cast( - dlsym(handle_, "wv_view_focus_set")); - view.UrlSet = - reinterpret_cast(dlsym(handle_, "wv_view_url_set")); - view.UrlGet = - reinterpret_cast(dlsym(handle_, "wv_view_url_get")); - view.UrlRequestSet = reinterpret_cast( - dlsym(handle_, "wv_view_url_request_set")); - view.HtmlStringLoad = reinterpret_cast( - dlsym(handle_, "wv_view_html_string_load")); - view.BackPossible = reinterpret_cast( - dlsym(handle_, "wv_view_back_possible")); - view.ForwardPossible = reinterpret_cast( - dlsym(handle_, "wv_view_forward_possible")); - view.Back = reinterpret_cast(dlsym(handle_, "wv_view_back")); - view.Forward = - reinterpret_cast(dlsym(handle_, "wv_view_forward")); - view.Reload = - reinterpret_cast(dlsym(handle_, "wv_view_reload")); - view.Stop = reinterpret_cast(dlsym(handle_, "wv_view_stop")); - view.Suspend = - reinterpret_cast(dlsym(handle_, "wv_view_suspend")); - view.Resume = - reinterpret_cast(dlsym(handle_, "wv_view_resume")); - view.TitleGet = reinterpret_cast( - dlsym(handle_, "wv_view_title_get")); - view.UserAgentSet = reinterpret_cast( - dlsym(handle_, "wv_view_user_agent_set")); - view.UserAgentGet = reinterpret_cast( - dlsym(handle_, "wv_view_user_agent_get")); - view.ScrollSet = reinterpret_cast( - dlsym(handle_, "wv_view_scroll_set")); - view.ScrollBy = reinterpret_cast( - dlsym(handle_, "wv_view_scroll_by")); - view.ScrollPosGet = reinterpret_cast( - dlsym(handle_, "wv_view_scroll_pos_get")); - view.ScriptExecute = reinterpret_cast( - dlsym(handle_, "wv_view_script_execute")); - view.BgColorSet = reinterpret_cast( - dlsym(handle_, "wv_view_bg_color_set")); - view.ContextGet = reinterpret_cast( - dlsym(handle_, "wv_view_context_get")); - view.SettingsGet = reinterpret_cast( - dlsym(handle_, "wv_view_settings_get")); - view.FeedTouchEvent = reinterpret_cast( - dlsym(handle_, "wv_view_feed_touch_event")); - view.FeedMouseDown = reinterpret_cast( - dlsym(handle_, "wv_view_feed_mouse_down")); - view.FeedMouseUp = reinterpret_cast( - dlsym(handle_, "wv_view_feed_mouse_up")); - view.FeedMouseMove = reinterpret_cast( - dlsym(handle_, "wv_view_feed_mouse_move")); - view.FeedMouseWheel = reinterpret_cast( - dlsym(handle_, "wv_view_feed_mouse_wheel")); - view.SendKeyEvent = reinterpret_cast( - dlsym(handle_, "wv_view_send_key_event")); - view.TouchEventsEnabledSet = - reinterpret_cast( - dlsym(handle_, "wv_view_touch_events_enabled_set")); - view.MouseEventsEnabledSet = - reinterpret_cast( - dlsym(handle_, "wv_view_mouse_events_enabled_set")); - view.KeyEventsEnabledSet = reinterpret_cast( - dlsym(handle_, "wv_view_key_events_enabled_set")); - view.ImeWindowSet = reinterpret_cast( - dlsym(handle_, "wv_view_ime_window_set")); - view.AddCallback = reinterpret_cast( - dlsym(handle_, "wv_view_add_cb")); - view.RemoveFullCallback = reinterpret_cast( - dlsym(handle_, "wv_view_remove_full_cb")); - view.OnJavaScriptAlert = - reinterpret_cast( - dlsym(handle_, "wv_view_javascript_alert_callback_set")); - view.OnJavaScriptConfirm = - reinterpret_cast( - dlsym(handle_, "wv_view_javascript_confirm_callback_set")); - view.OnJavaScriptPrompt = - reinterpret_cast( - dlsym(handle_, "wv_view_javascript_prompt_callback_set")); - view.JavaScriptAlertReply = reinterpret_cast( - dlsym(handle_, "wv_view_javascript_alert_reply")); - view.JavaScriptConfirmReply = - reinterpret_cast( - dlsym(handle_, "wv_view_javascript_confirm_reply")); - view.JavaScriptPromptReply = - reinterpret_cast( - dlsym(handle_, "wv_view_javascript_prompt_reply")); - view.JavaScriptMessageHandlerAdd = - reinterpret_cast( - dlsym(handle_, "wv_view_javascript_message_handler_add")); - view.SetSupportVideoHole = reinterpret_cast( - dlsym(handle_, "wv_view_set_support_video_hole")); - view.MainFrameScrollbarVisibleSet = - reinterpret_cast( - dlsym(handle_, "wv_view_main_frame_scrollbar_visible_set")); - - // wv_context - context.CookieManagerGet = reinterpret_cast( - dlsym(handle_, "wv_context_cookie_manager_get")); - context.CacheModelSet = reinterpret_cast( - dlsym(handle_, "wv_context_cache_model_set")); - context.WebStorageDeleteAll = - reinterpret_cast( - dlsym(handle_, "wv_context_web_storage_delete_all")); - context.CacheClear = reinterpret_cast( - dlsym(handle_, "wv_context_cache_clear")); - - // wv_cookie_manager - cookie_manager.AcceptPolicySet = - reinterpret_cast( - dlsym(handle_, "wv_cookie_manager_accept_policy_set")); - cookie_manager.CookiesClear = - reinterpret_cast( - dlsym(handle_, "wv_cookie_manager_cookies_clear")); - - // wv_settings - settings.JavaScriptEnabledSet = - reinterpret_cast( - dlsym(handle_, "wv_settings_javascript_enabled_set")); - settings.ImePanelEnabledSet = - reinterpret_cast( - dlsym(handle_, "wv_settings_ime_panel_enabled_set")); - settings.ForceZoomSet = reinterpret_cast( - dlsym(handle_, "wv_settings_force_zoom_set")); - - // wv_error - error.CodeGet = reinterpret_cast( - dlsym(handle_, "wv_error_code_get")); - error.DescriptionGet = reinterpret_cast( - dlsym(handle_, "wv_error_description_get")); - error.UrlGet = - reinterpret_cast(dlsym(handle_, "wv_error_url_get")); - - // wv_policy_decision - policy_decision.Use = reinterpret_cast( - dlsym(handle_, "wv_policy_decision_use")); - policy_decision.UrlGet = reinterpret_cast( - dlsym(handle_, "wv_policy_decision_url_get")); - policy_decision.ResponseStatusCodeGet = - reinterpret_cast( - dlsym(handle_, "wv_policy_decision_response_status_code_get")); - - // wv_console_message - console_message.LevelGet = reinterpret_cast( - dlsym(handle_, "wv_console_message_level_get")); - console_message.TextGet = reinterpret_cast( - dlsym(handle_, "wv_console_message_text_get")); - - initialize_result_ = - main.Init && main.Shutdown && main.SetArguments && view.Create && - view.Destroy && view.Resize && view.FocusSet && view.UrlSet && - view.UrlGet && view.UrlRequestSet && view.HtmlStringLoad && - view.BackPossible && view.ForwardPossible && view.Back && view.Forward && - view.Reload && view.Stop && view.Suspend && view.Resume && - view.TitleGet && view.UserAgentSet && view.UserAgentGet && - view.ScrollSet && view.ScrollBy && view.ScrollPosGet && - view.ScriptExecute && view.BgColorSet && view.ContextGet && - view.SettingsGet && view.FeedTouchEvent && view.FeedMouseDown && - view.FeedMouseUp && view.FeedMouseMove && view.FeedMouseWheel && - view.SendKeyEvent && view.TouchEventsEnabledSet && - view.MouseEventsEnabledSet && view.KeyEventsEnabledSet && - view.ImeWindowSet && view.AddCallback && view.RemoveFullCallback && - view.OnJavaScriptAlert && view.OnJavaScriptConfirm && - view.OnJavaScriptPrompt && view.JavaScriptAlertReply && - view.JavaScriptConfirmReply && view.JavaScriptPromptReply && - view.JavaScriptMessageHandlerAdd && view.SetSupportVideoHole && - view.MainFrameScrollbarVisibleSet && context.CookieManagerGet && - context.CacheModelSet && context.WebStorageDeleteAll && - context.CacheClear && cookie_manager.AcceptPolicySet && - cookie_manager.CookiesClear && settings.JavaScriptEnabledSet && - settings.ImePanelEnabledSet && settings.ForceZoomSet && error.CodeGet && - error.DescriptionGet && error.UrlGet && policy_decision.Use && - policy_decision.UrlGet && policy_decision.ResponseStatusCodeGet && - console_message.LevelGet && console_message.TextGet; - return *initialize_result_; -} diff --git a/packages/webview_flutter/tizen/src/wv_internal_api_binding.h b/packages/webview_flutter/tizen/src/wv_internal_api_binding.h deleted file mode 100644 index c358aec5f..000000000 --- a/packages/webview_flutter/tizen/src/wv_internal_api_binding.h +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_PLUGIN_WV_INTERNAL_API_BINDING_H_ -#define FLUTTER_PLUGIN_WV_INTERNAL_API_BINDING_H_ - -#include - -#include - -typedef struct wv_view_s* wv_view_h; -typedef struct wv_context_s* wv_context_h; -typedef struct wv_settings_s* wv_settings_h; -typedef struct wv_cookie_manager_s* wv_cookie_manager_h; -typedef struct wv_error_s* wv_error_h; -typedef struct wv_policy_decision_s* wv_policy_decision_h; -typedef struct wv_console_message_s* wv_console_message_h; - -typedef enum { - WV_HTTP_METHOD_GET, - WV_HTTP_METHOD_HEAD, - WV_HTTP_METHOD_POST, - WV_HTTP_METHOD_PUT, - WV_HTTP_METHOD_DELETE, -} wv_http_method_e; - -typedef enum { - WV_CACHE_MODEL_DOCUMENT_VIEWER, - WV_CACHE_MODEL_DOCUMENT_BROWSER, - WV_CACHE_MODEL_PRIMARY_WEBBROWSER -} wv_cache_model_e; - -typedef enum { - WV_TOUCH_EVENT_START, - WV_TOUCH_EVENT_MOVE, - WV_TOUCH_EVENT_END, - WV_TOUCH_EVENT_CANCEL -} wv_touch_event_type_e; - -typedef enum { - WV_TOUCH_POINT_STATE_DOWN, - WV_TOUCH_POINT_STATE_UP, - WV_TOUCH_POINT_STATE_MOVE, - WV_TOUCH_POINT_STATE_STILL, - WV_TOUCH_POINT_STATE_CANCEL -} wv_touch_point_state_e; - -typedef enum { - WV_MODIFIER_NONE = 0, - WV_MODIFIER_SHIFT = 1 << 0, - WV_MODIFIER_CONTROL = 1 << 1, - WV_MODIFIER_ALT = 1 << 2, - WV_MODIFIER_SUPER = 1 << 3, - WV_MODIFIER_HYPER = 1 << 4, - WV_MODIFIER_CAPS_LOCK = 1 << 5, - WV_MODIFIER_NUM_LOCK = 1 << 6 -} wv_modifier_e; - -typedef enum { - WV_MOUSE_BUTTON_LEFT = 1, - WV_MOUSE_BUTTON_MIDDLE = 2, - WV_MOUSE_BUTTON_RIGHT = 3 -} wv_mouse_button_type_e; - -typedef enum { - WV_COOKIE_ACCEPT_POLICY_ALWAYS, - WV_COOKIE_ACCEPT_POLICY_NEVER, - WV_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY -} wv_cookie_accept_policy_e; - -typedef enum { - WV_CONSOLE_MESSAGE_LEVEL_NULL, - WV_CONSOLE_MESSAGE_LEVEL_LOG, - WV_CONSOLE_MESSAGE_LEVEL_WARNING, - WV_CONSOLE_MESSAGE_LEVEL_ERROR, - WV_CONSOLE_MESSAGE_LEVEL_DEBUG, - WV_CONSOLE_MESSAGE_LEVEL_INFO -} wv_console_message_level_e; - -typedef struct { - int id; - int x; - int y; - wv_touch_point_state_e state; -} wv_touch_point_s; - -typedef struct { - const char* key_name; - const char* key; - const char* string; - const char* compose; - unsigned int timestamp; - wv_modifier_e modifiers; - int event_flags; - unsigned int key_code; -} wv_key_event_s; - -typedef struct { - const char* name; - void* body; -} wv_script_message_s; - -typedef void (*wv_view_cb)(wv_view_h obj, void* event_info, void* user_data); -typedef void (*wv_view_script_execute_cb)(wv_view_h view, - const char* result_value, - void* user_data); -typedef void (*wv_view_script_message_cb)(wv_view_h view, - wv_script_message_s message); -typedef bool (*wv_view_javascript_alert_cb)(wv_view_h view, - const char* alert_text, - void* user_data); -typedef bool (*wv_view_javascript_confirm_cb)(wv_view_h view, - const char* message, - void* user_data); -typedef bool (*wv_view_javascript_prompt_cb)(wv_view_h view, - const char* message, - const char* default_value, - void* user_data); - -typedef int (*WvInitFnPtr)(void); -typedef int (*WvShutdownFnPtr)(void); -typedef int (*WvSetArgumentsFnPtr)(int argc, const char** argv); - -typedef struct { - WvInitFnPtr Init = nullptr; - WvShutdownFnPtr Shutdown = nullptr; - WvSetArgumentsFnPtr SetArguments = nullptr; -} WvMainProcTable; - -typedef wv_view_h (*WvViewCreateFnPtr)(void); -typedef void (*WvViewDestroyFnPtr)(wv_view_h view); -typedef void (*WvViewResizeFnPtr)(wv_view_h view, int w, int h); -typedef bool (*WvViewFocusSetFnPtr)(wv_view_h view, int focused); -typedef bool (*WvViewUrlSetFnPtr)(wv_view_h view, const char* url); -typedef const char* (*WvViewUrlGetFnPtr)(wv_view_h view); -typedef bool (*WvViewUrlRequestSetFnPtr)(wv_view_h view, const char* url, - wv_http_method_e method, void* headers, - const char* body); -typedef bool (*WvViewHtmlStringLoadFnPtr)(wv_view_h view, const char* html, - const char* base_url, - const char* unreachable_url); -typedef bool (*WvViewBackPossibleFnPtr)(wv_view_h view); -typedef bool (*WvViewForwardPossibleFnPtr)(wv_view_h view); -typedef bool (*WvViewBackFnPtr)(wv_view_h view); -typedef bool (*WvViewForwardFnPtr)(wv_view_h view); -typedef bool (*WvViewReloadFnPtr)(wv_view_h view); -typedef bool (*WvViewStopFnPtr)(wv_view_h view); -typedef void (*WvViewSuspendFnPtr)(wv_view_h view); -typedef void (*WvViewResumeFnPtr)(wv_view_h view); -typedef const char* (*WvViewTitleGetFnPtr)(wv_view_h view); -typedef bool (*WvViewUserAgentSetFnPtr)(wv_view_h view, const char* user_agent); -typedef const char* (*WvViewUserAgentGetFnPtr)(wv_view_h view); -typedef bool (*WvViewScrollSetFnPtr)(wv_view_h view, int x, int y); -typedef void (*WvViewScrollByFnPtr)(wv_view_h view, int dx, int dy); -typedef bool (*WvViewScrollPosGetFnPtr)(wv_view_h view, int* x, int* y); -typedef bool (*WvViewScriptExecuteFnPtr)(wv_view_h view, const char* script, - wv_view_script_execute_cb callback, - void* user_data); -typedef bool (*WvViewJavaScriptMessageHandlerAddFnPtr)( - wv_view_h view, wv_view_script_message_cb callback, const char* name); -typedef bool (*WvViewBgColorSetFnPtr)(wv_view_h view, int r, int g, int b, - int a); -typedef wv_context_h (*WvViewContextGetFnPtr)(wv_view_h view); -typedef wv_settings_h (*WvViewSettingsGetFnPtr)(wv_view_h view); -typedef int (*WvViewFeedTouchEventFnPtr)(wv_view_h view, - wv_touch_event_type_e event_type, - GList* points, - wv_modifier_e modifiers); -typedef int (*WvViewFeedMouseDownFnPtr)(wv_view_h view, - wv_mouse_button_type_e button, int x, - int y); -typedef int (*WvViewFeedMouseUpFnPtr)(wv_view_h view, - wv_mouse_button_type_e button, int x, - int y); -typedef int (*WvViewFeedMouseMoveFnPtr)(wv_view_h view, int x, int y); -typedef int (*WvViewFeedMouseWheelFnPtr)(wv_view_h view, bool y_direction, - int step, int x, int y); -typedef int (*WvViewSendKeyEventFnPtr)(wv_view_h view, - const wv_key_event_s* key_event, - int is_press); -typedef int (*WvViewTouchEventsEnabledSetFnPtr)(wv_view_h view, int enabled); -typedef bool (*WvViewMouseEventsEnabledSetFnPtr)(wv_view_h view, bool enabled); -typedef bool (*WvViewKeyEventsEnabledSetFnPtr)(wv_view_h view, bool enabled); -typedef void (*WvViewImeWindowSetFnPtr)(wv_view_h view, void* window); -typedef int (*WvViewAddCallbackFnPtr)(wv_view_h view, const char* event, - wv_view_cb func, const void* user_data); -typedef int (*WvViewRemoveFullCallbackFnPtr)(wv_view_h view, const char* event, - wv_view_cb func, - const void* user_data); -typedef int (*WvViewJavaScriptAlertCallbackSetFnPtr)( - wv_view_h view, wv_view_javascript_alert_cb callback, void* user_data); -typedef int (*WvViewJavaScriptConfirmCallbackSetFnPtr)( - wv_view_h view, wv_view_javascript_confirm_cb callback, void* user_data); -typedef int (*WvViewJavaScriptPromptCallbackSetFnPtr)( - wv_view_h view, wv_view_javascript_prompt_cb callback, void* user_data); -typedef void (*WvViewJavaScriptAlertReplyFnPtr)(wv_view_h view); -typedef void (*WvViewJavaScriptConfirmReplyFnPtr)(wv_view_h view, bool result); -typedef void (*WvViewJavaScriptPromptReplyFnPtr)(wv_view_h view, - const char* result); -typedef bool (*WvViewSetSupportVideoHoleFnPtr)(wv_view_h view, void* window, - bool enable, - bool is_video_window); -typedef bool (*WvViewMainFrameScrollbarVisibleSetFnPtr)(wv_view_h view, - bool visible); - -typedef struct { - WvViewCreateFnPtr Create = nullptr; - WvViewDestroyFnPtr Destroy = nullptr; - WvViewResizeFnPtr Resize = nullptr; - WvViewFocusSetFnPtr FocusSet = nullptr; - WvViewUrlSetFnPtr UrlSet = nullptr; - WvViewUrlGetFnPtr UrlGet = nullptr; - WvViewUrlRequestSetFnPtr UrlRequestSet = nullptr; - WvViewHtmlStringLoadFnPtr HtmlStringLoad = nullptr; - WvViewBackPossibleFnPtr BackPossible = nullptr; - WvViewForwardPossibleFnPtr ForwardPossible = nullptr; - WvViewBackFnPtr Back = nullptr; - WvViewForwardFnPtr Forward = nullptr; - WvViewReloadFnPtr Reload = nullptr; - WvViewStopFnPtr Stop = nullptr; - WvViewSuspendFnPtr Suspend = nullptr; - WvViewResumeFnPtr Resume = nullptr; - WvViewTitleGetFnPtr TitleGet = nullptr; - WvViewUserAgentSetFnPtr UserAgentSet = nullptr; - WvViewUserAgentGetFnPtr UserAgentGet = nullptr; - WvViewScrollSetFnPtr ScrollSet = nullptr; - WvViewScrollByFnPtr ScrollBy = nullptr; - WvViewScrollPosGetFnPtr ScrollPosGet = nullptr; - WvViewScriptExecuteFnPtr ScriptExecute = nullptr; - WvViewBgColorSetFnPtr BgColorSet = nullptr; - WvViewContextGetFnPtr ContextGet = nullptr; - WvViewSettingsGetFnPtr SettingsGet = nullptr; - WvViewFeedTouchEventFnPtr FeedTouchEvent = nullptr; - WvViewFeedMouseDownFnPtr FeedMouseDown = nullptr; - WvViewFeedMouseUpFnPtr FeedMouseUp = nullptr; - WvViewFeedMouseMoveFnPtr FeedMouseMove = nullptr; - WvViewFeedMouseWheelFnPtr FeedMouseWheel = nullptr; - WvViewSendKeyEventFnPtr SendKeyEvent = nullptr; - WvViewTouchEventsEnabledSetFnPtr TouchEventsEnabledSet = nullptr; - WvViewMouseEventsEnabledSetFnPtr MouseEventsEnabledSet = nullptr; - WvViewKeyEventsEnabledSetFnPtr KeyEventsEnabledSet = nullptr; - WvViewImeWindowSetFnPtr ImeWindowSet = nullptr; - WvViewAddCallbackFnPtr AddCallback = nullptr; - WvViewRemoveFullCallbackFnPtr RemoveFullCallback = nullptr; - WvViewJavaScriptAlertCallbackSetFnPtr OnJavaScriptAlert = nullptr; - WvViewJavaScriptConfirmCallbackSetFnPtr OnJavaScriptConfirm = nullptr; - WvViewJavaScriptPromptCallbackSetFnPtr OnJavaScriptPrompt = nullptr; - WvViewJavaScriptAlertReplyFnPtr JavaScriptAlertReply = nullptr; - WvViewJavaScriptConfirmReplyFnPtr JavaScriptConfirmReply = nullptr; - WvViewJavaScriptPromptReplyFnPtr JavaScriptPromptReply = nullptr; - WvViewJavaScriptMessageHandlerAddFnPtr JavaScriptMessageHandlerAdd = nullptr; - WvViewSetSupportVideoHoleFnPtr SetSupportVideoHole = nullptr; - WvViewMainFrameScrollbarVisibleSetFnPtr MainFrameScrollbarVisibleSet = - nullptr; -} WvViewProcTable; - -typedef wv_cookie_manager_h (*WvContextCookieManagerGetFnPtr)( - wv_context_h context); -typedef int (*WvContextCacheModelSetFnPtr)(wv_context_h context, - wv_cache_model_e model); -typedef int (*WvContextWebStorageDeleteAllFnPtr)(wv_context_h context); -typedef int (*WvContextCacheClearFnPtr)(wv_context_h context); - -typedef struct { - WvContextCookieManagerGetFnPtr CookieManagerGet = nullptr; - WvContextCacheModelSetFnPtr CacheModelSet = nullptr; - WvContextWebStorageDeleteAllFnPtr WebStorageDeleteAll = nullptr; - WvContextCacheClearFnPtr CacheClear = nullptr; -} WvContextProcTable; - -typedef int (*WvCookieManagerAcceptPolicySetFnPtr)( - wv_cookie_manager_h manager, wv_cookie_accept_policy_e policy); -typedef int (*WvCookieManagerCookiesClearFnPtr)(wv_cookie_manager_h manager); - -typedef struct { - WvCookieManagerAcceptPolicySetFnPtr AcceptPolicySet = nullptr; - WvCookieManagerCookiesClearFnPtr CookiesClear = nullptr; -} WvCookieManagerProcTable; - -typedef bool (*WvSettingsJavaScriptEnabledSetFnPtr)(wv_settings_h settings, - bool enable); -typedef void (*WvSettingsImePanelEnabledSetFnPtr)(wv_settings_h settings, - bool enable); -typedef bool (*WvSettingsForceZoomSetFnPtr)(wv_settings_h settings, - bool enable); - -typedef struct { - WvSettingsJavaScriptEnabledSetFnPtr JavaScriptEnabledSet = nullptr; - WvSettingsImePanelEnabledSetFnPtr ImePanelEnabledSet = nullptr; - WvSettingsForceZoomSetFnPtr ForceZoomSet = nullptr; -} WvSettingsProcTable; - -typedef int (*WvErrorCodeGetFnPtr)(wv_error_h error); -typedef const char* (*WvErrorDescriptionGetFnPtr)(wv_error_h error); -typedef const char* (*WvErrorUrlGetFnPtr)(wv_error_h error); - -typedef struct { - WvErrorCodeGetFnPtr CodeGet = nullptr; - WvErrorDescriptionGetFnPtr DescriptionGet = nullptr; - WvErrorUrlGetFnPtr UrlGet = nullptr; -} WvErrorProcTable; - -typedef int (*WvPolicyDecisionUseFnPtr)(wv_policy_decision_h policy_decision); -typedef const char* (*WvPolicyDecisionUrlGetFnPtr)( - wv_policy_decision_h policy_decision); -typedef int (*WvPolicyDecisionResponseStatusCodeGetFnPtr)( - wv_policy_decision_h policy_decision); - -typedef struct { - WvPolicyDecisionUseFnPtr Use = nullptr; - WvPolicyDecisionUrlGetFnPtr UrlGet = nullptr; - WvPolicyDecisionResponseStatusCodeGetFnPtr ResponseStatusCodeGet = nullptr; -} WvPolicyDecisionProcTable; - -typedef wv_console_message_level_e (*WvConsoleMessageLevelGetFnPtr)( - wv_console_message_h message); -typedef const char* (*WvConsoleMessageTextGetFnPtr)( - wv_console_message_h message); - -typedef struct { - WvConsoleMessageLevelGetFnPtr LevelGet = nullptr; - WvConsoleMessageTextGetFnPtr TextGet = nullptr; -} WvConsoleMessageProcTable; - -class WvInternalApiBinding { - public: - static WvInternalApiBinding& GetInstance() { - static WvInternalApiBinding instance = WvInternalApiBinding(); - return instance; - } - - ~WvInternalApiBinding(); - - WvInternalApiBinding(const WvInternalApiBinding&) = delete; - WvInternalApiBinding& operator=(const WvInternalApiBinding&) = delete; - - bool Initialize(); - - WvMainProcTable main; - WvViewProcTable view; - WvContextProcTable context; - WvCookieManagerProcTable cookie_manager; - WvSettingsProcTable settings; - WvErrorProcTable error; - WvPolicyDecisionProcTable policy_decision; - WvConsoleMessageProcTable console_message; - - private: - WvInternalApiBinding(); - - void* handle_ = nullptr; - std::optional initialize_result_; -}; - -#endif // FLUTTER_PLUGIN_WV_INTERNAL_API_BINDING_H_ diff --git a/packages/webview_flutter/tizen/src/wv_webview_backend.cc b/packages/webview_flutter/tizen/src/wv_webview_backend.cc index 7771b62b1..7102c6ed2 100644 --- a/packages/webview_flutter/tizen/src/wv_webview_backend.cc +++ b/packages/webview_flutter/tizen/src/wv_webview_backend.cc @@ -74,14 +74,13 @@ wv_modifier_e ConvertModifiers(unsigned int modifiers) { } std::mutex g_view_registry_mutex; -std::map g_view_registry; +std::map g_view_registry; } // namespace WvWebViewBackend::WvWebViewBackend(Delegate* delegate) : delegate_(delegate) {} bool WvWebViewBackend::GlobalInitialize(bool standalone) { - auto& wv = WvInternalApiBinding::GetInstance(); std::vector argv = { "--disable-pinch", "--js-flags=--expose-gc", @@ -91,12 +90,13 @@ bool WvWebViewBackend::GlobalInitialize(bool standalone) { if (standalone) { argv.push_back("--enable-wv-standalone"); } - int result = wv.main.SetArguments(static_cast(argv.size()), argv.data()); + int result = ftpw_webview_flutter_wv_set_arguments( + static_cast(argv.size()), argv.data()); if (result != 0) { LOG_ERROR("wv_set_arguments() returned %d.", result); return false; } - result = wv.main.Init(); + result = ftpw_webview_flutter_wv_init(); if (result <= 0) { LOG_ERROR("wv_init() returned %d.", result); return false; @@ -106,74 +106,76 @@ bool WvWebViewBackend::GlobalInitialize(bool standalone) { void WvWebViewBackend::GlobalShutdown() { FlushPendingTeardowns(); - WvInternalApiBinding::GetInstance().main.Shutdown(); + ftpw_webview_flutter_wv_shutdown(); } bool WvWebViewBackend::Create(double width, double height, void* window, bool /*engine_policy*/) { window_ = window; - auto& wv = WvInternalApiBinding::GetInstance(); - - view_ = wv.view.Create(); + view_ = ftpw_webview_flutter_wv_view_create(); if (!view_) { return false; } - wv.view.FocusSet(view_, 1); + ftpw_webview_flutter_wv_view_focus_set(view_, 1); - wv_context_h context = wv.view.ContextGet(view_); - wv_cookie_manager_h cookie_manager = wv.context.CookieManagerGet(context); + void* context = ftpw_webview_flutter_wv_view_context_get(view_); + void* cookie_manager = + ftpw_webview_flutter_wv_context_cookie_manager_get(context); if (cookie_manager) { - wv.cookie_manager.AcceptPolicySet(cookie_manager, - WV_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY); + ftpw_webview_flutter_wv_cookie_manager_accept_policy_set(cookie_manager); } - wv.context.CacheModelSet(context, WV_CACHE_MODEL_PRIMARY_WEBBROWSER); + ftpw_webview_flutter_wv_context_cache_model_set(context); - wv_settings_h settings = wv.view.SettingsGet(view_); - wv.settings.ImePanelEnabledSet(settings, true); - wv.settings.ForceZoomSet(settings, true); - wv.view.ImeWindowSet(view_, window_); - wv.view.KeyEventsEnabledSet(view_, true); + void* settings = ftpw_webview_flutter_wv_view_settings_get(view_); + ftpw_webview_flutter_wv_settings_ime_panel_enabled_set(settings, true); + ftpw_webview_flutter_wv_settings_force_zoom_set(settings, true); + ftpw_webview_flutter_wv_view_ime_window_set(view_, window_); + ftpw_webview_flutter_wv_view_key_events_enabled_set(view_, true); #ifdef WEBVIEW_TIZEN_TOUCH_EVENTS_ENABLED - wv.view.TouchEventsEnabledSet(view_, true); - wv.view.MouseEventsEnabledSet(view_, false); + ftpw_webview_flutter_wv_view_touch_events_enabled_set(view_, true); + ftpw_webview_flutter_wv_view_mouse_events_enabled_set(view_, false); #else - wv.view.TouchEventsEnabledSet(view_, false); - wv.view.MouseEventsEnabledSet(view_, true); + ftpw_webview_flutter_wv_view_touch_events_enabled_set(view_, false); + ftpw_webview_flutter_wv_view_mouse_events_enabled_set(view_, true); #endif - wv.view.OnJavaScriptAlert(view_, &WvWebViewBackend::OnJavaScriptAlertDialog, - this); - wv.view.OnJavaScriptConfirm( + ftpw_webview_flutter_wv_view_javascript_alert_callback_set( + view_, &WvWebViewBackend::OnJavaScriptAlertDialog, this); + ftpw_webview_flutter_wv_view_javascript_confirm_callback_set( view_, &WvWebViewBackend::OnJavaScriptConfirmDialog, this); - wv.view.OnJavaScriptPrompt(view_, &WvWebViewBackend::OnJavaScriptPromptDialog, - this); + ftpw_webview_flutter_wv_view_javascript_prompt_callback_set( + view_, &WvWebViewBackend::OnJavaScriptPromptDialog, this); #ifdef TV_PROFILE - wv.view.SetSupportVideoHole(view_, window_, true, false); + ftpw_webview_flutter_wv_view_set_support_video_hole(view_, window_, true, + false); #endif - wv.view.AddCallback(view_, "offscreen,frame,rendered", - &WvWebViewBackend::OnFrameRendered, this); - wv.view.AddCallback(view_, "load,started", &WvWebViewBackend::OnLoadStarted, - this); - wv.view.AddCallback(view_, "load,finished", &WvWebViewBackend::OnLoadFinished, - this); - wv.view.AddCallback(view_, "load,progress", &WvWebViewBackend::OnProgress, - this); - wv.view.AddCallback(view_, "load,error", &WvWebViewBackend::OnLoadError, - this); - wv.view.AddCallback(view_, "console,message", - &WvWebViewBackend::OnConsoleMessage, this); - wv.view.AddCallback(view_, "policy,navigation,decide", - &WvWebViewBackend::OnNavigationPolicy, this); - wv.view.AddCallback(view_, "policy,response,decide", - &WvWebViewBackend::OnResponsePolicy, this); - wv.view.AddCallback(view_, "url,changed", &WvWebViewBackend::OnUrlChange, - this); - - wv.view.Resize(view_, static_cast(std::round(width)), - static_cast(std::round(height))); + ftpw_webview_flutter_wv_view_add_cb(view_, "offscreen,frame,rendered", + &WvWebViewBackend::OnFrameRendered, this); + ftpw_webview_flutter_wv_view_add_cb(view_, "load,started", + &WvWebViewBackend::OnLoadStarted, this); + ftpw_webview_flutter_wv_view_add_cb(view_, "load,finished", + &WvWebViewBackend::OnLoadFinished, this); + ftpw_webview_flutter_wv_view_add_cb(view_, "load,progress", + &WvWebViewBackend::OnProgress, this); + ftpw_webview_flutter_wv_view_add_cb(view_, "load,error", + &WvWebViewBackend::OnLoadError, this); + ftpw_webview_flutter_wv_view_add_cb( + view_, "console,message", &WvWebViewBackend::OnConsoleMessage, this); + ftpw_webview_flutter_wv_view_add_cb(view_, "policy,navigation,decide", + &WvWebViewBackend::OnNavigationPolicy, + this); + ftpw_webview_flutter_wv_view_add_cb(view_, "policy,response,decide", + &WvWebViewBackend::OnResponsePolicy, + this); + ftpw_webview_flutter_wv_view_add_cb(view_, "url,changed", + &WvWebViewBackend::OnUrlChange, this); + + ftpw_webview_flutter_wv_view_resize(view_, + static_cast(std::round(width)), + static_cast(std::round(height))); { std::lock_guard lock(g_view_registry_mutex); @@ -185,46 +187,49 @@ bool WvWebViewBackend::Create(double width, double height, void* window, std::function WvWebViewBackend::PrepareTeardown( std::shared_ptr pool) { - wv_view_h instance = view_; + void* instance = view_; view_ = nullptr; std::function destroy; if (instance) { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.view.RemoveFullCallback(instance, "offscreen,frame,rendered", - &WvWebViewBackend::OnFrameRendered, this); - wv.view.RemoveFullCallback(instance, "load,started", - &WvWebViewBackend::OnLoadStarted, this); - wv.view.RemoveFullCallback(instance, "load,finished", - &WvWebViewBackend::OnLoadFinished, this); - wv.view.RemoveFullCallback(instance, "load,progress", - &WvWebViewBackend::OnProgress, this); - wv.view.RemoveFullCallback(instance, "load,error", - &WvWebViewBackend::OnLoadError, this); - wv.view.RemoveFullCallback(instance, "console,message", - &WvWebViewBackend::OnConsoleMessage, this); - wv.view.RemoveFullCallback(instance, "policy,navigation,decide", - &WvWebViewBackend::OnNavigationPolicy, this); - wv.view.RemoveFullCallback(instance, "policy,response,decide", - &WvWebViewBackend::OnResponsePolicy, this); - wv.view.RemoveFullCallback(instance, "url,changed", - &WvWebViewBackend::OnUrlChange, this); - - wv.view.OnJavaScriptAlert(instance, nullptr, nullptr); - wv.view.OnJavaScriptConfirm(instance, nullptr, nullptr); - wv.view.OnJavaScriptPrompt(instance, nullptr, nullptr); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "offscreen,frame,rendered", + &WvWebViewBackend::OnFrameRendered, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "load,started", &WvWebViewBackend::OnLoadStarted, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "load,finished", &WvWebViewBackend::OnLoadFinished, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "load,progress", &WvWebViewBackend::OnProgress, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "load,error", &WvWebViewBackend::OnLoadError, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "console,message", &WvWebViewBackend::OnConsoleMessage, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "policy,navigation,decide", + &WvWebViewBackend::OnNavigationPolicy, this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "policy,response,decide", &WvWebViewBackend::OnResponsePolicy, + this); + ftpw_webview_flutter_wv_view_remove_full_cb( + instance, "url,changed", &WvWebViewBackend::OnUrlChange, this); + + ftpw_webview_flutter_wv_view_javascript_alert_callback_set( + instance, nullptr, nullptr); + ftpw_webview_flutter_wv_view_javascript_confirm_callback_set( + instance, nullptr, nullptr); + ftpw_webview_flutter_wv_view_javascript_prompt_callback_set( + instance, nullptr, nullptr); { std::lock_guard lock(g_view_registry_mutex); g_view_registry.erase(instance); } - wv.view.Stop(instance); - wv.view.Suspend(instance); + ftpw_webview_flutter_wv_view_stop(instance); + ftpw_webview_flutter_wv_view_suspend(instance); - destroy = [instance]() { - WvInternalApiBinding::GetInstance().view.Destroy(instance); - }; + destroy = [instance]() { ftpw_webview_flutter_wv_view_destroy(instance); }; } return RegisterPendingTeardown(std::move(pool), std::move(destroy)); @@ -233,9 +238,9 @@ std::function WvWebViewBackend::PrepareTeardown( void WvWebViewBackend::Offset(double left, double top) {} void WvWebViewBackend::Resize(double width, double height) { - WvInternalApiBinding::GetInstance().view.Resize( - view_, static_cast(std::round(width)), - static_cast(std::round(height))); + ftpw_webview_flutter_wv_view_resize(view_, + static_cast(std::round(width)), + static_cast(std::round(height))); } void WvWebViewBackend::Touch(int event_type, int button_type, double x, @@ -270,8 +275,8 @@ void WvWebViewBackend::SendTouchEvent(int event_type, double x, double y) { point.state = state; GList* points = g_list_append(nullptr, &point); - WvInternalApiBinding::GetInstance().view.FeedTouchEvent( - view_, touch_event_type, points, WV_MODIFIER_NONE); + ftpw_webview_flutter_wv_view_feed_touch_event(view_, touch_event_type, points, + WV_MODIFIER_NONE); g_list_free(points); } @@ -294,16 +299,18 @@ void WvWebViewBackend::SendMouseEvent(int event_type, int button_type, double x, int px = static_cast(x); int py = static_cast(y); - auto& wv = WvInternalApiBinding::GetInstance(); if (event_type == 0) { mouse_button_type_ = mouse_button_type; - wv.view.FeedMouseDown(view_, mouse_button_type_, px, py); + ftpw_webview_flutter_wv_view_feed_mouse_down(view_, mouse_button_type_, px, + py); } else if (event_type == 1) { if (dy != 0) { - wv.view.FeedMouseWheel(view_, true, dy > 0 ? 1 : -1, px, py); + ftpw_webview_flutter_wv_view_feed_mouse_wheel(view_, true, + dy > 0 ? 1 : -1, px, py); } } else if (event_type == 2) { - wv.view.FeedMouseUp(view_, mouse_button_type_, px, py); + ftpw_webview_flutter_wv_view_feed_mouse_up(view_, mouse_button_type_, px, + py); mouse_button_type_ = mouse_button_type; } else { LOG_WARN("Unknown mouse event type: %d", event_type); @@ -317,10 +324,9 @@ bool WvWebViewBackend::SendKey(const char* key, const char* string, return false; } - auto& wv = WvInternalApiBinding::GetInstance(); if (strcmp(key, "XF86Back") == 0 && !is_down) { - if (wv.view.BackPossible(view_)) { - wv.view.Back(view_); + if (ftpw_webview_flutter_wv_view_back_possible(view_)) { + ftpw_webview_flutter_wv_view_back(view_); return true; } return false; @@ -333,25 +339,26 @@ bool WvWebViewBackend::SendKey(const char* key, const char* string, key_event.compose = compose; key_event.modifiers = ConvertModifiers(modifiers); key_event.key_code = scan_code; - wv.view.SendKeyEvent(view_, &key_event, is_down ? 1 : 0); + ftpw_webview_flutter_wv_view_send_key_event(view_, &key_event, + is_down ? 1 : 0); return true; } void WvWebViewBackend::Resume() { if (view_) { - WvInternalApiBinding::GetInstance().view.Resume(view_); + ftpw_webview_flutter_wv_view_resume(view_); } } void WvWebViewBackend::Stop() { if (view_) { - WvInternalApiBinding::GetInstance().view.Stop(view_); + ftpw_webview_flutter_wv_view_stop(view_); } } void WvWebViewBackend::SetJavaScriptEnabled(bool enabled) { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.settings.JavaScriptEnabledSet(wv.view.SettingsGet(view_), enabled); + ftpw_webview_flutter_wv_settings_javascript_enabled_set( + ftpw_webview_flutter_wv_view_settings_get(view_), enabled); } void WvWebViewBackend::SetHasNavigationDelegate(bool has_navigation_delegate) { @@ -359,7 +366,7 @@ void WvWebViewBackend::SetHasNavigationDelegate(bool has_navigation_delegate) { } void WvWebViewBackend::LoadUrl(const std::string& url) { - WvInternalApiBinding::GetInstance().view.UrlSet(view_, url.c_str()); + ftpw_webview_flutter_wv_view_url_set(view_, url.c_str()); } bool WvWebViewBackend::LoadUrlRequest( @@ -386,7 +393,7 @@ bool WvWebViewBackend::LoadUrlRequest( strdup(header.second.c_str())); } - bool ret = WvInternalApiBinding::GetInstance().view.UrlRequestSet( + bool ret = ftpw_webview_flutter_wv_view_url_request_set( view_, url.c_str(), wv_method, wv_headers, reinterpret_cast(body.data())); eina_hash_free(wv_headers); @@ -395,32 +402,28 @@ bool WvWebViewBackend::LoadUrlRequest( void WvWebViewBackend::LoadHtmlString(const std::string& html, const std::string& base_url) { - WvInternalApiBinding::GetInstance().view.HtmlStringLoad( - view_, html.c_str(), base_url.c_str(), nullptr); + ftpw_webview_flutter_wv_view_html_string_load(view_, html.c_str(), + base_url.c_str(), nullptr); } bool WvWebViewBackend::CanGoBack() { - return WvInternalApiBinding::GetInstance().view.BackPossible(view_); + return ftpw_webview_flutter_wv_view_back_possible(view_); } bool WvWebViewBackend::CanGoForward() { - return WvInternalApiBinding::GetInstance().view.ForwardPossible(view_); + return ftpw_webview_flutter_wv_view_forward_possible(view_); } -void WvWebViewBackend::GoBack() { - WvInternalApiBinding::GetInstance().view.Back(view_); -} +void WvWebViewBackend::GoBack() { ftpw_webview_flutter_wv_view_back(view_); } void WvWebViewBackend::GoForward() { - WvInternalApiBinding::GetInstance().view.Forward(view_); + ftpw_webview_flutter_wv_view_forward(view_); } -void WvWebViewBackend::Reload() { - WvInternalApiBinding::GetInstance().view.Reload(view_); -} +void WvWebViewBackend::Reload() { ftpw_webview_flutter_wv_view_reload(view_); } std::string WvWebViewBackend::GetCurrentUrl() { - const char* url = WvInternalApiBinding::GetInstance().view.UrlGet(view_); + const char* url = ftpw_webview_flutter_wv_view_url_get(view_); return url ? url : ""; } @@ -429,7 +432,7 @@ void WvWebViewBackend::EvaluateJavaScript( std::function callback) { auto* callback_ptr = new std::function(std::move(callback)); - if (!WvInternalApiBinding::GetInstance().view.ScriptExecute( + if (!ftpw_webview_flutter_wv_view_script_execute( view_, javascript.c_str(), &WvWebViewBackend::OnEvaluateJavaScript, callback_ptr)) { LOG_WARN("wv_view_script_execute failed."); @@ -439,90 +442,84 @@ void WvWebViewBackend::EvaluateJavaScript( } void WvWebViewBackend::RegisterJavaScriptChannel(const std::string& name) { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.view.JavaScriptMessageHandlerAdd( + ftpw_webview_flutter_wv_view_javascript_message_handler_add( view_, &WvWebViewBackend::OnJavaScriptMessage, name.c_str()); } void WvWebViewBackend::ClearCache() { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.context.CacheClear(wv.view.ContextGet(view_)); + ftpw_webview_flutter_wv_context_cache_clear( + ftpw_webview_flutter_wv_view_context_get(view_)); } void WvWebViewBackend::ClearLocalStorage() { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.context.WebStorageDeleteAll(wv.view.ContextGet(view_)); + ftpw_webview_flutter_wv_context_web_storage_delete_all( + ftpw_webview_flutter_wv_view_context_get(view_)); } std::string WvWebViewBackend::GetTitle() { - const char* title = WvInternalApiBinding::GetInstance().view.TitleGet(view_); + const char* title = ftpw_webview_flutter_wv_view_title_get(view_); return title ? title : ""; } void WvWebViewBackend::ScrollTo(int32_t x, int32_t y) { - WvInternalApiBinding::GetInstance().view.ScrollSet(view_, x, y); + ftpw_webview_flutter_wv_view_scroll_set(view_, x, y); } void WvWebViewBackend::ScrollBy(int32_t x, int32_t y) { - WvInternalApiBinding::GetInstance().view.ScrollBy(view_, x, y); + ftpw_webview_flutter_wv_view_scroll_by(view_, x, y); } void WvWebViewBackend::GetScrollPosition(int32_t* x, int32_t* y) { - WvInternalApiBinding::GetInstance().view.ScrollPosGet(view_, x, y); + ftpw_webview_flutter_wv_view_scroll_pos_get(view_, x, y); } void WvWebViewBackend::SetBackgroundColor(int r, int g, int b, int a) { - WvInternalApiBinding::GetInstance().view.BgColorSet(view_, r, g, b, a); + ftpw_webview_flutter_wv_view_bg_color_set(view_, r, g, b, a); } void WvWebViewBackend::SetUserAgent(const std::string& user_agent) { - WvInternalApiBinding::GetInstance().view.UserAgentSet(view_, - user_agent.c_str()); + ftpw_webview_flutter_wv_view_user_agent_set(view_, user_agent.c_str()); } std::string WvWebViewBackend::GetUserAgent() { - const char* user_agent = - WvInternalApiBinding::GetInstance().view.UserAgentGet(view_); + const char* user_agent = ftpw_webview_flutter_wv_view_user_agent_get(view_); return user_agent ? user_agent : ""; } void WvWebViewBackend::EnableZoom(bool enabled) { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.settings.ForceZoomSet(wv.view.SettingsGet(view_), enabled); + ftpw_webview_flutter_wv_settings_force_zoom_set( + ftpw_webview_flutter_wv_view_settings_get(view_), enabled); } void WvWebViewBackend::JavaScriptAlertReply() { - WvInternalApiBinding::GetInstance().view.JavaScriptAlertReply(view_); + ftpw_webview_flutter_wv_view_javascript_alert_reply(view_); } void WvWebViewBackend::JavaScriptConfirmReply(bool result) { - WvInternalApiBinding::GetInstance().view.JavaScriptConfirmReply(view_, - result); + ftpw_webview_flutter_wv_view_javascript_confirm_reply(view_, result); } void WvWebViewBackend::JavaScriptPromptReply(const std::string& result) { - WvInternalApiBinding::GetInstance().view.JavaScriptPromptReply( - view_, result.c_str()); + ftpw_webview_flutter_wv_view_javascript_prompt_reply(view_, result.c_str()); } void WvWebViewBackend::SetScrollbarVisible(bool visible) { scrollbar_enabled_ = visible; - WvInternalApiBinding::GetInstance().view.MainFrameScrollbarVisibleSet( + ftpw_webview_flutter_wv_view_main_frame_scrollbar_visible_set( view_, scrollbar_enabled_); } bool WvWebViewBackend::ClearCookies() { - auto& wv = WvInternalApiBinding::GetInstance(); - wv_cookie_manager_h cookie_manager = - wv.context.CookieManagerGet(wv.view.ContextGet(view_)); + void* cookie_manager = ftpw_webview_flutter_wv_context_cookie_manager_get( + ftpw_webview_flutter_wv_view_context_get(view_)); if (cookie_manager) { - wv.cookie_manager.CookiesClear(cookie_manager); + ftpw_webview_flutter_wv_cookie_manager_cookies_clear(cookie_manager); return true; } return false; } -void WvWebViewBackend::OnFrameRendered(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnFrameRendered(void* obj, void* event_info, void* user_data) { if (event_info) { static_cast(user_data)->delegate_->OnFrameRendered( @@ -530,25 +527,23 @@ void WvWebViewBackend::OnFrameRendered(wv_view_h obj, void* event_info, } } -void WvWebViewBackend::OnLoadStarted(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnLoadStarted(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - auto& wv = WvInternalApiBinding::GetInstance(); - wv.view.MainFrameScrollbarVisibleSet(backend->view_, - backend->scrollbar_enabled_); - const char* url = wv.view.UrlGet(backend->view_); + ftpw_webview_flutter_wv_view_main_frame_scrollbar_visible_set( + backend->view_, backend->scrollbar_enabled_); + const char* url = ftpw_webview_flutter_wv_view_url_get(backend->view_); backend->delegate_->OnLoadStarted(url ? url : ""); } -void WvWebViewBackend::OnLoadFinished(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnLoadFinished(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - const char* url = - WvInternalApiBinding::GetInstance().view.UrlGet(backend->view_); + const char* url = ftpw_webview_flutter_wv_view_url_get(backend->view_); backend->delegate_->OnLoadFinished(url ? url : ""); } -void WvWebViewBackend::OnProgress(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnProgress(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); int32_t progress = @@ -556,53 +551,54 @@ void WvWebViewBackend::OnProgress(wv_view_h obj, void* event_info, backend->delegate_->OnProgress(progress); } -void WvWebViewBackend::OnLoadError(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnLoadError(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - wv_error_h error = static_cast(event_info); - auto& wv = WvInternalApiBinding::GetInstance(); - const char* description = wv.error.DescriptionGet(error); - const char* url = wv.error.UrlGet(error); - backend->delegate_->OnLoadError( - wv.error.CodeGet(error), description ? description : "", url ? url : ""); + void* error = event_info; + const char* description = + ftpw_webview_flutter_wv_error_description_get(error); + const char* url = ftpw_webview_flutter_wv_error_url_get(error); + backend->delegate_->OnLoadError(ftpw_webview_flutter_wv_error_code_get(error), + description ? description : "", + url ? url : ""); } -void WvWebViewBackend::OnConsoleMessage(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnConsoleMessage(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - wv_console_message_h message = static_cast(event_info); - auto& wv = WvInternalApiBinding::GetInstance(); - wv_console_message_level_e log_level = wv.console_message.LevelGet(message); - const char* text = wv.console_message.TextGet(message); + void* message = event_info; + wv_console_message_level_e log_level = + ftpw_webview_flutter_wv_console_message_level_get(message); + const char* text = ftpw_webview_flutter_wv_console_message_text_get(message); backend->delegate_->OnConsoleMessage(ConvertLogLevelToString(log_level), text ? text : ""); } -void WvWebViewBackend::OnNavigationPolicy(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnNavigationPolicy(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - wv_policy_decision_h policy_decision = - static_cast(event_info); - auto& wv = WvInternalApiBinding::GetInstance(); - wv.policy_decision.Use(policy_decision); + void* policy_decision = event_info; + ftpw_webview_flutter_wv_policy_decision_use(policy_decision); if (!backend->has_navigation_delegate_) { return; } - wv.view.Suspend(backend->view_); - const char* url = wv.policy_decision.UrlGet(policy_decision); + ftpw_webview_flutter_wv_view_suspend(backend->view_); + const char* url = + ftpw_webview_flutter_wv_policy_decision_url_get(policy_decision); backend->delegate_->OnNavigationPolicyDecide(url ? url : ""); } -void WvWebViewBackend::OnResponsePolicy(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnResponsePolicy(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - wv_policy_decision_h policy_decision = - static_cast(event_info); - auto& wv = WvInternalApiBinding::GetInstance(); - int status_code = wv.policy_decision.ResponseStatusCodeGet(policy_decision); - const char* url = wv.policy_decision.UrlGet(policy_decision); - wv.policy_decision.Use(policy_decision); + void* policy_decision = event_info; + int status_code = + ftpw_webview_flutter_wv_policy_decision_response_status_code_get( + policy_decision); + const char* url = + ftpw_webview_flutter_wv_policy_decision_url_get(policy_decision); + ftpw_webview_flutter_wv_policy_decision_use(policy_decision); if (!backend->has_navigation_delegate_ || status_code < 400) { return; @@ -610,16 +606,14 @@ void WvWebViewBackend::OnResponsePolicy(wv_view_h obj, void* event_info, backend->delegate_->OnResponsePolicyDecide(url ? url : "", status_code); } -void WvWebViewBackend::OnUrlChange(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnUrlChange(void* obj, void* event_info, void* user_data) { WvWebViewBackend* backend = static_cast(user_data); - const char* url = - WvInternalApiBinding::GetInstance().view.UrlGet(backend->view_); + const char* url = ftpw_webview_flutter_wv_view_url_get(backend->view_); backend->delegate_->OnUrlChanged(url ? url : ""); } -void WvWebViewBackend::OnEvaluateJavaScript(wv_view_h obj, - const char* result_value, +void WvWebViewBackend::OnEvaluateJavaScript(void* obj, const char* result_value, void* user_data) { auto* callback = static_cast*>(user_data); @@ -627,7 +621,7 @@ void WvWebViewBackend::OnEvaluateJavaScript(wv_view_h obj, delete callback; } -void WvWebViewBackend::OnJavaScriptMessage(wv_view_h obj, +void WvWebViewBackend::OnJavaScriptMessage(void* obj, wv_script_message_s message) { WvWebViewBackend* backend = nullptr; { @@ -643,35 +637,30 @@ void WvWebViewBackend::OnJavaScriptMessage(wv_view_h obj, } } -bool WvWebViewBackend::OnJavaScriptAlertDialog(wv_view_h view, - const char* message, +bool WvWebViewBackend::OnJavaScriptAlertDialog(void* view, const char* message, void* data) { WvWebViewBackend* backend = static_cast(data); - const char* url = - WvInternalApiBinding::GetInstance().view.UrlGet(backend->view_); + const char* url = ftpw_webview_flutter_wv_view_url_get(backend->view_); backend->delegate_->OnJavaScriptAlertDialog(message ? message : "", url ? url : ""); return true; } -bool WvWebViewBackend::OnJavaScriptConfirmDialog(wv_view_h view, +bool WvWebViewBackend::OnJavaScriptConfirmDialog(void* view, const char* message, void* data) { WvWebViewBackend* backend = static_cast(data); - const char* url = - WvInternalApiBinding::GetInstance().view.UrlGet(backend->view_); + const char* url = ftpw_webview_flutter_wv_view_url_get(backend->view_); backend->delegate_->OnJavaScriptConfirmDialog(message ? message : "", url ? url : ""); return true; } -bool WvWebViewBackend::OnJavaScriptPromptDialog(wv_view_h view, - const char* message, +bool WvWebViewBackend::OnJavaScriptPromptDialog(void* view, const char* message, const char* default_text, void* data) { WvWebViewBackend* backend = static_cast(data); - const char* url = - WvInternalApiBinding::GetInstance().view.UrlGet(backend->view_); + const char* url = ftpw_webview_flutter_wv_view_url_get(backend->view_); backend->delegate_->OnJavaScriptPromptDialog( message ? message : "", default_text ? default_text : "", url ? url : ""); return true; diff --git a/packages/webview_flutter/tizen/src/wv_webview_backend.h b/packages/webview_flutter/tizen/src/wv_webview_backend.h index 47b6a7220..d68fec686 100644 --- a/packages/webview_flutter/tizen/src/wv_webview_backend.h +++ b/packages/webview_flutter/tizen/src/wv_webview_backend.h @@ -12,8 +12,8 @@ #include #include +#include "ftpw_webview_flutter.h" #include "webview_backend.h" -#include "wv_internal_api_binding.h" class WvWebViewBackend : public WebViewBackend { public: @@ -75,26 +75,23 @@ class WvWebViewBackend : public WebViewBackend { static void GlobalShutdown(); private: - static void OnFrameRendered(wv_view_h obj, void* event_info, void* user_data); - static void OnLoadStarted(wv_view_h obj, void* event_info, void* user_data); - static void OnLoadFinished(wv_view_h obj, void* event_info, void* user_data); - static void OnProgress(wv_view_h obj, void* event_info, void* user_data); - static void OnLoadError(wv_view_h obj, void* event_info, void* user_data); - static void OnConsoleMessage(wv_view_h obj, void* event_info, - void* user_data); - static void OnNavigationPolicy(wv_view_h obj, void* event_info, - void* user_data); - static void OnResponsePolicy(wv_view_h obj, void* event_info, - void* user_data); - static void OnUrlChange(wv_view_h obj, void* event_info, void* user_data); - static void OnEvaluateJavaScript(wv_view_h obj, const char* result_value, + static void OnFrameRendered(void* obj, void* event_info, void* user_data); + static void OnLoadStarted(void* obj, void* event_info, void* user_data); + static void OnLoadFinished(void* obj, void* event_info, void* user_data); + static void OnProgress(void* obj, void* event_info, void* user_data); + static void OnLoadError(void* obj, void* event_info, void* user_data); + static void OnConsoleMessage(void* obj, void* event_info, void* user_data); + static void OnNavigationPolicy(void* obj, void* event_info, void* user_data); + static void OnResponsePolicy(void* obj, void* event_info, void* user_data); + static void OnUrlChange(void* obj, void* event_info, void* user_data); + static void OnEvaluateJavaScript(void* obj, const char* result_value, void* user_data); - static void OnJavaScriptMessage(wv_view_h obj, wv_script_message_s message); - static bool OnJavaScriptAlertDialog(wv_view_h view, const char* message, + static void OnJavaScriptMessage(void* obj, wv_script_message_s message); + static bool OnJavaScriptAlertDialog(void* view, const char* message, void* data); - static bool OnJavaScriptConfirmDialog(wv_view_h view, const char* message, + static bool OnJavaScriptConfirmDialog(void* view, const char* message, void* data); - static bool OnJavaScriptPromptDialog(wv_view_h view, const char* message, + static bool OnJavaScriptPromptDialog(void* view, const char* message, const char* default_text, void* data); void SendTouchEvent(int type, double x, double y); @@ -103,7 +100,7 @@ class WvWebViewBackend : public WebViewBackend { Delegate* delegate_; bool scrollbar_enabled_ = true; - wv_view_h view_ = nullptr; + void* view_ = nullptr; void* window_ = nullptr; bool has_navigation_delegate_ = false; wv_mouse_button_type_e mouse_button_type_ =