diff --git a/packages/webview_flutter/CHANGELOG.md b/packages/webview_flutter/CHANGELOG.md index d3720af7f..be01c5163 100644 --- a/packages/webview_flutter/CHANGELOG.md +++ b/packages/webview_flutter/CHANGELOG.md @@ -1,5 +1,11 @@ -## NEXT - +## 0.11.1 + +* Update minimum supported SDK version to Flutter 3.38/Dart 3.10. +* Update webview_flutter to 4.14.1. +* Update webview_flutter_platform_interface to 2.15.1. +* Select the web engine backend from the device's platform version. +* Fix a crash and missing request headers on the WV backend. +* Correct the WV API declarations. * Omit obvious local variable types. * Reformat with a line length of 100. diff --git a/packages/webview_flutter/README.md b/packages/webview_flutter/README.md index 77e93a5ea..7991643ad 100644 --- a/packages/webview_flutter/README.md +++ b/packages/webview_flutter/README.md @@ -22,8 +22,8 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore ```yaml dependencies: - webview_flutter: ^4.13.1 - webview_flutter_tizen: ^0.11.0 + webview_flutter: ^4.14.1 + webview_flutter_tizen: ^0.11.1 ``` ## Example @@ -73,6 +73,10 @@ The plugin chooses a backend from the platform version reported by the device: The WV backends are experimental. `WebViewController.tizenEnginePolicy` has no WV equivalent, so it is ignored (with a warning) on Tizen 10.1 and later. +## Cookies + +- `WebViewCookieManager.getCookies` throws `UnimplementedError`: neither backend can read cookies yet. On the EWK backend the web engine's cookie API returns nothing, a defect being fixed; on the WV backends that API is not yet in the platform library. + ## Note - To play Youtube, make app's background color to transparent. diff --git a/packages/webview_flutter/example/lib/main.dart b/packages/webview_flutter/example/lib/main.dart index 51f13510e..24b76c313 100644 --- a/packages/webview_flutter/example/lib/main.dart +++ b/packages/webview_flutter/example/lib/main.dart @@ -433,8 +433,15 @@ class SampleMenu extends StatelessWidget { } Future _onListCookies(BuildContext context) async { - final cookies = - await webViewController.runJavaScriptReturningResult('document.cookie') as String; + final Uri? domain = Uri.tryParse((await webViewController.currentUrl()) ?? ''); + + final List cookies; + if (domain == null) { + cookies = []; + } else { + cookies = await cookieManager.getCookies(domain: domain); + } + if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -545,12 +552,13 @@ class SampleMenu extends StatelessWidget { return webViewController.loadHtmlString(kAlertTestPage); } - Widget _getCookieList(String cookies) { - if (cookies == '""') { + Widget _getCookieList(List cookies) { + if (cookies.isEmpty) { return Container(); } - final List cookieList = cookies.split(';'); - final Iterable cookieWidgets = cookieList.map((String cookie) => Text(cookie)); + final Iterable cookieWidgets = cookies.map( + (WebViewCookie cookie) => Text(cookie.toString()), + ); return Column( mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.min, diff --git a/packages/webview_flutter/example/pubspec.yaml b/packages/webview_flutter/example/pubspec.yaml index 96c1b1238..a69dd78a9 100644 --- a/packages/webview_flutter/example/pubspec.yaml +++ b/packages/webview_flutter/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the webview_flutter_tizen plugin. publish_to: "none" environment: - sdk: ^3.8.0 - flutter: ">=3.32.0" + sdk: ^3.10.0 + flutter: ">=3.38.0" dependencies: flutter: @@ -12,7 +12,7 @@ dependencies: path_provider: ^2.0.7 path_provider_tizen: path: ../../path_provider/ - webview_flutter: ^4.13.0 + webview_flutter: ^4.14.1 webview_flutter_tizen: path: ../ diff --git a/packages/webview_flutter/lib/src/tizen_webview_cookie_manager.dart b/packages/webview_flutter/lib/src/tizen_webview_cookie_manager.dart index c924f511a..3d502bfb5 100644 --- a/packages/webview_flutter/lib/src/tizen_webview_cookie_manager.dart +++ b/packages/webview_flutter/lib/src/tizen_webview_cookie_manager.dart @@ -21,6 +21,14 @@ class TizenWebViewCookieManager extends PlatformWebViewCookieManager { return await _cookieManagerChannel.invokeMethod('clearCookies') ?? false; } + @override + Future> getCookies(Uri url) { + throw UnimplementedError( + 'This version of `TizenWebViewCookieManager` currently has no ' + 'implementation for getCookies method.', + ); + } + @override Future setCookie(WebViewCookie cookie) async { if (!_isValidPath(cookie.path)) { diff --git a/packages/webview_flutter/pubspec.yaml b/packages/webview_flutter/pubspec.yaml index c0431e814..84fa834cc 100644 --- a/packages/webview_flutter/pubspec.yaml +++ b/packages/webview_flutter/pubspec.yaml @@ -2,11 +2,11 @@ name: webview_flutter_tizen description: Tizen implementation of the webview_flutter plugin. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/main/packages/webview_flutter -version: 0.11.0 +version: 0.11.1 environment: - sdk: ^3.8.0 - flutter: ">=3.32.0" + sdk: ^3.10.0 + flutter: ">=3.38.0" flutter: plugin: @@ -21,8 +21,8 @@ dependencies: flutter: sdk: flutter flutter_tizen: ^0.2.1 - webview_flutter: ^4.13.1 - webview_flutter_platform_interface: ^2.13.0 + webview_flutter: ^4.14.1 + webview_flutter_platform_interface: ^2.15.1 topics: - html diff --git a/packages/webview_flutter/tizen/src/webview_backend_factory.cc b/packages/webview_flutter/tizen/src/webview_backend_factory.cc index 361d6579a..befcd88ef 100644 --- a/packages/webview_flutter/tizen/src/webview_backend_factory.cc +++ b/packages/webview_flutter/tizen/src/webview_backend_factory.cc @@ -4,6 +4,8 @@ #include "webview_backend_factory.h" +#include + #include #include @@ -19,9 +21,15 @@ enum class BackendKind { kEwk, kEwkWrapper, kWvStandalone }; BackendKind DefaultBackendForPlatform() { int major = 0, minor = 0; - if (const char* value = std::getenv("TIZEN_API_VERSION")) { + char* value = nullptr; + int ret = system_info_get_platform_string( + "http://tizen.org/feature/platform.version", &value); + if (ret == SYSTEM_INFO_ERROR_NONE && value) { std::sscanf(value, "%d.%d", &major, &minor); } + if (value) { + free(value); + } if (major >= 11) { return BackendKind::kWvStandalone; } diff --git a/packages/webview_flutter/tizen/src/wv_internal_api_binding.h b/packages/webview_flutter/tizen/src/wv_internal_api_binding.h index c358aec5f..0ff53525d 100644 --- a/packages/webview_flutter/tizen/src/wv_internal_api_binding.h +++ b/packages/webview_flutter/tizen/src/wv_internal_api_binding.h @@ -94,6 +94,7 @@ typedef struct { wv_modifier_e modifiers; int event_flags; unsigned int key_code; + const char* device_name; } wv_key_event_s; typedef struct { @@ -135,8 +136,8 @@ 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); + 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); @@ -163,10 +164,10 @@ 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 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); @@ -176,10 +177,10 @@ typedef int (*WvViewFeedMouseUpFnPtr)(wv_view_h view, 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 (*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); @@ -257,10 +258,10 @@ typedef struct { 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 bool (*WvContextCacheModelSetFnPtr)(wv_context_h context, + wv_cache_model_e model); +typedef bool (*WvContextWebStorageDeleteAllFnPtr)(wv_context_h context); +typedef bool (*WvContextCacheClearFnPtr)(wv_context_h context); typedef struct { WvContextCookieManagerGetFnPtr CookieManagerGet = nullptr; @@ -269,9 +270,9 @@ typedef struct { WvContextCacheClearFnPtr CacheClear = nullptr; } WvContextProcTable; -typedef int (*WvCookieManagerAcceptPolicySetFnPtr)( +typedef void (*WvCookieManagerAcceptPolicySetFnPtr)( wv_cookie_manager_h manager, wv_cookie_accept_policy_e policy); -typedef int (*WvCookieManagerCookiesClearFnPtr)(wv_cookie_manager_h manager); +typedef void (*WvCookieManagerCookiesClearFnPtr)(wv_cookie_manager_h manager); typedef struct { WvCookieManagerAcceptPolicySetFnPtr AcceptPolicySet = nullptr; @@ -301,7 +302,7 @@ typedef struct { WvErrorUrlGetFnPtr UrlGet = nullptr; } WvErrorProcTable; -typedef int (*WvPolicyDecisionUseFnPtr)(wv_policy_decision_h policy_decision); +typedef bool (*WvPolicyDecisionUseFnPtr)(wv_policy_decision_h policy_decision); typedef const char* (*WvPolicyDecisionUrlGetFnPtr)( wv_policy_decision_h policy_decision); typedef int (*WvPolicyDecisionResponseStatusCodeGetFnPtr)( diff --git a/packages/webview_flutter/tizen/src/wv_webview_backend.cc b/packages/webview_flutter/tizen/src/wv_webview_backend.cc index 7771b62b1..71ddcdfd3 100644 --- a/packages/webview_flutter/tizen/src/wv_webview_backend.cc +++ b/packages/webview_flutter/tizen/src/wv_webview_backend.cc @@ -4,12 +4,9 @@ #include "wv_webview_backend.h" -#include -#include #include #include -#include #include #include #include @@ -371,25 +368,17 @@ bool WvWebViewBackend::LoadUrlRequest( wv_method = WV_HTTP_METHOD_POST; } - Eina_Hash* wv_headers = eina_hash_new( - [](const void* key) -> unsigned int { - return key ? strlen(static_cast(key)) + 1 : 0; - }, - [](const void* key1, int key1_length, const void* key2, - int key2_length) -> int { - return strcmp(static_cast(key1), - static_cast(key2)); - }, - EINA_KEY_HASH(eina_hash_superfast), [](void* data) { free(data); }, 10); + GHashTable* wv_headers = + g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); for (const auto& header : headers) { - eina_hash_add(wv_headers, header.first.c_str(), - strdup(header.second.c_str())); + g_hash_table_insert(wv_headers, g_strdup(header.first.c_str()), + g_strdup(header.second.c_str())); } bool ret = WvInternalApiBinding::GetInstance().view.UrlRequestSet( view_, url.c_str(), wv_method, wv_headers, reinterpret_cast(body.data())); - eina_hash_free(wv_headers); + g_hash_table_destroy(wv_headers); return ret; }