Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
8 changes: 6 additions & 2 deletions packages/webview_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 14 additions & 6 deletions packages/webview_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,15 @@ class SampleMenu extends StatelessWidget {
}

Future<void> _onListCookies(BuildContext context) async {
final cookies =
await webViewController.runJavaScriptReturningResult('document.cookie') as String;
final Uri? domain = Uri.tryParse((await webViewController.currentUrl()) ?? '');

final List<WebViewCookie> cookies;
if (domain == null) {
cookies = [];
} else {
cookies = await cookieManager.getCookies(domain: domain);
Comment thread
seungsoo47 marked this conversation as resolved.
}

if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
Expand Down Expand Up @@ -545,12 +552,13 @@ class SampleMenu extends StatelessWidget {
return webViewController.loadHtmlString(kAlertTestPage);
}

Widget _getCookieList(String cookies) {
if (cookies == '""') {
Widget _getCookieList(List<WebViewCookie> cookies) {
if (cookies.isEmpty) {
return Container();
}
final List<String> cookieList = cookies.split(';');
final Iterable<Text> cookieWidgets = cookieList.map((String cookie) => Text(cookie));
final Iterable<Text> cookieWidgets = cookies.map(
(WebViewCookie cookie) => Text(cookie.toString()),
);
return Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
Expand Down
6 changes: 3 additions & 3 deletions packages/webview_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ 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:
sdk: flutter
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: ../

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class TizenWebViewCookieManager extends PlatformWebViewCookieManager {
return await _cookieManagerChannel.invokeMethod<bool>('clearCookies') ?? false;
}

@override
Future<List<WebViewCookie>> getCookies(Uri url) {
throw UnimplementedError(
'This version of `TizenWebViewCookieManager` currently has no '
'implementation for getCookies method.',
);
}

@override
Future<void> setCookie(WebViewCookie cookie) async {
if (!_isValidPath(cookie.path)) {
Expand Down
10 changes: 5 additions & 5 deletions packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion packages/webview_flutter/tizen/src/webview_backend_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "webview_backend_factory.h"

#include <system_info.h>

#include <cstdio>
#include <cstdlib>

Expand All @@ -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;
}
Expand Down
35 changes: 18 additions & 17 deletions packages/webview_flutter/tizen/src/wv_internal_api_binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)(
Expand Down
21 changes: 5 additions & 16 deletions packages/webview_flutter/tizen/src/wv_webview_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

#include "wv_webview_backend.h"

#include <Eina.h>
#include <Evas.h>
#include <glib.h>

#include <cmath>
#include <cstdlib>
#include <cstring>
#include <mutex>
#include <vector>
Expand Down Expand Up @@ -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<const char*>(key)) + 1 : 0;
},
[](const void* key1, int key1_length, const void* key2,
int key2_length) -> int {
return strcmp(static_cast<const char*>(key1),
static_cast<const char*>(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<const char*>(body.data()));
eina_hash_free(wv_headers);
g_hash_table_destroy(wv_headers);
return ret;
}

Expand Down
Loading