Skip to content

Commit 4c72bbf

Browse files
Added InAppBrowser.onMainWindowWillClose event, Added WindowType.WINDOW for InAppWebViewSettings.windowType, fix #1738, Fixed InAppWebViewController.callAsyncJavaScript Android-issue when the last line of the functionBody parameter includes a code comment
1 parent 63c2f7f commit 4c72bbf

File tree

38 files changed

+137
-51
lines changed

38 files changed

+137
-51
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

dev_packages/flutter_inappwebview_internal_annotations/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

flutter_inappwebview/CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 6.0.0-rc.1
2+
3+
- Updated minimum platform interface and implementation versions
4+
- Added `InAppBrowser.onMainWindowWillClose` event
5+
- Added `WindowType.WINDOW` for `InAppWebViewSettings.windowType`
6+
- Fixed "Cloudflare Turnstile failure" [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738)
7+
- Fixed `InAppWebViewController.callAsyncJavaScript` Android-issue when the last line of the `functionBody` parameter includes a code comment
8+
9+
### BREAKING CHANGES
10+
11+
- Default value of `InAppWebViewSettings.windowType` is `WindowType.WINDOW`
12+
113
## 6.0.0-beta.32
214

315
- Updated minimum platform interface and implementation versions
@@ -17,7 +29,7 @@
1729
- Fixed "onClosed not considering back navigation or up button / close button in ChromeSafariBrowser when using noHistory: true" [#1882](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1882)
1830
- Merged "Fixed error in InterceptAjaxRequestJS 'Failed to set responseType property'" [#1904](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1904) (thanks to [EArminjon](https://github.com/EArminjon))
1931

20-
### BREAKING CHANGE
32+
### BREAKING CHANGES
2133

2234
- Due to Flutter platform channels async nature, using `useShouldInterceptAjaxRequest: true` would break sync ajax requests, so that the `XMLHttpRequest.send()` will not wait for the response. To fix this issue, the default value of `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` is `true`. To intercept also sync ajax requests, this value should be `false`.
2335

flutter_inappwebview/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

flutter_inappwebview/example/integration_test/in_app_webview/on_received_icon.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ void onReceivedIcon() {
2626
pageLoaded.complete();
2727
},
2828
onReceivedIcon: (controller, icon) {
29-
onReceivedIconCompleter.complete(icon);
29+
if (!onReceivedIconCompleter.isCompleted) {
30+
onReceivedIconCompleter.complete(icon);
31+
}
3032
},
3133
),
3234
),

flutter_inappwebview/example/lib/in_app_browser_example.screen.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class MyInAppBrowser extends InAppBrowser {
6161
print("\n\nOverride ${navigationAction.request.url}\n\n");
6262
return NavigationActionPolicy.ALLOW;
6363
}
64+
65+
void onMainWindowWillClose() {
66+
close();
67+
}
6468
}
6569

