Skip to content

Commit

Permalink
[webview_flutter] Update lightweight web engine binary (flutter-tizen…
Browse files Browse the repository at this point in the history
…#380)

* Update lightweight web engine binary
* Update lightweight web engine header (LWEWebView.h)

Signed-off-by: MuHong Byun <[email protected]>
  • Loading branch information
bwikbs authored May 11, 2022
1 parent dd5d56a commit c0974e6
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 70 deletions.
4 changes: 4 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.4

* Update LWE binary (645719ed084d899ec7d53de1758db71a8974e446).

## 0.4.3

* Remove unused things.
Expand Down
4 changes: 2 additions & 2 deletions packages/webview_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore

```yaml
dependencies:
webview_flutter: ^3.0.1
webview_flutter_tizen: ^0.4.2
webview_flutter: ^3.0.2
webview_flutter_tizen: ^0.4.4
```
## Example
Expand Down
129 changes: 64 additions & 65 deletions packages/webview_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:webview_flutter_tizen/webview_flutter_tizen.dart';

void main() => runApp(MaterialApp(home: WebViewExample()));
void main() => runApp(const MaterialApp(home: WebViewExample()));

const String kNavigationExamplePage = '''
<!DOCTYPE html><html>
Expand Down Expand Up @@ -72,6 +72,10 @@ const String kTransparentBackgroundPage = '''
''';

class WebViewExample extends StatefulWidget {
const WebViewExample({this.cookieManager});

final CookieManager? cookieManager;

@override
_WebViewExampleState createState() => _WebViewExampleState();
}
Expand All @@ -94,42 +98,38 @@ class _WebViewExampleState extends State<WebViewExample> {
// This drop down menu demonstrates that Flutter widgets can be shown over the web view.
actions: <Widget>[
NavigationControls(_controller.future),
SampleMenu(_controller.future),
SampleMenu(_controller.future, widget.cookieManager),
],
),
// We're using a Builder here so we have a context that is below the Scaffold
// to allow calling Scaffold.of(context) so we can show a snackbar.
body: Builder(builder: (BuildContext context) {
return WebView(
initialUrl: 'https://www.apache.org/licenses/LICENSE-2.0.txt',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
onProgress: (int progress) {
print('WebView is loading (progress : $progress%)');
},
javascriptChannels: <JavascriptChannel>{
_toasterJavascriptChannel(context),
},
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith('https://www.youtube.com/')) {
print('blocking navigation to $request}');
return NavigationDecision.prevent;
}
print('allowing navigation to $request');
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
print('Page started loading: $url');
},
onPageFinished: (String url) {
print('Page finished loading: $url');
},
gestureNavigationEnabled: true,
backgroundColor: const Color(0x00000000),
);
}),
body: WebView(
initialUrl: 'https://flutter.dev',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
onProgress: (int progress) {
print('WebView is loading (progress : $progress%)');
},
javascriptChannels: <JavascriptChannel>{
_toasterJavascriptChannel(context),
},
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith('https://www.youtube.com/')) {
print('blocking navigation to $request}');
return NavigationDecision.prevent;
}
print('allowing navigation to $request');
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
print('Page started loading: $url');
},
onPageFinished: (String url) {
print('Page finished loading: $url');
},
gestureNavigationEnabled: true,
backgroundColor: const Color(0x00000000),
),
floatingActionButton: favoriteButton(),
);
}
Expand All @@ -138,8 +138,7 @@ class _WebViewExampleState extends State<WebViewExample> {
return JavascriptChannel(
name: 'Toaster',
onMessageReceived: (JavascriptMessage message) {
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message.message)),
);
});
Expand All @@ -150,19 +149,24 @@ class _WebViewExampleState extends State<WebViewExample> {
future: _controller.future,
builder: (BuildContext context,
AsyncSnapshot<WebViewController> controller) {
if (controller.hasData) {
return FloatingActionButton(
onPressed: () async {
final String url = (await controller.data!.currentUrl())!;
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
SnackBar(content: Text('Favorited $url')),
);
},
child: const Icon(Icons.favorite),
);
}
return Container();
return FloatingActionButton(
onPressed: () async {
String? url;
if (controller.hasData) {
url = (await controller.data!.currentUrl())!;
}
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
controller.hasData
? 'Favorited $url'
: 'Unable to favorite',
),
),
);
},
child: const Icon(Icons.favorite),
);
});
}
}
Expand All @@ -184,10 +188,11 @@ enum MenuOptions {
}

class SampleMenu extends StatelessWidget {
SampleMenu(this.controller);
SampleMenu(this.controller, CookieManager? cookieManager)
: cookieManager = CookieManagerTizen();

final Future<WebViewController> controller;
final CookieManagerTizen cookieManager = CookieManagerTizen();
late final CookieManagerTizen cookieManager;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -313,8 +318,7 @@ class SampleMenu extends StatelessWidget {
WebViewController controller, BuildContext context) async {
final String cookies =
await controller.runJavascriptReturningResult('document.cookie');
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
Expand All @@ -330,8 +334,7 @@ class SampleMenu extends StatelessWidget {
WebViewController controller, BuildContext context) async {
await controller.runJavascript(
'caches.open("test_caches_entry"); localStorage["test_localStorage"] = "dummy_entry";');
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(const SnackBar(
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Added a test entry to cache.'),
));
}
Expand All @@ -346,8 +349,7 @@ class SampleMenu extends StatelessWidget {
Future<void> _onClearCache(
WebViewController controller, BuildContext context) async {
await controller.clearCache();
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(const SnackBar(
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Cache cleared.'),
));
}
Expand All @@ -358,8 +360,7 @@ class SampleMenu extends StatelessWidget {
if (!hadCookies) {
message = 'There are no cookies.';
}
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(message),
));
}
Expand All @@ -373,7 +374,7 @@ class SampleMenu extends StatelessWidget {

Future<void> _onSetCookie(
WebViewController controller, BuildContext context) async {
await CookieManager().setCookie(
await cookieManager.setCookie(
const WebViewCookie(
name: 'foo', value: 'bar', domain: 'httpbin.org', path: '/anything'),
);
Expand Down Expand Up @@ -464,8 +465,7 @@ class NavigationControls extends StatelessWidget {
if (await controller!.canGoBack()) {
await controller.goBack();
} else {
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('No back history item')),
);
return;
Expand All @@ -480,8 +480,7 @@ class NavigationControls extends StatelessWidget {
if (await controller!.canGoForward()) {
await controller.goForward();
} else {
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('No forward history item')),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_tizen
description: Tizen implementation of the webview plugin
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/webview_flutter
version: 0.4.3
version: 0.4.4

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/webview_flutter/tizen/inc/lwe/LWEWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class LWE_EXPORT WebContainer {
void Focus();
void Blur();

void SetSettings(const Settings& setttings);
void SetSettings(const Settings& settings);
void RemoveJavascriptInterface(const std::string& exposedObjectName,
const std::string& jsFunctionName);
void ClearCache();
Expand Down Expand Up @@ -379,7 +379,7 @@ class LWE_EXPORT WebView {
void EvaluateJavaScript(const std::string& script,
std::function<void(const std::string&)> cb);
void ClearHistory();
void SetSettings(const Settings& setttings);
void SetSettings(const Settings& settings);
void RemoveJavascriptInterface(const std::string& exposedObjectName,
const std::string& jsFunctionName);
void ClearCache();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c0974e6

Please sign in to comment.