Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'tizen_webview.dart';
const String kTizenNavigationDelegateChannelName =
'plugins.flutter.io/tizen_webview_navigation_delegate_';

/// An implementation of [PlatformWebViewController] the Tizen WebView API.
/// An implementation of [PlatformWebViewController] using the Tizen WebView API.
class TizenWebViewController extends PlatformWebViewController {
/// Constructs a [TizenWebViewController].
TizenWebViewController(super.params)
Expand Down
22 changes: 9 additions & 13 deletions packages/webview_flutter/tizen/src/webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

namespace {

typedef flutter::MethodCall<flutter::EncodableValue> FlMethodCall;
typedef flutter::MethodResult<flutter::EncodableValue> FlMethodResult;
typedef flutter::MethodChannel<flutter::EncodableValue> FlMethodChannel;

constexpr size_t kBufferPoolSize = 5;
constexpr char kEwkInstance[] = "ewk_instance";
constexpr char kTizenWebViewChannelName[] = "plugins.flutter.io/tizen_webview_";
Expand Down Expand Up @@ -133,13 +129,13 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int view_id,

InitWebView();

tizen_webview_channel_ = std::make_unique<FlMethodChannel>(
GetPluginRegistrar()->messenger(), GetTizenWebViewChannelName(),
webview_channel_ = std::make_unique<FlMethodChannel>(
GetPluginRegistrar()->messenger(), GetWebViewChannelName(),
&flutter::StandardMethodCodec::GetInstance());

tizen_webview_channel_->SetMethodCallHandler(
webview_channel_->SetMethodCallHandler(
[webview = this](const auto& call, auto result) {
webview->HandleTizenWebViewMethodCall(call, std::move(result));
webview->HandleWebViewMethodCall(call, std::move(result));
});

navigation_delegate_channel_ = std::make_unique<FlMethodChannel>(
Expand Down Expand Up @@ -170,7 +166,7 @@ void WebView::RegisterJavaScriptChannelName(const std::string& name) {

WebView::~WebView() { Dispose(); }

std::string WebView::GetTizenWebViewChannelName() {
std::string WebView::GetWebViewChannelName() {
return std::string(kTizenWebViewChannelName) + std::to_string(GetViewId());
}

Expand Down Expand Up @@ -338,8 +334,8 @@ void WebView::InitWebView() {
evas_object_data_set(webview_instance_, kEwkInstance, this);
}

void WebView::HandleTizenWebViewMethodCall(
const FlMethodCall& method_call, std::unique_ptr<FlMethodResult> result) {
void WebView::HandleWebViewMethodCall(const FlMethodCall& method_call,
std::unique_ptr<FlMethodResult> result) {
if (!webview_instance_) {
result->Error("Invalid operation",
"The webview instance has not been initialized.");
Expand Down Expand Up @@ -668,7 +664,7 @@ void WebView::OnJavaScriptMessage(Evas_Object* obj,
if (obj) {
WebView* webview =
static_cast<WebView*>(evas_object_data_get(obj, kEwkInstance));
if (webview->tizen_webview_channel_) {
if (webview->webview_channel_) {
std::string channel_name(message.name);
std::string message_body(static_cast<char*>(message.body));

Expand All @@ -678,7 +674,7 @@ void WebView::OnJavaScriptMessage(Evas_Object* obj,
{flutter::EncodableValue("message"),
flutter::EncodableValue(message_body)},
};
webview->tizen_webview_channel_->InvokeMethod(
webview->webview_channel_->InvokeMethod(
"javaScriptChannelMessage",
std::make_unique<flutter::EncodableValue>(args));
}
Expand Down
22 changes: 11 additions & 11 deletions packages/webview_flutter/tizen/src/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <mutex>
#include <string>

typedef flutter::MethodCall<flutter::EncodableValue> FlMethodCall;
typedef flutter::MethodResult<flutter::EncodableValue> FlMethodResult;
typedef flutter::MethodChannel<flutter::EncodableValue> FlMethodChannel;

class BufferPool;
class BufferUnit;

Expand Down Expand Up @@ -52,15 +56,13 @@ class WebView : public PlatformView {
size_t height);

private:
void HandleTizenWebViewMethodCall(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
void HandleCookieMethodCall(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
void HandleWebViewMethodCall(const FlMethodCall& method_call,
std::unique_ptr<FlMethodResult> result);
void HandleCookieMethodCall(const FlMethodCall& method_call,
std::unique_ptr<FlMethodResult> result);

void RegisterJavaScriptChannelName(const std::string& name);
std::string GetTizenWebViewChannelName();
std::string GetWebViewChannelName();
std::string GetNavigationDelegateChannelName();

void InitWebView();
Expand All @@ -86,10 +88,8 @@ class WebView : public PlatformView {
BufferUnit* candidate_surface_ = nullptr;
BufferUnit* rendered_surface_ = nullptr;
bool has_navigation_delegate_ = false;
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>>
tizen_webview_channel_;
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>>
navigation_delegate_channel_;
std::unique_ptr<FlMethodChannel> webview_channel_;
std::unique_ptr<FlMethodChannel> navigation_delegate_channel_;
std::unique_ptr<flutter::TextureVariant> texture_variant_;
std::mutex mutex_;
std::unique_ptr<BufferPool> tbm_pool_;
Expand Down
5 changes: 5 additions & 0 deletions packages/webview_flutter_lwe/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.0

* Update webivew_flutter to 4.0.2.
* Update webview_flutter_platform_interface to 2.0.1.

## 0.1.1

* Use only error type names defined in `web_resource_error.dart`.
Expand Down
23 changes: 17 additions & 6 deletions packages/webview_flutter_lwe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore

```yaml
dependencies:
webview_flutter: ^3.0.4
webview_flutter_lwe: ^0.1.1
webview_flutter: ^4.0.2
webview_flutter_lwe: ^0.2.0
```

## Example
Expand All @@ -30,16 +30,27 @@ dependencies:
import 'package:webview_flutter/webview_flutter.dart';

class WebViewExample extends StatefulWidget {
const WebViewExample({Key? key}) : super(key: key);
const WebViewExample({super.key});

@override
WebViewExampleState createState() => WebViewExampleState();
State<WebViewExample> createState() => _WebViewExampleState();
}

class WebViewExampleState extends State<WebViewExample> {
class _WebViewExampleState extends State<WebViewExample> {
final WebViewController _controller = WebViewController();

@override
void initState() {
super.initState();

_controller.loadRequest(Uri.parse('https://flutter.dev'));
}

@override
Widget build(BuildContext context) {
return WebView(initialUrl: 'https://flutter.dev');
return Scaffold(
body: WebViewWidget(controller: _controller),
);
}
}
```
Expand Down
Loading