diff --git a/packages/flutter_inappwebview/CHANGELOG.md b/packages/flutter_inappwebview/CHANGELOG.md index eaacca998..96b137659 100644 --- a/packages/flutter_inappwebview/CHANGELOG.md +++ b/packages/flutter_inappwebview/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.3.0 +- Use wrapper APIs for the EWK and WV backends. - Move the native web engine code behind a `WebViewBackend` interface. - Add an experimental WV API backend with EWK-wrapper and standalone modes. - Select EWK through Tizen 10.0, WV EWK-wrapper mode on Tizen 10.1, and WV standalone mode from Tizen 11.0. diff --git a/packages/flutter_inappwebview/tizen/inc/ftpw_flutter_inappwebview.h b/packages/flutter_inappwebview/tizen/inc/ftpw_flutter_inappwebview.h new file mode 100644 index 000000000..8b343f2a0 --- /dev/null +++ b/packages/flutter_inappwebview/tizen/inc/ftpw_flutter_inappwebview.h @@ -0,0 +1,300 @@ +// 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_FLUTTER_INAPPWEBVIEW_H_ +#define FLUTTER_TIZEN_PLUGINS_WRAPPER_FLUTTER_INAPPWEBVIEW_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_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; + const char* device_name; +} wv_key_event_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 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_flutter_inappwebview_ewk_view_bg_color_set(void* obj, int r, + int g, int b, + int a); +unsigned char ftpw_flutter_inappwebview_ewk_view_touch_events_enabled_set( + void* view, unsigned char enabled); +unsigned char ftpw_flutter_inappwebview_ewk_view_feed_touch_event( + void* obj, Ewk_Touch_Event_Type type, const void* points, + const void* modifiers); +unsigned char ftpw_flutter_inappwebview_ewk_view_mouse_events_enabled_set( + void* view, unsigned char enabled); +unsigned char ftpw_flutter_inappwebview_ewk_view_feed_mouse_down( + void* obj, Ewk_Mouse_Button_Type button, int x, int y); +unsigned char ftpw_flutter_inappwebview_ewk_view_feed_mouse_up( + void* obj, Ewk_Mouse_Button_Type button, int x, int y); +unsigned char ftpw_flutter_inappwebview_ewk_view_feed_mouse_wheel( + void* obj, unsigned char y_direction, int step, int x, int y); +unsigned char ftpw_flutter_inappwebview_ewk_view_send_key_event( + void* obj, void* key_event, unsigned char is_press); +void ftpw_flutter_inappwebview_ewk_view_offscreen_rendering_enabled_set( + void* obj, unsigned char enabled); +void ftpw_flutter_inappwebview_ewk_view_ime_window_set(void* obj, void* window); +unsigned char ftpw_flutter_inappwebview_ewk_view_key_events_enabled_set( + void* obj, unsigned char enabled); +unsigned char ftpw_flutter_inappwebview_ewk_view_set_support_video_hole( + void* obj, void* window, unsigned char enabled, unsigned char is_supported); +void ftpw_flutter_inappwebview_ewk_view_javascript_alert_callback_set( + void* o, Ewk_View_JavaScript_Alert_Callback callback, void* user_data); +void ftpw_flutter_inappwebview_ewk_view_javascript_confirm_callback_set( + void* o, Ewk_View_JavaScript_Confirm_Callback callback, void* user_data); +void ftpw_flutter_inappwebview_ewk_view_javascript_prompt_callback_set( + void* o, Ewk_View_JavaScript_Prompt_Callback callback, void* user_data); +void ftpw_flutter_inappwebview_ewk_view_javascript_alert_reply(void* o); +void ftpw_flutter_inappwebview_ewk_view_javascript_confirm_reply( + void* o, unsigned char result); +void ftpw_flutter_inappwebview_ewk_view_javascript_prompt_reply( + void* o, const char* result); +void ftpw_flutter_inappwebview_ewk_set_arguments(int argc, char** argv); +void ftpw_flutter_inappwebview_ewk_settings_ime_panel_enabled_set( + void* settings, unsigned char enabled); +void ftpw_flutter_inappwebview_ewk_settings_force_zoom_set( + void* settings, unsigned char enable); +Ewk_Console_Message_Level +ftpw_flutter_inappwebview_ewk_console_message_level_get(const void* message); +const char* ftpw_flutter_inappwebview_ewk_console_message_text_get( + const void* message); + +int ftpw_flutter_inappwebview_wv_init(void); +int ftpw_flutter_inappwebview_wv_shutdown(void); +int ftpw_flutter_inappwebview_wv_set_arguments(int argc, const char** argv); +void* ftpw_flutter_inappwebview_wv_view_create(void); +void ftpw_flutter_inappwebview_wv_view_destroy(void* view); +void ftpw_flutter_inappwebview_wv_view_resize(void* view, int w, int h); +bool ftpw_flutter_inappwebview_wv_view_focus_set(void* view, int focused); +bool ftpw_flutter_inappwebview_wv_view_url_set(void* view, const char* url); +const char* ftpw_flutter_inappwebview_wv_view_url_get(void* view); +bool ftpw_flutter_inappwebview_wv_view_url_request_set(void* view, + const char* url, + wv_http_method_e method, + void* headers, + const char* body); +bool ftpw_flutter_inappwebview_wv_view_html_string_load( + void* view, const char* html, const char* base_url, + const char* unreachable_url); +bool ftpw_flutter_inappwebview_wv_view_back_possible(void* view); +bool ftpw_flutter_inappwebview_wv_view_forward_possible(void* view); +bool ftpw_flutter_inappwebview_wv_view_back(void* view); +bool ftpw_flutter_inappwebview_wv_view_forward(void* view); +bool ftpw_flutter_inappwebview_wv_view_reload(void* view); +bool ftpw_flutter_inappwebview_wv_view_stop(void* view); +void ftpw_flutter_inappwebview_wv_view_suspend(void* view); +void ftpw_flutter_inappwebview_wv_view_resume(void* view); +const char* ftpw_flutter_inappwebview_wv_view_title_get(void* view); +double ftpw_flutter_inappwebview_wv_view_load_progress_get(void* view); +bool ftpw_flutter_inappwebview_wv_view_scale_set(void* view, + double scale_factor, int cx, + int cy); +double ftpw_flutter_inappwebview_wv_view_scale_get(void* view); +bool ftpw_flutter_inappwebview_wv_view_user_agent_set(void* view, + const char* user_agent); +const char* ftpw_flutter_inappwebview_wv_view_user_agent_get(void* view); +bool ftpw_flutter_inappwebview_wv_view_scroll_set(void* view, int x, int y); +bool ftpw_flutter_inappwebview_wv_view_scroll_pos_get(void* view, int* x, + int* y); +bool ftpw_flutter_inappwebview_wv_view_script_execute( + void* view, const char* script, wv_view_script_execute_cb callback, + void* user_data); +bool ftpw_flutter_inappwebview_wv_view_bg_color_set(void* view, int r, int g, + int b, int a); +void* ftpw_flutter_inappwebview_wv_view_context_get(void* view); +void* ftpw_flutter_inappwebview_wv_view_settings_get(void* view); +bool ftpw_flutter_inappwebview_wv_view_feed_touch_event( + void* view, wv_touch_event_type_e event_type, void* points, + wv_modifier_e modifiers); +int ftpw_flutter_inappwebview_wv_view_feed_mouse_down( + void* view, wv_mouse_button_type_e button, int x, int y); +int ftpw_flutter_inappwebview_wv_view_feed_mouse_up( + void* view, wv_mouse_button_type_e button, int x, int y); +int ftpw_flutter_inappwebview_wv_view_feed_mouse_wheel(void* view, + bool y_direction, + int step, int x, int y); +bool ftpw_flutter_inappwebview_wv_view_send_key_event( + void* view, const wv_key_event_s* key_event, int is_press); +bool ftpw_flutter_inappwebview_wv_view_touch_events_enabled_set(void* view, + int enabled); +bool ftpw_flutter_inappwebview_wv_view_mouse_events_enabled_set(void* view, + bool enabled); +bool ftpw_flutter_inappwebview_wv_view_key_events_enabled_set(void* view, + bool enabled); +void ftpw_flutter_inappwebview_wv_view_ime_window_set(void* view, void* window); +int ftpw_flutter_inappwebview_wv_view_add_cb(void* view, const char* event, + wv_view_cb func, + const void* user_data); +int ftpw_flutter_inappwebview_wv_view_remove_full_cb(void* view, + const char* event, + wv_view_cb func, + const void* user_data); +int ftpw_flutter_inappwebview_wv_view_javascript_alert_callback_set( + void* view, wv_view_javascript_alert_cb callback, void* user_data); +int ftpw_flutter_inappwebview_wv_view_javascript_confirm_callback_set( + void* view, wv_view_javascript_confirm_cb callback, void* user_data); +int ftpw_flutter_inappwebview_wv_view_javascript_prompt_callback_set( + void* view, wv_view_javascript_prompt_cb callback, void* user_data); +void ftpw_flutter_inappwebview_wv_view_javascript_alert_reply(void* view); +void ftpw_flutter_inappwebview_wv_view_javascript_confirm_reply(void* view, + bool result); +void ftpw_flutter_inappwebview_wv_view_javascript_prompt_reply( + void* view, const char* result); +bool ftpw_flutter_inappwebview_wv_view_set_support_video_hole( + void* view, void* window, bool enable, bool is_video_window); +bool ftpw_flutter_inappwebview_wv_view_main_frame_scrollbar_visible_set( + void* view, bool visible); +void* ftpw_flutter_inappwebview_wv_context_cookie_manager_get(void* context); +bool ftpw_flutter_inappwebview_wv_context_cache_model_set( + void* context, wv_cache_model_e model); +bool ftpw_flutter_inappwebview_wv_context_cache_clear(void* context); +void ftpw_flutter_inappwebview_wv_cookie_manager_accept_policy_set( + void* manager, wv_cookie_accept_policy_e policy); +void ftpw_flutter_inappwebview_wv_cookie_manager_cookies_clear(void* manager); +bool ftpw_flutter_inappwebview_wv_settings_javascript_enabled_set( + void* settings, bool enable); +void ftpw_flutter_inappwebview_wv_settings_ime_panel_enabled_set(void* settings, + bool enable); +bool ftpw_flutter_inappwebview_wv_settings_force_zoom_set(void* settings, + bool enable); +int ftpw_flutter_inappwebview_wv_error_code_get(void* error); +const char* ftpw_flutter_inappwebview_wv_error_description_get(void* error); +const char* ftpw_flutter_inappwebview_wv_error_url_get(void* error); +bool ftpw_flutter_inappwebview_wv_policy_decision_use(void* policy_decision); +const char* ftpw_flutter_inappwebview_wv_policy_decision_url_get( + void* policy_decision); +wv_console_message_level_e +ftpw_flutter_inappwebview_wv_console_message_level_get(void* message); +const char* ftpw_flutter_inappwebview_wv_console_message_text_get( + void* message); + +#ifdef __cplusplus +} +#endif + +#endif // FLUTTER_TIZEN_PLUGINS_WRAPPER_FLUTTER_INAPPWEBVIEW_H_ diff --git a/packages/flutter_inappwebview/tizen/lib/aarch64/libftpw_flutter_inappwebview.so b/packages/flutter_inappwebview/tizen/lib/aarch64/libftpw_flutter_inappwebview.so new file mode 100755 index 000000000..40fbbc1a4 Binary files /dev/null and b/packages/flutter_inappwebview/tizen/lib/aarch64/libftpw_flutter_inappwebview.so differ diff --git a/packages/flutter_inappwebview/tizen/lib/armel/libftpw_flutter_inappwebview.so b/packages/flutter_inappwebview/tizen/lib/armel/libftpw_flutter_inappwebview.so new file mode 100755 index 000000000..c68a9dc8c Binary files /dev/null and b/packages/flutter_inappwebview/tizen/lib/armel/libftpw_flutter_inappwebview.so differ diff --git a/packages/flutter_inappwebview/tizen/lib/i586/libftpw_flutter_inappwebview.so b/packages/flutter_inappwebview/tizen/lib/i586/libftpw_flutter_inappwebview.so new file mode 100755 index 000000000..29e8a75ef Binary files /dev/null and b/packages/flutter_inappwebview/tizen/lib/i586/libftpw_flutter_inappwebview.so differ diff --git a/packages/flutter_inappwebview/tizen/lib/x86_64/libftpw_flutter_inappwebview.so b/packages/flutter_inappwebview/tizen/lib/x86_64/libftpw_flutter_inappwebview.so new file mode 100755 index 000000000..8b84d7898 Binary files /dev/null and b/packages/flutter_inappwebview/tizen/lib/x86_64/libftpw_flutter_inappwebview.so differ diff --git a/packages/flutter_inappwebview/tizen/project_def.prop b/packages/flutter_inappwebview/tizen/project_def.prop index c09310f67..df6623c8e 100644 --- a/packages/flutter_inappwebview/tizen/project_def.prop +++ b/packages/flutter_inappwebview/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_flutter_inappwebview diff --git a/packages/flutter_inappwebview/tizen/src/ewk_internal_api_binding.cc b/packages/flutter_inappwebview/tizen/src/ewk_internal_api_binding.cc deleted file mode 100644 index ae09096af..000000000 --- a/packages/flutter_inappwebview/tizen/src/ewk_internal_api_binding.cc +++ /dev/null @@ -1,134 +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 "ewk_internal_api_binding.h" - -#include - -#include "log.h" - -namespace { - -template -T ResolveEwkSymbol(void* handle, const char* symbol) { - dlerror(); - void* value = dlsym(handle, symbol); - const char* error = dlerror(); - if (error || !value) { - LOG_ERROR("Failed to resolve EWK symbol %s: %s", symbol, - error ? error : "not found"); - return nullptr; - } - return reinterpret_cast(value); -} - -} // namespace - -EwkInternalApiBinding::EwkInternalApiBinding() { - handle_ = dlopen("libchromium-ewk.so", RTLD_LAZY); - if (!handle_) { - const char* error = dlerror(); - LOG_ERROR("Failed to open libchromium-ewk.so: %s", - error ? error : "unknown error"); - } -} - -EwkInternalApiBinding::~EwkInternalApiBinding() { - if (handle_) { - dlclose(handle_); - } -} - -bool EwkInternalApiBinding::Initialize() { - if (initialize_result_.has_value()) { - return *initialize_result_; - } - - if (!handle_) { - LOG_ERROR( - "EWK internal API binding was initialized without a library handle."); - initialize_result_ = false; - return false; - } - - // ewk_view - view.SetBackgroundColor = ResolveEwkSymbol( - handle_, "ewk_view_bg_color_set"); - view.TouchEventsEnabledSet = - ResolveEwkSymbol( - handle_, "ewk_view_touch_events_enabled_set"); - view.FeedTouchEvent = ResolveEwkSymbol( - handle_, "ewk_view_feed_touch_event"); - view.MouseEventsEnabledSet = - ResolveEwkSymbol( - handle_, "ewk_view_mouse_events_enabled_set"); - view.FeedMouseDown = ResolveEwkSymbol( - handle_, "ewk_view_feed_mouse_down"); - view.FeedMouseUp = ResolveEwkSymbol( - handle_, "ewk_view_feed_mouse_up"); - view.FeedMouseWheel = ResolveEwkSymbol( - handle_, "ewk_view_feed_mouse_wheel"); - view.SendKeyEvent = ResolveEwkSymbol( - handle_, "ewk_view_send_key_event"); - view.OffscreenRenderingEnabledSet = - ResolveEwkSymbol( - handle_, "ewk_view_offscreen_rendering_enabled_set"); - view.ImeWindowSet = ResolveEwkSymbol( - handle_, "ewk_view_ime_window_set"); - view.KeyEventsEnabledSet = ResolveEwkSymbol( - handle_, "ewk_view_key_events_enabled_set"); - view.SupportVideoHoleSet = ResolveEwkSymbol( - handle_, "ewk_view_set_support_video_hole"); - - view.OnJavaScriptAlert = - ResolveEwkSymbol( - handle_, "ewk_view_javascript_alert_callback_set"); - view.OnJavaScriptConfirm = - ResolveEwkSymbol( - handle_, "ewk_view_javascript_confirm_callback_set"); - view.OnJavaScriptPrompt = - ResolveEwkSymbol( - handle_, "ewk_view_javascript_prompt_callback_set"); - - view.JavaScriptAlertReply = - ResolveEwkSymbol( - handle_, "ewk_view_javascript_alert_reply"); - view.JavaScriptConfirmReply = - ResolveEwkSymbol( - handle_, "ewk_view_javascript_confirm_reply"); - view.JavaScriptPromptReply = - ResolveEwkSymbol( - handle_, "ewk_view_javascript_prompt_reply"); - - // ewk_main - main.SetArguments = - ResolveEwkSymbol(handle_, "ewk_set_arguments"); - - // ewk_settings - settings.ImePanelEnabledSet = - ResolveEwkSymbol( - handle_, "ewk_settings_ime_panel_enabled_set"); - settings.ForceZoomSet = ResolveEwkSymbol( - handle_, "ewk_settings_force_zoom_set"); - - // ewk_console_message - console_message.LevelGet = ResolveEwkSymbol( - handle_, "ewk_console_message_level_get"); - console_message.TextGet = ResolveEwkSymbol( - handle_, "ewk_console_message_text_get"); - - initialize_result_ = view.SetBackgroundColor && view.TouchEventsEnabledSet && - view.FeedTouchEvent && view.MouseEventsEnabledSet && - view.FeedMouseDown && view.FeedMouseUp && - view.FeedMouseWheel && view.SendKeyEvent && - view.OffscreenRenderingEnabledSet && view.ImeWindowSet && - view.KeyEventsEnabledSet && view.SupportVideoHoleSet && - view.OnJavaScriptAlert && view.OnJavaScriptConfirm && - view.OnJavaScriptPrompt && view.JavaScriptAlertReply && - view.JavaScriptConfirmReply && - view.JavaScriptPromptReply && main.SetArguments && - settings.ImePanelEnabledSet && settings.ForceZoomSet && - console_message.LevelGet && console_message.TextGet; - return *initialize_result_; -} diff --git a/packages/flutter_inappwebview/tizen/src/ewk_internal_api_binding.h b/packages/flutter_inappwebview/tizen/src/ewk_internal_api_binding.h deleted file mode 100644 index f101e5827..000000000 --- a/packages/flutter_inappwebview/tizen/src/ewk_internal_api_binding.h +++ /dev/null @@ -1,176 +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_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 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 (*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 (*EwkViewSupportVideoHoleSetFnPtr)(Evas_Object* obj, - void* window, - Eina_Bool enabled, - Eina_Bool is_supported); -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 struct { - EwkViewBgColorSetFnPtr SetBackgroundColor = nullptr; - EwkViewTouchEventsEnabledSetFnPtr TouchEventsEnabledSet = nullptr; - EwkViewFeedTouchEventFnPtr FeedTouchEvent = nullptr; - EwkViewMouseEventsEnabledSetFnPtr MouseEventsEnabledSet = nullptr; - EwkViewFeedMouseDownFnPtr FeedMouseDown = nullptr; - EwkViewFeedMouseUpFnPtr FeedMouseUp = nullptr; - EwkViewFeedMouseWheelFnPtr FeedMouseWheel = nullptr; - EwkViewSendKeyEventFnPtr SendKeyEvent = nullptr; - EwkViewOffscreenRenderingEnabledSetFnPtr OffscreenRenderingEnabledSet = - nullptr; - EwkViewImeWindowSetFnPtr ImeWindowSet = nullptr; - EwkViewKeyEventsEnabledSetFnPtr KeyEventsEnabledSet = nullptr; - EwkViewSupportVideoHoleSetFnPtr SupportVideoHoleSet = nullptr; - EwkViewJavaScriptAlertCallbackSetFnPtr OnJavaScriptAlert = nullptr; - EwkViewJavaScriptConfirmCallbackSetFnPtr OnJavaScriptConfirm = nullptr; - EwkViewJavaScriptPromptCallbackSetFnPtr OnJavaScriptPrompt = nullptr; - EwkViewJavaScriptAlertReplyFnPtr JavaScriptAlertReply = nullptr; - EwkViewJavaScriptConfirmReplyFnPtr JavaScriptConfirmReply = nullptr; - EwkViewJavaScriptPromptReplyFnPtr JavaScriptPromptReply = nullptr; - -} EwkViewProcTable; - -typedef void (*EwkSetArgumentsFnPtr)(int argc, char** argv); - -typedef struct { - EwkSetArgumentsFnPtr SetArguments = 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 struct { - EwkConsoleMessageLevelGetFnPtr LevelGet = nullptr; - EwkConsoleMessageTextGetFnPtr TextGet = nullptr; -} EwkConsoleMessageProcTable; - -class EwkInternalApiBinding { - public: - static EwkInternalApiBinding& GetInstance() { - static EwkInternalApiBinding instance = EwkInternalApiBinding(); - return instance; - } - - ~EwkInternalApiBinding(); - - EwkInternalApiBinding(const EwkInternalApiBinding&) = delete; - EwkInternalApiBinding& operator=(const EwkInternalApiBinding&) = delete; - - 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/flutter_inappwebview/tizen/src/ewk_webview_backend.cc b/packages/flutter_inappwebview/tizen/src/ewk_webview_backend.cc index 762b9db7a..aaabcf5d5 100644 --- a/packages/flutter_inappwebview/tizen/src/ewk_webview_backend.cc +++ b/packages/flutter_inappwebview/tizen/src/ewk_webview_backend.cc @@ -79,8 +79,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_flutter_inappwebview_ewk_set_arguments(chromium_argc, chromium_argv); }); Ecore_Evas* evas = GetOffscreenHost(); @@ -95,8 +94,8 @@ 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_flutter_inappwebview_ewk_view_offscreen_rendering_enabled_set(view_, + true); Ewk_Context* context = ewk_view_context_get(view_); if (context) { @@ -111,30 +110,30 @@ bool EwkWebViewBackend::Create(double width, double height, void* window) { LOG_WARN("Unable to access the EWK context; skipping cookie/cache setup."); } - EwkInternalApiBinding::GetInstance().settings.ImePanelEnabledSet( + ftpw_flutter_inappwebview_ewk_settings_ime_panel_enabled_set( ewk_view_settings_get(view_), true); - EwkInternalApiBinding::GetInstance().settings.ForceZoomSet( + ftpw_flutter_inappwebview_ewk_settings_force_zoom_set( ewk_view_settings_get(view_), true); - EwkInternalApiBinding::GetInstance().view.ImeWindowSet(view_, window); - EwkInternalApiBinding::GetInstance().view.KeyEventsEnabledSet(view_, true); + ftpw_flutter_inappwebview_ewk_view_ime_window_set(view_, window); + ftpw_flutter_inappwebview_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_flutter_inappwebview_ewk_view_touch_events_enabled_set(view_, true); + ftpw_flutter_inappwebview_ewk_view_mouse_events_enabled_set(view_, false); #else - EwkInternalApiBinding::GetInstance().view.TouchEventsEnabledSet(view_, false); - EwkInternalApiBinding::GetInstance().view.MouseEventsEnabledSet(view_, true); + ftpw_flutter_inappwebview_ewk_view_touch_events_enabled_set(view_, false); + ftpw_flutter_inappwebview_ewk_view_mouse_events_enabled_set(view_, true); #endif - EwkInternalApiBinding::GetInstance().view.OnJavaScriptAlert( + ftpw_flutter_inappwebview_ewk_view_javascript_alert_callback_set( view_, &EwkWebViewBackend::OnJavaScriptAlertDialog, this); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptConfirm( + ftpw_flutter_inappwebview_ewk_view_javascript_confirm_callback_set( view_, &EwkWebViewBackend::OnJavaScriptConfirmDialog, this); - EwkInternalApiBinding::GetInstance().view.OnJavaScriptPrompt( + ftpw_flutter_inappwebview_ewk_view_javascript_prompt_callback_set( view_, &EwkWebViewBackend::OnJavaScriptPromptDialog, this); #ifdef TV_PROFILE - EwkInternalApiBinding::GetInstance().view.SupportVideoHoleSet(view_, window, - true, false); + ftpw_flutter_inappwebview_ewk_view_set_support_video_hole(view_, window, true, + false); #endif evas_object_smart_callback_add(view_, "offscreen,frame,rendered", @@ -196,16 +195,12 @@ Evas_Object* EwkWebViewBackend::DetachView() { evas_object_smart_callback_del(instance, "title,changed", &EwkWebViewBackend::OnTitleChange); - auto& ewk_view = EwkInternalApiBinding::GetInstance().view; - if (ewk_view.OnJavaScriptAlert) { - ewk_view.OnJavaScriptAlert(instance, nullptr, nullptr); - } - if (ewk_view.OnJavaScriptConfirm) { - ewk_view.OnJavaScriptConfirm(instance, nullptr, nullptr); - } - if (ewk_view.OnJavaScriptPrompt) { - ewk_view.OnJavaScriptPrompt(instance, nullptr, nullptr); - } + ftpw_flutter_inappwebview_ewk_view_javascript_alert_callback_set( + instance, nullptr, nullptr); + ftpw_flutter_inappwebview_ewk_view_javascript_confirm_callback_set( + instance, nullptr, nullptr); + ftpw_flutter_inappwebview_ewk_view_javascript_prompt_callback_set( + instance, nullptr, nullptr); evas_object_data_del(instance, kEwkInstance); @@ -269,8 +264,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_flutter_inappwebview_ewk_view_feed_touch_event(view_, mouse_event_type, + points, 0); eina_list_free(points); delete point; } @@ -296,16 +291,16 @@ void EwkWebViewBackend::SendMouseEvent(int event_type, int button_type, if (event_type == 0) { // down event mouse_button_type_ = mouse_button_type; - EwkInternalApiBinding::GetInstance().view.FeedMouseDown( + ftpw_flutter_inappwebview_ewk_view_feed_mouse_down( view_, mouse_button_type_, px, py); } else if (event_type == 1) { if (dy != 0) { - EwkInternalApiBinding::GetInstance().view.FeedMouseWheel( + ftpw_flutter_inappwebview_ewk_view_feed_mouse_wheel( view_, true, dy > 0 ? 1 : -1, px, py); } } else if (event_type == 2) { // up event - EwkInternalApiBinding::GetInstance().view.FeedMouseUp( - view_, mouse_button_type_, px, py); + ftpw_flutter_inappwebview_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); @@ -332,14 +327,14 @@ bool EwkWebViewBackend::SendKey(const char* key, const char* string, Evas_Event_Key_Down down_event = {}; down_event.key = key; down_event.string = string; - EwkInternalApiBinding::GetInstance().view.SendKeyEvent(view_, &down_event, - is_down); + ftpw_flutter_inappwebview_ewk_view_send_key_event(view_, &down_event, + is_down); } else { Evas_Event_Key_Up up_event = {}; up_event.key = key; up_event.string = string; - EwkInternalApiBinding::GetInstance().view.SendKeyEvent(view_, &up_event, - is_down); + ftpw_flutter_inappwebview_ewk_view_send_key_event(view_, &up_event, + is_down); } return true; } @@ -461,8 +456,7 @@ void EwkWebViewBackend::GetScrollPosition(int32_t* x, int32_t* y) { } void EwkWebViewBackend::SetBackgroundColor(int r, int g, int b, int a) { - EwkInternalApiBinding::GetInstance().view.SetBackgroundColor(view_, r, g, b, - a); + ftpw_flutter_inappwebview_ewk_view_bg_color_set(view_, r, g, b, a); } void EwkWebViewBackend::SetUserAgent(const std::string& user_agent) { @@ -474,22 +468,20 @@ std::string EwkWebViewBackend::GetUserAgent() { } void EwkWebViewBackend::EnableZoom(bool enabled) { - EwkInternalApiBinding::GetInstance().settings.ForceZoomSet( + ftpw_flutter_inappwebview_ewk_settings_force_zoom_set( ewk_view_settings_get(view_), enabled); } void EwkWebViewBackend::JavaScriptAlertReply() { - EwkInternalApiBinding::GetInstance().view.JavaScriptAlertReply(view_); + ftpw_flutter_inappwebview_ewk_view_javascript_alert_reply(view_); } void EwkWebViewBackend::JavaScriptConfirmReply(bool result) { - EwkInternalApiBinding::GetInstance().view.JavaScriptConfirmReply(view_, - result); + ftpw_flutter_inappwebview_ewk_view_javascript_confirm_reply(view_, result); } void EwkWebViewBackend::JavaScriptPromptReply(const char* result) { - EwkInternalApiBinding::GetInstance().view.JavaScriptPromptReply(view_, - result); + ftpw_flutter_inappwebview_ewk_view_javascript_prompt_reply(view_, result); } bool EwkWebViewBackend::ClearCookies() { @@ -573,11 +565,11 @@ 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); + void* message = event_info; Ewk_Console_Message_Level log_level = - EwkInternalApiBinding::GetInstance().console_message.LevelGet(message); - std::string text = ToString( - EwkInternalApiBinding::GetInstance().console_message.TextGet(message)); + ftpw_flutter_inappwebview_ewk_console_message_level_get(message); + std::string text = + ToString(ftpw_flutter_inappwebview_ewk_console_message_text_get(message)); backend->delegate_->OnConsoleMessage(ConvertLogLevelToString(log_level), text); } @@ -619,7 +611,7 @@ void EwkWebViewBackend::OnEvaluateJavaScript(Evas_Object* obj, delete callback; } -Eina_Bool EwkWebViewBackend::OnJavaScriptAlertDialog(Evas_Object* o, +Eina_Bool EwkWebViewBackend::OnJavaScriptAlertDialog(void* o, const char* message, void* data) { EwkWebViewBackend* backend = static_cast(data); @@ -628,7 +620,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); @@ -637,7 +629,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/flutter_inappwebview/tizen/src/ewk_webview_backend.h b/packages/flutter_inappwebview/tizen/src/ewk_webview_backend.h index 60eac989b..ead5e03f0 100644 --- a/packages/flutter_inappwebview/tizen/src/ewk_webview_backend.h +++ b/packages/flutter_inappwebview/tizen/src/ewk_webview_backend.h @@ -15,7 +15,7 @@ #include #include -#include "ewk_internal_api_binding.h" +#include "ftpw_flutter_inappwebview.h" #include "webview_backend.h" typedef struct _Ecore_Evas Ecore_Evas; @@ -94,11 +94,11 @@ class EwkWebViewBackend : public WebViewBackend { static void OnTitleChange(void* data, Evas_Object* obj, void* event_info); static void OnEvaluateJavaScript(Evas_Object* obj, const char* result_value, void* user_data); - 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/flutter_inappwebview/tizen/src/webview_backend_factory.cc b/packages/flutter_inappwebview/tizen/src/webview_backend_factory.cc index 768e01cdf..c387a08be 100644 --- a/packages/flutter_inappwebview/tizen/src/webview_backend_factory.cc +++ b/packages/flutter_inappwebview/tizen/src/webview_backend_factory.cc @@ -9,10 +9,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 { @@ -56,26 +54,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 = GetSelectedBackend(); 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/flutter_inappwebview/tizen/src/wv_internal_api_binding.cc b/packages/flutter_inappwebview/tizen/src/wv_internal_api_binding.cc deleted file mode 100644 index 637da889a..000000000 --- a/packages/flutter_inappwebview/tizen/src/wv_internal_api_binding.cc +++ /dev/null @@ -1,204 +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() { - // NOTE: WV symbols are exported by the Chromium EWK library. - 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; - } - - 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")); - - 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.LoadProgressGet = reinterpret_cast( - dlsym(handle_, "wv_view_load_progress_get")); - view.ScaleSet = reinterpret_cast( - dlsym(handle_, "wv_view_scale_set")); - view.ScaleGet = reinterpret_cast( - dlsym(handle_, "wv_view_scale_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.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.SetSupportVideoHole = reinterpret_cast( - dlsym(handle_, "wv_view_set_support_video_hole")); - view.MainFrameScrollbarVisibleSet = - reinterpret_cast( - dlsym(handle_, "wv_view_main_frame_scrollbar_visible_set")); - - context.CookieManagerGet = reinterpret_cast( - dlsym(handle_, "wv_context_cookie_manager_get")); - context.CacheModelSet = reinterpret_cast( - dlsym(handle_, "wv_context_cache_model_set")); - context.CacheClear = reinterpret_cast( - dlsym(handle_, "wv_context_cache_clear")); - - 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")); - - 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")); - - 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")); - - policy_decision.Use = reinterpret_cast( - dlsym(handle_, "wv_policy_decision_use")); - policy_decision.UrlGet = reinterpret_cast( - dlsym(handle_, "wv_policy_decision_url_get")); - - 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.LoadProgressGet && view.ScaleSet && view.ScaleGet && - view.UserAgentSet && view.UserAgentGet && view.ScrollSet && - 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.SetSupportVideoHole && view.MainFrameScrollbarVisibleSet && - context.CookieManagerGet && context.CacheModelSet && 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 && - console_message.LevelGet && console_message.TextGet; - return *initialize_result_; -} diff --git a/packages/flutter_inappwebview/tizen/src/wv_internal_api_binding.h b/packages/flutter_inappwebview/tizen/src/wv_internal_api_binding.h deleted file mode 100644 index 3be88887b..000000000 --- a/packages/flutter_inappwebview/tizen/src/wv_internal_api_binding.h +++ /dev/null @@ -1,347 +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; - const char* device_name; -} wv_key_event_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 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, - GHashTable* 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 double (*WvViewLoadProgressGetFnPtr)(wv_view_h view); -typedef bool (*WvViewScaleSetFnPtr)(wv_view_h view, double scale_factor, int cx, - int cy); -typedef double (*WvViewScaleGetFnPtr)(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 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 (*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 bool (*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 bool (*WvViewSendKeyEventFnPtr)(wv_view_h view, - const wv_key_event_s* key_event, - int is_press); -typedef bool (*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; - WvViewLoadProgressGetFnPtr LoadProgressGet = nullptr; - WvViewScaleSetFnPtr ScaleSet = nullptr; - WvViewScaleGetFnPtr ScaleGet = nullptr; - WvViewUserAgentSetFnPtr UserAgentSet = nullptr; - WvViewUserAgentGetFnPtr UserAgentGet = nullptr; - WvViewScrollSetFnPtr ScrollSet = 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; - WvViewSetSupportVideoHoleFnPtr SetSupportVideoHole = nullptr; - WvViewMainFrameScrollbarVisibleSetFnPtr MainFrameScrollbarVisibleSet = - nullptr; -} WvViewProcTable; - -typedef wv_cookie_manager_h (*WvContextCookieManagerGetFnPtr)( - wv_context_h context); -typedef bool (*WvContextCacheModelSetFnPtr)(wv_context_h context, - wv_cache_model_e model); -typedef bool (*WvContextCacheClearFnPtr)(wv_context_h context); - -typedef struct { - WvContextCookieManagerGetFnPtr CookieManagerGet = nullptr; - WvContextCacheModelSetFnPtr CacheModelSet = nullptr; - WvContextCacheClearFnPtr CacheClear = nullptr; -} WvContextProcTable; - -typedef void (*WvCookieManagerAcceptPolicySetFnPtr)( - wv_cookie_manager_h manager, wv_cookie_accept_policy_e policy); -typedef void (*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 bool (*WvPolicyDecisionUseFnPtr)(wv_policy_decision_h policy_decision); -typedef const char* (*WvPolicyDecisionUrlGetFnPtr)( - wv_policy_decision_h policy_decision); - -typedef struct { - WvPolicyDecisionUseFnPtr Use = nullptr; - WvPolicyDecisionUrlGetFnPtr UrlGet = 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/flutter_inappwebview/tizen/src/wv_webview_backend.cc b/packages/flutter_inappwebview/tizen/src/wv_webview_backend.cc index 348d6e8d6..7574752ea 100644 --- a/packages/flutter_inappwebview/tizen/src/wv_webview_backend.cc +++ b/packages/flutter_inappwebview/tizen/src/wv_webview_backend.cc @@ -74,7 +74,6 @@ wv_modifier_e ConvertModifiers(unsigned int modifiers) { WvWebViewBackend::WvWebViewBackend(Delegate* delegate) : delegate_(delegate) {} bool WvWebViewBackend::GlobalInitialize(bool standalone) { - auto& wv = WvInternalApiBinding::GetInstance(); std::vector argv = { "--disable-pinch", "--js-flags=--expose-gc", @@ -84,12 +83,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_flutter_inappwebview_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_flutter_inappwebview_wv_init(); if (result <= 0) { LOG_ERROR("wv_init() returned %d.", result); return false; @@ -99,131 +99,139 @@ bool WvWebViewBackend::GlobalInitialize(bool standalone) { void WvWebViewBackend::GlobalShutdown() { FlushPendingTeardowns(); - WvInternalApiBinding::GetInstance().main.Shutdown(); + ftpw_flutter_inappwebview_wv_shutdown(); } bool WvWebViewBackend::Create(double width, double height, void* window) { - auto& wv = WvInternalApiBinding::GetInstance(); - - view_ = wv.view.Create(); + view_ = ftpw_flutter_inappwebview_wv_view_create(); if (!view_) { return false; } - wv.view.FocusSet(view_, 1); + ftpw_flutter_inappwebview_wv_view_focus_set(view_, 1); - wv_context_h context = wv.view.ContextGet(view_); + void* context = ftpw_flutter_inappwebview_wv_view_context_get(view_); if (context) { - wv_cookie_manager_h cookie_manager = wv.context.CookieManagerGet(context); + void* cookie_manager = + ftpw_flutter_inappwebview_wv_context_cookie_manager_get(context); if (cookie_manager) { - wv.cookie_manager.AcceptPolicySet(cookie_manager, - WV_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY); + ftpw_flutter_inappwebview_wv_cookie_manager_accept_policy_set( + cookie_manager, WV_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY); } - wv.context.CacheModelSet(context, WV_CACHE_MODEL_PRIMARY_WEBBROWSER); + ftpw_flutter_inappwebview_wv_context_cache_model_set( + context, WV_CACHE_MODEL_PRIMARY_WEBBROWSER); } else { LOG_WARN("Unable to access the WV context; skipping cookie/cache setup."); } - 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_flutter_inappwebview_wv_view_settings_get(view_); + ftpw_flutter_inappwebview_wv_settings_ime_panel_enabled_set(settings, true); + ftpw_flutter_inappwebview_wv_settings_force_zoom_set(settings, true); + ftpw_flutter_inappwebview_wv_view_ime_window_set(view_, window); + ftpw_flutter_inappwebview_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_flutter_inappwebview_wv_view_touch_events_enabled_set(view_, true); + ftpw_flutter_inappwebview_wv_view_mouse_events_enabled_set(view_, false); #else - wv.view.TouchEventsEnabledSet(view_, false); - wv.view.MouseEventsEnabledSet(view_, true); + ftpw_flutter_inappwebview_wv_view_touch_events_enabled_set(view_, false); + ftpw_flutter_inappwebview_wv_view_mouse_events_enabled_set(view_, true); #endif - wv.view.OnJavaScriptAlert(view_, &WvWebViewBackend::OnJavaScriptAlertDialog, - this); - wv.view.OnJavaScriptConfirm( + ftpw_flutter_inappwebview_wv_view_javascript_alert_callback_set( + view_, &WvWebViewBackend::OnJavaScriptAlertDialog, this); + ftpw_flutter_inappwebview_wv_view_javascript_confirm_callback_set( view_, &WvWebViewBackend::OnJavaScriptConfirmDialog, this); - wv.view.OnJavaScriptPrompt(view_, &WvWebViewBackend::OnJavaScriptPromptDialog, - this); + ftpw_flutter_inappwebview_wv_view_javascript_prompt_callback_set( + view_, &WvWebViewBackend::OnJavaScriptPromptDialog, this); #ifdef TV_PROFILE - wv.view.SetSupportVideoHole(view_, window, true, false); + ftpw_flutter_inappwebview_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_, "url,changed", &WvWebViewBackend::OnUrlChange, - this); - wv.view.AddCallback(view_, "title,changed", &WvWebViewBackend::OnTitleChange, - this); - - wv.view.Resize(view_, static_cast(std::round(width)), - static_cast(std::round(height))); + ftpw_flutter_inappwebview_wv_view_add_cb(view_, "offscreen,frame,rendered", + &WvWebViewBackend::OnFrameRendered, + this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "load,started", &WvWebViewBackend::OnLoadStarted, this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "load,finished", &WvWebViewBackend::OnLoadFinished, this); + ftpw_flutter_inappwebview_wv_view_add_cb(view_, "load,progress", + &WvWebViewBackend::OnProgress, this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "load,error", &WvWebViewBackend::OnLoadError, this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "console,message", &WvWebViewBackend::OnConsoleMessage, this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "policy,navigation,decide", &WvWebViewBackend::OnNavigationPolicy, + this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "url,changed", &WvWebViewBackend::OnUrlChange, this); + ftpw_flutter_inappwebview_wv_view_add_cb( + view_, "title,changed", &WvWebViewBackend::OnTitleChange, this); + + ftpw_flutter_inappwebview_wv_view_resize( + view_, static_cast(std::round(width)), + static_cast(std::round(height))); return true; } WvWebViewBackend::~WvWebViewBackend() { - if (wv_view_h instance = DetachView()) { - WvInternalApiBinding::GetInstance().view.Destroy(instance); + if (void* instance = DetachView()) { + ftpw_flutter_inappwebview_wv_view_destroy(instance); } } -wv_view_h WvWebViewBackend::DetachView() { - wv_view_h instance = view_; +void* WvWebViewBackend::DetachView() { + void* instance = view_; view_ = nullptr; if (!instance) { return nullptr; } - 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, "url,changed", - &WvWebViewBackend::OnUrlChange, this); - wv.view.RemoveFullCallback(instance, "title,changed", - &WvWebViewBackend::OnTitleChange, this); - - wv.view.OnJavaScriptAlert(instance, nullptr, nullptr); - wv.view.OnJavaScriptConfirm(instance, nullptr, nullptr); - wv.view.OnJavaScriptPrompt(instance, nullptr, nullptr); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "offscreen,frame,rendered", &WvWebViewBackend::OnFrameRendered, + this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "load,started", &WvWebViewBackend::OnLoadStarted, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "load,finished", &WvWebViewBackend::OnLoadFinished, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "load,progress", &WvWebViewBackend::OnProgress, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "load,error", &WvWebViewBackend::OnLoadError, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "console,message", &WvWebViewBackend::OnConsoleMessage, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "policy,navigation,decide", + &WvWebViewBackend::OnNavigationPolicy, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "url,changed", &WvWebViewBackend::OnUrlChange, this); + ftpw_flutter_inappwebview_wv_view_remove_full_cb( + instance, "title,changed", &WvWebViewBackend::OnTitleChange, this); + + ftpw_flutter_inappwebview_wv_view_javascript_alert_callback_set( + instance, nullptr, nullptr); + ftpw_flutter_inappwebview_wv_view_javascript_confirm_callback_set( + instance, nullptr, nullptr); + ftpw_flutter_inappwebview_wv_view_javascript_prompt_callback_set( + instance, nullptr, nullptr); // NOTE: A suspended view must be resumed before it can be stopped. - wv.view.Resume(instance); - wv.view.Stop(instance); + ftpw_flutter_inappwebview_wv_view_resume(instance); + ftpw_flutter_inappwebview_wv_view_stop(instance); return instance; } std::function WvWebViewBackend::PrepareTeardown( std::shared_ptr pool) { - wv_view_h instance = DetachView(); + void* instance = DetachView(); std::function destroy; if (instance) { destroy = [instance]() { - WvInternalApiBinding::GetInstance().view.Destroy(instance); + ftpw_flutter_inappwebview_wv_view_destroy(instance); }; } @@ -235,7 +243,7 @@ void WvWebViewBackend::Offset(double /* left */, double /* top */) { } void WvWebViewBackend::Resize(double width, double height) { - WvInternalApiBinding::GetInstance().view.Resize( + ftpw_flutter_inappwebview_wv_view_resize( view_, static_cast(std::round(width)), static_cast(std::round(height))); } @@ -272,8 +280,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_flutter_inappwebview_wv_view_feed_touch_event(view_, touch_event_type, + points, WV_MODIFIER_NONE); g_list_free(points); } @@ -296,16 +304,18 @@ void WvWebViewBackend::SendMouseEvent(int event_type, int button_type, double x, int px = static_cast(std::round(x)); int py = static_cast(std::round(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_flutter_inappwebview_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_flutter_inappwebview_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_flutter_inappwebview_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); @@ -319,10 +329,9 @@ bool WvWebViewBackend::SendKey(const char* key, const char* string, return false; } - auto& wv = WvInternalApiBinding::GetInstance(); if (key && strcmp(key, "XF86Back") == 0 && !is_down) { - if (wv.view.BackPossible(view_)) { - wv.view.Back(view_); + if (ftpw_flutter_inappwebview_wv_view_back_possible(view_)) { + ftpw_flutter_inappwebview_wv_view_back(view_); return true; } return false; @@ -335,35 +344,36 @@ 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_flutter_inappwebview_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_flutter_inappwebview_wv_view_resume(view_); } } void WvWebViewBackend::Suspend() { if (view_) { - WvInternalApiBinding::GetInstance().view.Suspend(view_); + ftpw_flutter_inappwebview_wv_view_suspend(view_); } } void WvWebViewBackend::Stop() { if (view_) { - WvInternalApiBinding::GetInstance().view.Stop(view_); + ftpw_flutter_inappwebview_wv_view_stop(view_); } } void WvWebViewBackend::SetJavaScriptEnabled(bool enabled) { - auto& wv = WvInternalApiBinding::GetInstance(); - wv.settings.JavaScriptEnabledSet(wv.view.SettingsGet(view_), enabled); + ftpw_flutter_inappwebview_wv_settings_javascript_enabled_set( + ftpw_flutter_inappwebview_wv_view_settings_get(view_), enabled); } bool WvWebViewBackend::LoadUrl(const std::string& url) { - return WvInternalApiBinding::GetInstance().view.UrlSet(view_, url.c_str()); + return ftpw_flutter_inappwebview_wv_view_url_set(view_, url.c_str()); } bool WvWebViewBackend::LoadUrlRequest( @@ -384,7 +394,7 @@ bool WvWebViewBackend::LoadUrlRequest( // NOTE: The WV API requires a NUL-terminated non-empty request body. std::string body_str(body.begin(), body.end()); - bool ret = WvInternalApiBinding::GetInstance().view.UrlRequestSet( + bool ret = ftpw_flutter_inappwebview_wv_view_url_request_set( view_, url.c_str(), wv_method, wv_headers, body.empty() ? nullptr : body_str.c_str()); g_hash_table_destroy(wv_headers); @@ -393,32 +403,32 @@ bool WvWebViewBackend::LoadUrlRequest( bool WvWebViewBackend::LoadHtmlString(const std::string& html, const std::string& base_url) { - return WvInternalApiBinding::GetInstance().view.HtmlStringLoad( + return ftpw_flutter_inappwebview_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_flutter_inappwebview_wv_view_back_possible(view_); } bool WvWebViewBackend::CanGoForward() { - return WvInternalApiBinding::GetInstance().view.ForwardPossible(view_); + return ftpw_flutter_inappwebview_wv_view_forward_possible(view_); } bool WvWebViewBackend::GoBack() { - return WvInternalApiBinding::GetInstance().view.Back(view_); + return ftpw_flutter_inappwebview_wv_view_back(view_); } bool WvWebViewBackend::GoForward() { - return WvInternalApiBinding::GetInstance().view.Forward(view_); + return ftpw_flutter_inappwebview_wv_view_forward(view_); } bool WvWebViewBackend::Reload() { - return WvInternalApiBinding::GetInstance().view.Reload(view_); + return ftpw_flutter_inappwebview_wv_view_reload(view_); } std::string WvWebViewBackend::GetCurrentUrl() { - const char* url = WvInternalApiBinding::GetInstance().view.UrlGet(view_); + const char* url = ftpw_flutter_inappwebview_wv_view_url_get(view_); return url ? url : ""; } @@ -426,8 +436,7 @@ int32_t WvWebViewBackend::GetProgress() { if (!view_) { return 0; } - double progress = - WvInternalApiBinding::GetInstance().view.LoadProgressGet(view_); + double progress = ftpw_flutter_inappwebview_wv_view_load_progress_get(view_); if (progress < 0) { return 0; } @@ -438,12 +447,12 @@ double WvWebViewBackend::GetScale() { if (!view_) { return 1.0; } - double scale = WvInternalApiBinding::GetInstance().view.ScaleGet(view_); + double scale = ftpw_flutter_inappwebview_wv_view_scale_get(view_); return scale > 0 ? scale : 1.0; } void WvWebViewBackend::SetScale(double scale, int32_t x, int32_t y) { - WvInternalApiBinding::GetInstance().view.ScaleSet(view_, scale, x, y); + ftpw_flutter_inappwebview_wv_view_scale_set(view_, scale, x, y); } void WvWebViewBackend::EvaluateJavaScript( @@ -451,7 +460,7 @@ void WvWebViewBackend::EvaluateJavaScript( std::function callback) { auto* callback_ptr = new std::function(std::move(callback)); - if (!WvInternalApiBinding::GetInstance().view.ScriptExecute( + if (!ftpw_flutter_inappwebview_wv_view_script_execute( view_, javascript.c_str(), &WvWebViewBackend::OnEvaluateJavaScript, callback_ptr)) { LOG_WARN("wv_view_script_execute failed."); @@ -461,75 +470,72 @@ void WvWebViewBackend::EvaluateJavaScript( } void WvWebViewBackend::ClearCache() { - auto& wv = WvInternalApiBinding::GetInstance(); - wv_context_h context = wv.view.ContextGet(view_); + void* context = ftpw_flutter_inappwebview_wv_view_context_get(view_); if (context) { - wv.context.CacheClear(context); + ftpw_flutter_inappwebview_wv_context_cache_clear(context); } } std::string WvWebViewBackend::GetTitle() { - const char* title = WvInternalApiBinding::GetInstance().view.TitleGet(view_); + const char* title = ftpw_flutter_inappwebview_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_flutter_inappwebview_wv_view_scroll_set(view_, x, y); } void WvWebViewBackend::GetScrollPosition(int32_t* x, int32_t* y) { - WvInternalApiBinding::GetInstance().view.ScrollPosGet(view_, x, y); + ftpw_flutter_inappwebview_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_flutter_inappwebview_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_flutter_inappwebview_wv_view_user_agent_set(view_, user_agent.c_str()); } std::string WvWebViewBackend::GetUserAgent() { const char* user_agent = - WvInternalApiBinding::GetInstance().view.UserAgentGet(view_); + ftpw_flutter_inappwebview_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_flutter_inappwebview_wv_settings_force_zoom_set( + ftpw_flutter_inappwebview_wv_view_settings_get(view_), enabled); } void WvWebViewBackend::JavaScriptAlertReply() { - WvInternalApiBinding::GetInstance().view.JavaScriptAlertReply(view_); + ftpw_flutter_inappwebview_wv_view_javascript_alert_reply(view_); } void WvWebViewBackend::JavaScriptConfirmReply(bool result) { - WvInternalApiBinding::GetInstance().view.JavaScriptConfirmReply(view_, - result); + ftpw_flutter_inappwebview_wv_view_javascript_confirm_reply(view_, result); } void WvWebViewBackend::JavaScriptPromptReply(const char* result) { - WvInternalApiBinding::GetInstance().view.JavaScriptPromptReply(view_, result); + ftpw_flutter_inappwebview_wv_view_javascript_prompt_reply(view_, result); } bool WvWebViewBackend::ClearCookies() { if (!view_) { return false; } - auto& wv = WvInternalApiBinding::GetInstance(); - wv_context_h context = wv.view.ContextGet(view_); - wv_cookie_manager_h cookie_manager = - context ? wv.context.CookieManagerGet(context) : nullptr; + void* context = ftpw_flutter_inappwebview_wv_view_context_get(view_); + void* cookie_manager = + context ? ftpw_flutter_inappwebview_wv_context_cookie_manager_get(context) + : nullptr; if (cookie_manager) { - wv.cookie_manager.CookiesClear(cookie_manager); + ftpw_flutter_inappwebview_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( @@ -537,24 +543,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_, true); - const char* url = wv.view.UrlGet(backend->view_); + ftpw_flutter_inappwebview_wv_view_main_frame_scrollbar_visible_set( + backend->view_, true); + const char* url = ftpw_flutter_inappwebview_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_flutter_inappwebview_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) { if (!event_info) { return; @@ -565,54 +570,55 @@ 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); + void* error = static_cast(event_info); + const char* description = + ftpw_flutter_inappwebview_wv_error_description_get(error); + const char* url = ftpw_flutter_inappwebview_wv_error_url_get(error); backend->delegate_->OnLoadError( - wv.error.CodeGet(error), description ? description : "", url ? url : ""); + ftpw_flutter_inappwebview_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 = static_cast(event_info); + wv_console_message_level_e log_level = + ftpw_flutter_inappwebview_wv_console_message_level_get(message); + const char* text = + ftpw_flutter_inappwebview_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(); + void* policy_decision = static_cast(event_info); - const char* current_url = wv.view.UrlGet(backend->view_); + const char* current_url = + ftpw_flutter_inappwebview_wv_view_url_get(backend->view_); const std::string url_before_navigation = current_url ? current_url : ""; - const char* url = wv.policy_decision.UrlGet(policy_decision); + const char* url = + ftpw_flutter_inappwebview_wv_policy_decision_url_get(policy_decision); const std::string requested_url = url ? url : ""; - wv.policy_decision.Use(policy_decision); + ftpw_flutter_inappwebview_wv_policy_decision_use(policy_decision); backend->delegate_->OnNavigationPolicyDecide(requested_url, url_before_navigation); } -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_flutter_inappwebview_wv_view_url_get(backend->view_); backend->delegate_->OnUrlChanged(url ? url : ""); } -void WvWebViewBackend::OnTitleChange(wv_view_h obj, void* event_info, +void WvWebViewBackend::OnTitleChange(void* obj, void* event_info, void* user_data) { const char* title = static_cast(event_info); if (!title) { @@ -621,8 +627,7 @@ void WvWebViewBackend::OnTitleChange(wv_view_h obj, void* event_info, static_cast(user_data)->delegate_->OnTitleChanged(title); } -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); @@ -630,35 +635,30 @@ void WvWebViewBackend::OnEvaluateJavaScript(wv_view_h obj, delete callback; } -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_flutter_inappwebview_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_flutter_inappwebview_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_flutter_inappwebview_wv_view_url_get(backend->view_); backend->delegate_->OnJavaScriptPromptDialog( message ? message : "", default_text ? default_text : "", url ? url : ""); return true; diff --git a/packages/flutter_inappwebview/tizen/src/wv_webview_backend.h b/packages/flutter_inappwebview/tizen/src/wv_webview_backend.h index 4071d012e..b40210895 100644 --- a/packages/flutter_inappwebview/tizen/src/wv_webview_backend.h +++ b/packages/flutter_inappwebview/tizen/src/wv_webview_backend.h @@ -12,8 +12,8 @@ #include #include +#include "ftpw_flutter_inappwebview.h" #include "webview_backend.h" -#include "wv_internal_api_binding.h" class WvWebViewBackend : public WebViewBackend { public: @@ -74,26 +74,24 @@ class WvWebViewBackend : public WebViewBackend { static void GlobalShutdown(); private: - wv_view_h DetachView(); - - 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 OnUrlChange(wv_view_h obj, void* event_info, void* user_data); - static void OnTitleChange(wv_view_h obj, void* event_info, void* user_data); - static void OnEvaluateJavaScript(wv_view_h obj, const char* result_value, + void* DetachView(); + + 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 OnUrlChange(void* obj, void* event_info, void* user_data); + static void OnTitleChange(void* obj, void* event_info, void* user_data); + static void OnEvaluateJavaScript(void* obj, const char* result_value, void* user_data); - static bool OnJavaScriptAlertDialog(wv_view_h view, const char* 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); @@ -101,7 +99,7 @@ class WvWebViewBackend : public WebViewBackend { double dy); Delegate* delegate_; - wv_view_h view_ = nullptr; + void* view_ = nullptr; wv_mouse_button_type_e mouse_button_type_ = static_cast(0); };