6670
class InAppBrowserExampleScreen extends StatefulWidget {

flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
116116
InAppWebView(
117117
key: webViewKey,
118118
initialUrlRequest:
119-
URLRequest(url: WebUri('https://flutter.dev')),
119+
URLRequest(url: WebUri('https://google.com')),
120120
// initialUrlRequest:
121121
// URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
122122
// initialFile: "assets/index.html",

flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,7 @@ class InAppBrowser implements PlatformInAppBrowserEvents {
538538
NavigationAction navigationAction) {
539539
return null;
540540
}
541+
542+
@override
543+
void onMainWindowWillClose() {}
541544
}

flutter_inappwebview/pubspec.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_inappwebview
22
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
3-
version: 6.0.0-beta.32
3+
version: 6.0.0-rc.1
44
homepage: https://inappwebview.dev/
55
repository: https://github.com/pichillilorenzo/flutter_inappwebview
66
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
@@ -18,11 +18,11 @@ environment:
1818
dependencies:
1919
flutter:
2020
sdk: flutter
21-
flutter_inappwebview_platform_interface: ^1.0.6
22-
flutter_inappwebview_android: ^1.0.8
23-
flutter_inappwebview_ios: ^1.0.9
24-
flutter_inappwebview_macos: ^1.0.7
25-
flutter_inappwebview_web: ^1.0.4
21+
flutter_inappwebview_platform_interface: ^1.0.7
22+
flutter_inappwebview_android: ^1.0.9
23+
flutter_inappwebview_ios: ^1.0.10
24+
flutter_inappwebview_macos: ^1.0.8
25+
flutter_inappwebview_web: ^1.0.5
2626

2727
dev_dependencies:
2828
flutter_test:

flutter_inappwebview_android/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.0.9
2+
3+
- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7`
4+
- Fixed "Cloudflare Turnstile failure" [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738)
5+
- Fixed `InAppWebViewController.callAsyncJavaScript` issue when the last line of the `functionBody` parameter includes a code comment
6+
17
## 1.0.8
28

39
- Implemented `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests`

flutter_inappwebview_android/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/ConsoleLogJS.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public class ConsoleLogJS {
1515
);
1616

1717
public static final String CONSOLE_LOG_JS_SOURCE = "(function(console) {" +
18+
" function _buildMessage(args) {" +
19+
" var message = '';" +
20+
" for (var i in args) {" +
21+
" try {" +
22+
" message += message === '' ? args[i] : ' ' + args[i];" +
23+
" } catch(ignored) {}" +
24+
" }" +
25+
" return message;" +
26+
" }" +
1827
" var oldLogs = {" +
1928
" 'log': console.log," +
2029
" 'debug': console.debug," +
@@ -25,16 +34,7 @@ public class ConsoleLogJS {
2534
" for (var k in oldLogs) {" +
2635
" (function(oldLog) {" +
2736
" console[oldLog] = function() {" +
28-
" var message = '';" +
29-
" for (var i in arguments) {" +
30-
" if (message == '') {" +
31-
" message += arguments[i];" +
32-
" }" +
33-
" else {" +
34-
" message += ' ' + arguments[i];" +
35-
" }" +
36-
" }" +
37-
" oldLogs[oldLog].call(console, message);" +
37+
" oldLogs[oldLog].call(console, _buildMessage(arguments));" +
3838
" }" +
3939
" })(k);" +
4040
" }" +

flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class PluginScriptsUtil {
1818

1919
public static final String CALL_ASYNC_JAVA_SCRIPT_WRAPPER_JS_SOURCE = "(function(obj) {" +
2020
" (async function(" + VAR_FUNCTION_ARGUMENT_NAMES + ") {" +
21-
" " + VAR_FUNCTION_BODY +
21+
" \n" + VAR_FUNCTION_BODY + "\n" +
2222
" })(" + VAR_FUNCTION_ARGUMENT_VALUES + ").then(function(value) {" +
2323
" window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('callAsyncJavaScript', {'value': value, 'error': null, 'resultUuid': '" + VAR_RESULT_UUID + "'});" +
2424
" }).catch(function(error) {" +

flutter_inappwebview_android/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_inappwebview_android
22
description: Android implementation of the flutter_inappwebview plugin.
3-
version: 1.0.8
3+
version: 1.0.9
44
homepage: https://inappwebview.dev/
55
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android
66
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
@@ -18,7 +18,7 @@ environment:
1818
dependencies:
1919
flutter:
2020
sdk: flutter
21-
flutter_inappwebview_platform_interface: ^1.0.6
21+
flutter_inappwebview_platform_interface: ^1.0.7
2222

2323
dev_dependencies:
2424
flutter_test:

flutter_inappwebview_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.10
2+
3+
- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7`
4+
15
## 1.0.9
26

37
- Implemented `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests`

flutter_inappwebview_ios/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

flutter_inappwebview_ios/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_inappwebview_ios
22
description: iOS implementation of the flutter_inappwebview plugin.
3-
version: 1.0.9
3+
version: 1.0.10
44
homepage: https://inappwebview.dev/
55
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_ios
66
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
@@ -18,7 +18,7 @@ environment:
1818
dependencies:
1919
flutter:
2020
sdk: flutter
21-
flutter_inappwebview_platform_interface: ^1.0.6
21+
flutter_inappwebview_platform_interface: ^1.0.7
2222

2323
dev_dependencies:
2424
flutter_test:

flutter_inappwebview_macos/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.8
2+
3+
- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7`
4+
- Implemented `InAppBrowser.onMainWindowWillClose` event
5+
16
## 1.0.7
27

38
- Implemented `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests`
@@ -29,7 +34,7 @@
2934
## 1.0.1
3035

3136
- Added `PlatformPrintJobController.onComplete` setter
32-
- Updated `flutter_inappwebview_platform_interface` version dependency to `1.0.2`
37+
- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.2`
3338

3439
## 1.0.0
3540

flutter_inappwebview_macos/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController {
122122
}
123123
}
124124
break;
125+
case "onMainWindowWillClose":
126+
_debugLog(call.method, call.arguments);
127+
eventHandler?.onMainWindowWillClose();
128+
break;
125129
case "onExit":
126130
_debugLog(call.method, call.arguments);
127131
_isOpened = false;

flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserChannelDelegate.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public class InAppBrowserChannelDelegate : ChannelDelegate {
2525
channel?.invokeMethod("onMenuItemClicked", arguments: arguments)
2626
}
2727

28+
public func onMainWindowWillClose() {
29+
let arguments: [String: Any?] = [:]
30+
channel?.invokeMethod("onMainWindowWillClose", arguments: arguments)
31+
}
32+
2833
public func onExit() {
2934
let arguments: [String: Any?] = [:]
3035
channel?.invokeMethod("onExit", arguments: arguments)

flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ public class InAppBrowserManager: ChannelDelegate {
8686

8787
if #available(macOS 10.12, *), browserSettings.windowType == .tabbed {
8888
NSApplication.shared.mainWindow?.addTabbedWindow(window, ordered: .above)
89-
} else {
89+
} else if browserSettings.windowType == .child {
9090
NSApplication.shared.mainWindow?.addChildWindow(window, ordered: .above)
91+
} else {
92+
window.windowController?.showWindow(self)
9193
}
9294

9395
if browserSettings.hidden {

flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserSettings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class InAppBrowserSettings: ISettings<InAppBrowserWebViewController> {
1616
var hideUrlBar = false
1717
var hideProgressBar = false
1818
var toolbarTopFixedTitle: String?
19-
var windowType = InAppBrowserWindowType.child
19+
var windowType = InAppBrowserWindowType.window
2020
var windowAlphaValue = 1.0
2121
var _windowStyleMask: NSNumber?
2222
var windowStyleMask: NSWindow.StyleMask? {

flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserWindow.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class InAppBrowserWindow : NSWindow, NSWindowDelegate, NSToolbarDelegate,
6262
delegate = self
6363

6464
NotificationCenter.default.addObserver(self,
65-
selector: #selector(onMainWindowClose(_:)),
65+
selector: #selector(onMainWindowWillClose(_:)),
6666
name: NSWindow.willCloseNotification,
6767
object: NSApplication.shared.mainWindow)
6868

@@ -348,13 +348,17 @@ public class InAppBrowserWindow : NSWindow, NSWindowDelegate, NSToolbarDelegate,
348348
dispose()
349349
}
350350

351-
@objc func onMainWindowClose(_ notification: Notification) {
352-
close()
351+
@objc func onMainWindowWillClose(_ notification: Notification) {
352+
if let webViewController = contentViewController as? InAppBrowserWebViewController {
353+
webViewController.channelDelegate?.onMainWindowWillClose()
354+
}
353355
}
354356

355-
356357
public func dispose() {
357358
delegate = nil
359+
NotificationCenter.default.removeObserver(self,
360+
name: NSWindow.willCloseNotification,
361+
object: NSApplication.shared.mainWindow)
358362
if let webViewController = contentViewController as? InAppBrowserWebViewController {
359363
webViewController.dispose()
360364
}

flutter_inappwebview_macos/macos/Classes/Types/InAppBrowserWindowType.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import Foundation
99

1010
public enum InAppBrowserWindowType: String {
11+
case window = "WINDOW"
1112
case child = "CHILD"
1213
case tabbed = "TABBED"
1314
}

flutter_inappwebview_macos/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_inappwebview_macos
22
description: macOS implementation of the flutter_inappwebview plugin.
3-
version: 1.0.7
3+
version: 1.0.8
44
homepage: https://inappwebview.dev/
55
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_macos
66
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
@@ -18,7 +18,7 @@ environment:
1818
dependencies:
1919
flutter:
2020
sdk: flutter
21-
flutter_inappwebview_platform_interface: ^1.0.6
21+
flutter_inappwebview_platform_interface: ^1.0.7
2222

2323
dev_dependencies:
2424
flutter_test:

flutter_inappwebview_platform_interface/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.7
2+
3+
- Added `InAppBrowser.onMainWindowWillClose` event
4+
- Added `WindowType.WINDOW` for `InAppWebViewSettings.windowType`
5+
16
## 1.0.6
27

38
- Added `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` [#1905](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1905)

flutter_inappwebview_platform_interface/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 Lorenzo Pichilli
189+
Copyright 2023 Lorenzo Pichilli
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class InAppBrowserSettings_
254254
ModalTransitionStyle_? transitionStyle;
255255

256256
///How the browser window should be added to the main window.
257-
///The default value is [WindowType.CHILD].
257+
///The default value is [WindowType.WINDOW].
258258
///
259259
///**Officially Supported Platforms/Implementations**:
260260
///- MacOS

flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)