windows: completed CookieManager implementation, added WebViewEnvironment getAvailableVersion and compareBrowserVersions methods
This commit is contained in:
parent
7da9cb2643
commit
ade2edfb7d
|
@ -24,6 +24,9 @@ Future main() async {
|
||||||
// await Permission.storage.request();
|
// await Permission.storage.request();
|
||||||
|
|
||||||
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) {
|
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) {
|
||||||
|
final availableVersion = await WebViewEnvironment.getAvailableVersion();
|
||||||
|
assert(availableVersion != null, 'Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.');
|
||||||
|
|
||||||
webViewEnvironment = await WebViewEnvironment.create(settings:
|
webViewEnvironment = await WebViewEnvironment.create(settings:
|
||||||
WebViewEnvironmentSettings(
|
WebViewEnvironmentSettings(
|
||||||
userDataFolder: 'custom_path'
|
userDataFolder: 'custom_path'
|
||||||
|
|
|
@ -30,6 +30,14 @@ class WebViewEnvironment {
|
||||||
return WebViewEnvironment.fromPlatform(platform: await PlatformWebViewEnvironment.static().create(settings: settings));
|
return WebViewEnvironment.fromPlatform(platform: await PlatformWebViewEnvironment.static().create(settings: settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
|
||||||
|
static Future<String?> getAvailableVersion(
|
||||||
|
{String? browserExecutableFolder}) => PlatformWebViewEnvironment.static().getAvailableVersion(browserExecutableFolder: browserExecutableFolder);
|
||||||
|
|
||||||
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
|
||||||
|
static Future<int?> compareBrowserVersions(
|
||||||
|
{required String version1, required String version2}) => PlatformWebViewEnvironment.static().compareBrowserVersions(version1: version1, version2: version2);
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
|
||||||
Future<void> dispose() => platform.dispose();
|
Future<void> dispose() => platform.dispose();
|
||||||
}
|
}
|
|
@ -155,7 +155,7 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [AndroidWebStorage].
|
/// Creates a new [AndroidWebStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [AndroidWebStorage] in `flutter_inappwebview` instead.
|
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
AndroidWebStorage createPlatformWebStorage(
|
AndroidWebStorage createPlatformWebStorage(
|
||||||
PlatformWebStorageCreationParams params,
|
PlatformWebStorageCreationParams params,
|
||||||
|
@ -166,7 +166,7 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [AndroidLocalStorage].
|
/// Creates a new [AndroidLocalStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [AndroidLocalStorage] in `flutter_inappwebview` instead.
|
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
AndroidLocalStorage createPlatformLocalStorage(
|
AndroidLocalStorage createPlatformLocalStorage(
|
||||||
PlatformLocalStorageCreationParams params,
|
PlatformLocalStorageCreationParams params,
|
||||||
|
@ -177,7 +177,7 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [AndroidSessionStorage].
|
/// Creates a new [AndroidSessionStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
|
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
AndroidSessionStorage createPlatformSessionStorage(
|
AndroidSessionStorage createPlatformSessionStorage(
|
||||||
PlatformSessionStorageCreationParams params,
|
PlatformSessionStorageCreationParams params,
|
||||||
|
|
|
@ -150,7 +150,7 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [IOSWebStorage].
|
/// Creates a new [IOSWebStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [IOSWebStorage] in `flutter_inappwebview` instead.
|
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
IOSWebStorage createPlatformWebStorage(
|
IOSWebStorage createPlatformWebStorage(
|
||||||
PlatformWebStorageCreationParams params,
|
PlatformWebStorageCreationParams params,
|
||||||
|
@ -161,7 +161,7 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [IOSLocalStorage].
|
/// Creates a new [IOSLocalStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [IOSLocalStorage] in `flutter_inappwebview` instead.
|
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
IOSLocalStorage createPlatformLocalStorage(
|
IOSLocalStorage createPlatformLocalStorage(
|
||||||
PlatformLocalStorageCreationParams params,
|
PlatformLocalStorageCreationParams params,
|
||||||
|
@ -172,7 +172,7 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [IOSSessionStorage].
|
/// Creates a new [IOSSessionStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
|
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
IOSSessionStorage createPlatformSessionStorage(
|
IOSSessionStorage createPlatformSessionStorage(
|
||||||
PlatformSessionStorageCreationParams params,
|
PlatformSessionStorageCreationParams params,
|
||||||
|
|
|
@ -138,7 +138,7 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [MacOSWebStorage].
|
/// Creates a new [MacOSWebStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [MacOSWebStorage] in `flutter_inappwebview` instead.
|
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
MacOSWebStorage createPlatformWebStorage(
|
MacOSWebStorage createPlatformWebStorage(
|
||||||
PlatformWebStorageCreationParams params,
|
PlatformWebStorageCreationParams params,
|
||||||
|
@ -149,7 +149,7 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [MacOSLocalStorage].
|
/// Creates a new [MacOSLocalStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [MacOSLocalStorage] in `flutter_inappwebview` instead.
|
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
MacOSLocalStorage createPlatformLocalStorage(
|
MacOSLocalStorage createPlatformLocalStorage(
|
||||||
PlatformLocalStorageCreationParams params,
|
PlatformLocalStorageCreationParams params,
|
||||||
|
@ -160,7 +160,7 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
/// Creates a new [MacOSSessionStorage].
|
/// Creates a new [MacOSSessionStorage].
|
||||||
///
|
///
|
||||||
/// This function should only be called by the app-facing package.
|
/// This function should only be called by the app-facing package.
|
||||||
/// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead.
|
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
|
||||||
@override
|
@override
|
||||||
MacOSSessionStorage createPlatformSessionStorage(
|
MacOSSessionStorage createPlatformSessionStorage(
|
||||||
PlatformSessionStorageCreationParams params,
|
PlatformSessionStorageCreationParams params,
|
||||||
|
|
|
@ -40,6 +40,7 @@ class PlatformCookieManagerCreationParams {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformCookieManager extends PlatformInterface {
|
abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
/// Creates a new [PlatformCookieManager]
|
/// Creates a new [PlatformCookieManager]
|
||||||
|
@ -94,6 +95,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
|
///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
|
||||||
///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
|
///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
Future<bool> setCookie(
|
Future<bool> setCookie(
|
||||||
{required WebUri url,
|
{required WebUri url,
|
||||||
|
@ -133,6 +135,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
|
///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
|
||||||
///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
|
///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
Future<List<Cookie>> getCookies(
|
Future<List<Cookie>> getCookies(
|
||||||
{required WebUri url,
|
{required WebUri url,
|
||||||
|
@ -163,6 +166,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
Future<Cookie?> getCookie(
|
Future<Cookie?> getCookie(
|
||||||
{required WebUri url,
|
{required WebUri url,
|
||||||
|
@ -198,6 +202,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
|
///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
|
||||||
///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
|
///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
Future<bool> deleteCookie(
|
Future<bool> deleteCookie(
|
||||||
{required WebUri url,
|
{required WebUri url,
|
||||||
|
@ -235,6 +240,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
Future<bool> deleteCookies(
|
Future<bool> deleteCookies(
|
||||||
{required WebUri url,
|
{required WebUri url,
|
||||||
|
@ -261,6 +267,7 @@ abstract class PlatformCookieManager extends PlatformInterface {
|
||||||
///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)))
|
///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)))
|
||||||
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
|
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
|
||||||
///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
|
///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
Future<bool> deleteAllCookies() {
|
Future<bool> deleteAllCookies() {
|
||||||
throw UnimplementedError(
|
throw UnimplementedError(
|
||||||
|
|
|
@ -14,7 +14,8 @@ class Cookie_ {
|
||||||
IOSPlatform(),
|
IOSPlatform(),
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(),
|
AndroidPlatform(),
|
||||||
WebPlatform()
|
WebPlatform(),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
@ -23,7 +24,8 @@ class Cookie_ {
|
||||||
IOSPlatform(),
|
IOSPlatform(),
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(),
|
AndroidPlatform(),
|
||||||
WebPlatform()
|
WebPlatform(),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
dynamic value;
|
dynamic value;
|
||||||
|
|
||||||
|
@ -33,12 +35,17 @@ class Cookie_ {
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(
|
AndroidPlatform(
|
||||||
note:
|
note:
|
||||||
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
|
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
int? expiresDate;
|
int? expiresDate;
|
||||||
|
|
||||||
///Indicates if the cookie is a session only cookie.
|
///Indicates if the cookie is a session only cookie.
|
||||||
@SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()])
|
@SupportedPlatforms(platforms: [
|
||||||
|
IOSPlatform(),
|
||||||
|
MacOSPlatform(),
|
||||||
|
WindowsPlatform()
|
||||||
|
])
|
||||||
bool? isSessionOnly;
|
bool? isSessionOnly;
|
||||||
|
|
||||||
///The cookie domain.
|
///The cookie domain.
|
||||||
|
@ -47,7 +54,8 @@ class Cookie_ {
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(
|
AndroidPlatform(
|
||||||
note:
|
note:
|
||||||
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
|
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
String? domain;
|
String? domain;
|
||||||
|
|
||||||
|
@ -57,7 +65,8 @@ class Cookie_ {
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(
|
AndroidPlatform(
|
||||||
note:
|
note:
|
||||||
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
|
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
HTTPCookieSameSitePolicy_? sameSite;
|
HTTPCookieSameSitePolicy_? sameSite;
|
||||||
|
|
||||||
|
@ -67,7 +76,8 @@ class Cookie_ {
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(
|
AndroidPlatform(
|
||||||
note:
|
note:
|
||||||
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
|
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
bool? isSecure;
|
bool? isSecure;
|
||||||
|
|
||||||
|
@ -77,7 +87,8 @@ class Cookie_ {
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(
|
AndroidPlatform(
|
||||||
note:
|
note:
|
||||||
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
|
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
bool? isHttpOnly;
|
bool? isHttpOnly;
|
||||||
|
|
||||||
|
@ -87,7 +98,8 @@ class Cookie_ {
|
||||||
MacOSPlatform(),
|
MacOSPlatform(),
|
||||||
AndroidPlatform(
|
AndroidPlatform(
|
||||||
note:
|
note:
|
||||||
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported.")
|
"available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported."),
|
||||||
|
WindowsPlatform()
|
||||||
])
|
])
|
||||||
String? path;
|
String? path;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Cookie {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
|
///- Windows
|
||||||
String? domain;
|
String? domain;
|
||||||
|
|
||||||
///The cookie expiration date in milliseconds.
|
///The cookie expiration date in milliseconds.
|
||||||
|
@ -26,6 +27,7 @@ class Cookie {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
|
///- Windows
|
||||||
int? expiresDate;
|
int? expiresDate;
|
||||||
|
|
||||||
///Indicates if the cookie is a http only cookie.
|
///Indicates if the cookie is a http only cookie.
|
||||||
|
@ -36,6 +38,7 @@ class Cookie {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
|
///- Windows
|
||||||
bool? isHttpOnly;
|
bool? isHttpOnly;
|
||||||
|
|
||||||
///Indicates if the cookie is secure or not.
|
///Indicates if the cookie is secure or not.
|
||||||
|
@ -46,6 +49,7 @@ class Cookie {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
|
///- Windows
|
||||||
bool? isSecure;
|
bool? isSecure;
|
||||||
|
|
||||||
///Indicates if the cookie is a session only cookie.
|
///Indicates if the cookie is a session only cookie.
|
||||||
|
@ -53,6 +57,7 @@ class Cookie {
|
||||||
///**Officially Supported Platforms/Implementations**:
|
///**Officially Supported Platforms/Implementations**:
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
|
///- Windows
|
||||||
bool? isSessionOnly;
|
bool? isSessionOnly;
|
||||||
|
|
||||||
///The cookie name.
|
///The cookie name.
|
||||||
|
@ -62,6 +67,7 @@ class Cookie {
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
///- Web but iframe requires same origin
|
///- Web but iframe requires same origin
|
||||||
|
///- Windows
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
///The cookie path.
|
///The cookie path.
|
||||||
|
@ -72,6 +78,7 @@ class Cookie {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
|
///- Windows
|
||||||
String? path;
|
String? path;
|
||||||
|
|
||||||
///The cookie same site policy.
|
///The cookie same site policy.
|
||||||
|
@ -82,6 +89,7 @@ class Cookie {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
|
///- Windows
|
||||||
HTTPCookieSameSitePolicy? sameSite;
|
HTTPCookieSameSitePolicy? sameSite;
|
||||||
|
|
||||||
///The cookie value.
|
///The cookie value.
|
||||||
|
@ -91,6 +99,7 @@ class Cookie {
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Android native WebView
|
///- Android native WebView
|
||||||
///- Web but iframe requires same origin
|
///- Web but iframe requires same origin
|
||||||
|
///- Windows
|
||||||
dynamic value;
|
dynamic value;
|
||||||
Cookie(
|
Cookie(
|
||||||
{this.domain,
|
{this.domain,
|
||||||
|
|
|
@ -33,6 +33,7 @@ class PlatformWebStorageCreationParams {
|
||||||
///- iOS
|
///- iOS
|
||||||
///- MacOS
|
///- MacOS
|
||||||
///- Web
|
///- Web
|
||||||
|
///- Windows
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
abstract class PlatformWebStorage extends PlatformInterface
|
abstract class PlatformWebStorage extends PlatformInterface
|
||||||
implements Disposable {
|
implements Disposable {
|
||||||
|
|
|
@ -20,6 +20,7 @@ class PlatformWebViewEnvironmentCreationParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
///Controls a WebView Environment used by WebView instances.
|
///Controls a WebView Environment used by WebView instances.
|
||||||
|
///Use [dispose] when not needed anymore to release references.
|
||||||
///
|
///
|
||||||
///**Officially Supported Platforms/Implementations**:
|
///**Officially Supported Platforms/Implementations**:
|
||||||
///- Windows
|
///- Windows
|
||||||
|
@ -102,6 +103,40 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface
|
||||||
'create is not implemented on the current platform');
|
'create is not implemented on the current platform');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion}
|
||||||
|
///Get the browser version info including channel name if it is not the WebView2 Runtime.
|
||||||
|
///
|
||||||
|
///Channel names are Beta, Dev, and Canary.
|
||||||
|
///If an override exists for the browserExecutableFolder or the channel preference, the override is used.
|
||||||
|
///If an override is not specified, then the parameter value passed to [getAvailableVersion] is used.
|
||||||
|
///Returns `null` if it fails to find an installed WebView2 runtime or non-stable Microsoft Edge installation.
|
||||||
|
///
|
||||||
|
///**Officially Supported Platforms/Implementations**:
|
||||||
|
///- Windows ([Official API - GetAvailableCoreWebView2BrowserVersionString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions))
|
||||||
|
///{@endtemplate}
|
||||||
|
Future<String?> getAvailableVersion(
|
||||||
|
{String? browserExecutableFolder}) {
|
||||||
|
throw UnimplementedError(
|
||||||
|
'getAvailableVersion is not implemented on the current platform');
|
||||||
|
}
|
||||||
|
|
||||||
|
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.compareBrowserVersions}
|
||||||
|
///This method is for anyone want to compare version correctly to determine which version is newer, older or same.
|
||||||
|
///
|
||||||
|
///Use it to determine whether to use webview2 or certain feature based upon version.
|
||||||
|
///Sets the value of result to `-1`, `0` or `1` if version1 is less than, equal or greater than version2 respectively.
|
||||||
|
///Returns `null` if it fails to parse any of the version strings.
|
||||||
|
///Directly use the version info obtained from [getAvailableVersion] with input, channel information is ignored.
|
||||||
|
///
|
||||||
|
///**Officially Supported Platforms/Implementations**:
|
||||||
|
///- Windows ([Official API - CompareBrowserVersions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions))
|
||||||
|
///{@endtemplate}
|
||||||
|
Future<int?> compareBrowserVersions(
|
||||||
|
{required String version1, required String version2}) {
|
||||||
|
throw UnimplementedError(
|
||||||
|
'compareBrowserVersions is not implemented on the current platform');
|
||||||
|
}
|
||||||
|
|
||||||
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
|
///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose}
|
||||||
///Disposes the WebView Environment reference.
|
///Disposes the WebView Environment reference.
|
||||||
///{@endtemplate}
|
///{@endtemplate}
|
||||||
|
|
|
@ -221,14 +221,6 @@ class WindowsCookieManager extends PlatformCookieManager
|
||||||
return await channel?.invokeMethod<bool>('deleteAllCookies', args) ?? false;
|
return await channel?.invokeMethod<bool>('deleteAllCookies', args) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<bool> removeSessionCookies() async {
|
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
|
||||||
args.putIfAbsent('webViewEnvironmentId', () => params.webViewEnvironment?.id);
|
|
||||||
return await channel?.invokeMethod<bool>('removeSessionCookies', args) ??
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// empty
|
// empty
|
||||||
|
|
|
@ -8,18 +8,18 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla
|
||||||
/// value to avoid breaking changes. See [PlatformFindInteractionControllerCreationParams] for
|
/// value to avoid breaking changes. See [PlatformFindInteractionControllerCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSFindInteractionControllerCreationParams
|
class WindowsFindInteractionControllerCreationParams
|
||||||
extends PlatformFindInteractionControllerCreationParams {
|
extends PlatformFindInteractionControllerCreationParams {
|
||||||
/// Creates a new [MacOSFindInteractionControllerCreationParams] instance.
|
/// Creates a new [WindowsFindInteractionControllerCreationParams] instance.
|
||||||
const MacOSFindInteractionControllerCreationParams(
|
const WindowsFindInteractionControllerCreationParams(
|
||||||
{super.onFindResultReceived});
|
{super.onFindResultReceived});
|
||||||
|
|
||||||
/// Creates a [MacOSFindInteractionControllerCreationParams] instance based on [PlatformFindInteractionControllerCreationParams].
|
/// Creates a [WindowsFindInteractionControllerCreationParams] instance based on [PlatformFindInteractionControllerCreationParams].
|
||||||
factory MacOSFindInteractionControllerCreationParams.fromPlatformFindInteractionControllerCreationParams(
|
factory WindowsFindInteractionControllerCreationParams.fromPlatformFindInteractionControllerCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformFindInteractionControllerCreationParams params) {
|
PlatformFindInteractionControllerCreationParams params) {
|
||||||
return MacOSFindInteractionControllerCreationParams(
|
return WindowsFindInteractionControllerCreationParams(
|
||||||
onFindResultReceived: params.onFindResultReceived);
|
onFindResultReceived: params.onFindResultReceived);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ class WindowsFindInteractionController extends PlatformFindInteractionController
|
||||||
WindowsFindInteractionController(
|
WindowsFindInteractionController(
|
||||||
PlatformFindInteractionControllerCreationParams params)
|
PlatformFindInteractionControllerCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSFindInteractionControllerCreationParams
|
params is WindowsFindInteractionControllerCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSFindInteractionControllerCreationParams
|
: WindowsFindInteractionControllerCreationParams
|
||||||
.fromPlatformFindInteractionControllerCreationParams(params),
|
.fromPlatformFindInteractionControllerCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,38 +3,38 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSHttpAuthCredentialDatabase].
|
/// Object specifying creation parameters for creating a [WindowsHttpAuthCredentialDatabase].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformHttpAuthCredentialDatabaseCreationParams] for
|
/// value to avoid breaking changes. See [PlatformHttpAuthCredentialDatabaseCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSHttpAuthCredentialDatabaseCreationParams
|
class WindowsHttpAuthCredentialDatabaseCreationParams
|
||||||
extends PlatformHttpAuthCredentialDatabaseCreationParams {
|
extends PlatformHttpAuthCredentialDatabaseCreationParams {
|
||||||
/// Creates a new [MacOSHttpAuthCredentialDatabaseCreationParams] instance.
|
/// Creates a new [WindowsHttpAuthCredentialDatabaseCreationParams] instance.
|
||||||
const MacOSHttpAuthCredentialDatabaseCreationParams(
|
const WindowsHttpAuthCredentialDatabaseCreationParams(
|
||||||
// This parameter prevents breaking changes later.
|
// This parameter prevents breaking changes later.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformHttpAuthCredentialDatabaseCreationParams params,
|
PlatformHttpAuthCredentialDatabaseCreationParams params,
|
||||||
) : super();
|
) : super();
|
||||||
|
|
||||||
/// Creates a [MacOSHttpAuthCredentialDatabaseCreationParams] instance based on [PlatformHttpAuthCredentialDatabaseCreationParams].
|
/// Creates a [WindowsHttpAuthCredentialDatabaseCreationParams] instance based on [PlatformHttpAuthCredentialDatabaseCreationParams].
|
||||||
factory MacOSHttpAuthCredentialDatabaseCreationParams.fromPlatformHttpAuthCredentialDatabaseCreationParams(
|
factory WindowsHttpAuthCredentialDatabaseCreationParams.fromPlatformHttpAuthCredentialDatabaseCreationParams(
|
||||||
PlatformHttpAuthCredentialDatabaseCreationParams params) {
|
PlatformHttpAuthCredentialDatabaseCreationParams params) {
|
||||||
return MacOSHttpAuthCredentialDatabaseCreationParams(params);
|
return WindowsHttpAuthCredentialDatabaseCreationParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase}
|
///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase}
|
||||||
class MacOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase
|
class WindowsHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase
|
||||||
with ChannelController {
|
with ChannelController {
|
||||||
/// Creates a new [MacOSHttpAuthCredentialDatabase].
|
/// Creates a new [WindowsHttpAuthCredentialDatabase].
|
||||||
MacOSHttpAuthCredentialDatabase(
|
WindowsHttpAuthCredentialDatabase(
|
||||||
PlatformHttpAuthCredentialDatabaseCreationParams params)
|
PlatformHttpAuthCredentialDatabaseCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSHttpAuthCredentialDatabaseCreationParams
|
params is WindowsHttpAuthCredentialDatabaseCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSHttpAuthCredentialDatabaseCreationParams
|
: WindowsHttpAuthCredentialDatabaseCreationParams
|
||||||
.fromPlatformHttpAuthCredentialDatabaseCreationParams(params),
|
.fromPlatformHttpAuthCredentialDatabaseCreationParams(params),
|
||||||
) {
|
) {
|
||||||
channel = const MethodChannel(
|
channel = const MethodChannel(
|
||||||
|
@ -43,16 +43,16 @@ class MacOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase
|
||||||
initMethodCallHandler();
|
initMethodCallHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
static MacOSHttpAuthCredentialDatabase? _instance;
|
static WindowsHttpAuthCredentialDatabase? _instance;
|
||||||
|
|
||||||
///Gets the database shared instance.
|
///Gets the database shared instance.
|
||||||
static MacOSHttpAuthCredentialDatabase instance() {
|
static WindowsHttpAuthCredentialDatabase instance() {
|
||||||
return (_instance != null) ? _instance! : _init();
|
return (_instance != null) ? _instance! : _init();
|
||||||
}
|
}
|
||||||
|
|
||||||
static MacOSHttpAuthCredentialDatabase _init() {
|
static WindowsHttpAuthCredentialDatabase _init() {
|
||||||
_instance = MacOSHttpAuthCredentialDatabase(
|
_instance = WindowsHttpAuthCredentialDatabase(
|
||||||
MacOSHttpAuthCredentialDatabaseCreationParams(
|
WindowsHttpAuthCredentialDatabaseCreationParams(
|
||||||
const PlatformHttpAuthCredentialDatabaseCreationParams()));
|
const PlatformHttpAuthCredentialDatabaseCreationParams()));
|
||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,6 @@ class MacOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
extension InternalHttpAuthCredentialDatabase
|
extension InternalHttpAuthCredentialDatabase
|
||||||
on MacOSHttpAuthCredentialDatabase {
|
on WindowsHttpAuthCredentialDatabase {
|
||||||
get handleMethod => _handleMethod;
|
get handleMethod => _handleMethod;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
Set<String> _webMessageListenerObjNames = Set();
|
Set<String> _webMessageListenerObjNames = Set();
|
||||||
Map<String, ScriptHtmlTagAttributes> _injectedScriptsFromURL = {};
|
Map<String, ScriptHtmlTagAttributes> _injectedScriptsFromURL = {};
|
||||||
Set<WindowsWebMessageChannel> _webMessageChannels = Set();
|
Set<WindowsWebMessageChannel> _webMessageChannels = Set();
|
||||||
Set<MacOSWebMessageListener> _webMessageListeners = Set();
|
Set<WindowsWebMessageListener> _webMessageListeners = Set();
|
||||||
|
|
||||||
// static map that contains the properties to be saved and restored for keep alive feature
|
// static map that contains the properties to be saved and restored for keep alive feature
|
||||||
static final Map<InAppWebViewKeepAlive, InAppWebViewControllerKeepAliveProps?>
|
static final Map<InAppWebViewKeepAlive, InAppWebViewControllerKeepAliveProps?>
|
||||||
|
@ -89,7 +89,7 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
dynamic _controllerFromPlatform;
|
dynamic _controllerFromPlatform;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
late MacOSWebStorage webStorage;
|
late WindowsWebStorage webStorage;
|
||||||
|
|
||||||
WindowsInAppWebViewController(
|
WindowsInAppWebViewController(
|
||||||
PlatformInAppWebViewControllerCreationParams params)
|
PlatformInAppWebViewControllerCreationParams params)
|
||||||
|
@ -161,9 +161,9 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
_controllerFromPlatform =
|
_controllerFromPlatform =
|
||||||
params.webviewParams?.controllerFromPlatform?.call(this) ?? this;
|
params.webviewParams?.controllerFromPlatform?.call(this) ?? this;
|
||||||
|
|
||||||
webStorage = MacOSWebStorage(MacOSWebStorageCreationParams(
|
webStorage = WindowsWebStorage(WindowsWebStorageCreationParams(
|
||||||
localStorage: MacOSLocalStorage.defaultStorage(controller: this),
|
localStorage: WindowsLocalStorage.defaultStorage(controller: this),
|
||||||
sessionStorage: MacOSSessionStorage.defaultStorage(controller: this)));
|
sessionStorage: WindowsSessionStorage.defaultStorage(controller: this)));
|
||||||
|
|
||||||
if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) {
|
if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) {
|
||||||
final keepAlive =
|
final keepAlive =
|
||||||
|
@ -189,7 +189,7 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
_webMessageChannels =
|
_webMessageChannels =
|
||||||
props.webMessageChannels as Set<WindowsWebMessageChannel>;
|
props.webMessageChannels as Set<WindowsWebMessageChannel>;
|
||||||
_webMessageListeners =
|
_webMessageListeners =
|
||||||
props.webMessageListeners as Set<MacOSWebMessageListener>;
|
props.webMessageListeners as Set<WindowsWebMessageListener>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1311,9 +1311,9 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
String? url = call.arguments["url"];
|
String? url = call.arguments["url"];
|
||||||
String? printJobId = call.arguments["printJobId"];
|
String? printJobId = call.arguments["printJobId"];
|
||||||
WebUri? uri = url != null ? WebUri(url) : null;
|
WebUri? uri = url != null ? WebUri(url) : null;
|
||||||
MacOSPrintJobController? printJob = printJobId != null
|
WindowsPrintJobController? printJob = printJobId != null
|
||||||
? MacOSPrintJobController(
|
? WindowsPrintJobController(
|
||||||
MacOSPrintJobControllerCreationParams(id: printJobId))
|
WindowsPrintJobControllerCreationParams(id: printJobId))
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (webviewParams != null) {
|
if (webviewParams != null) {
|
||||||
|
@ -2139,14 +2139,14 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MacOSPrintJobController?> printCurrentPage(
|
Future<WindowsPrintJobController?> printCurrentPage(
|
||||||
{PrintJobSettings? settings}) async {
|
{PrintJobSettings? settings}) async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
args.putIfAbsent("settings", () => settings?.toMap());
|
args.putIfAbsent("settings", () => settings?.toMap());
|
||||||
String? jobId =
|
String? jobId =
|
||||||
await channel?.invokeMethod<String?>('printCurrentPage', args);
|
await channel?.invokeMethod<String?>('printCurrentPage', args);
|
||||||
if (jobId != null) {
|
if (jobId != null) {
|
||||||
return MacOSPrintJobController(
|
return WindowsPrintJobController(
|
||||||
PlatformPrintJobControllerCreationParams(id: jobId));
|
PlatformPrintJobControllerCreationParams(id: jobId));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -2494,7 +2494,7 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController
|
||||||
!_webMessageListenerObjNames
|
!_webMessageListenerObjNames
|
||||||
.contains(webMessageListener.params.jsObjectName),
|
.contains(webMessageListener.params.jsObjectName),
|
||||||
"jsObjectName ${webMessageListener.params.jsObjectName} was already added.");
|
"jsObjectName ${webMessageListener.params.jsObjectName} was already added.");
|
||||||
_webMessageListeners.add(webMessageListener as MacOSWebMessageListener);
|
_webMessageListeners.add(webMessageListener as WindowsWebMessageListener);
|
||||||
_webMessageListenerObjNames.add(webMessageListener.params.jsObjectName);
|
_webMessageListenerObjNames.add(webMessageListener.params.jsObjectName);
|
||||||
|
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'in_app_webview/in_app_webview.dart';
|
||||||
import 'in_app_webview/in_app_webview_controller.dart';
|
import 'in_app_webview/in_app_webview_controller.dart';
|
||||||
import 'in_app_webview/headless_in_app_webview.dart';
|
import 'in_app_webview/headless_in_app_webview.dart';
|
||||||
import 'webview_environment/webview_environment.dart';
|
import 'webview_environment/webview_environment.dart';
|
||||||
|
import 'web_storage/web_storage.dart';
|
||||||
|
|
||||||
/// Implementation of [InAppWebViewPlatform] using the WebKit API.
|
/// Implementation of [InAppWebViewPlatform] using the WebKit API.
|
||||||
class WindowsInAppWebViewPlatform extends InAppWebViewPlatform {
|
class WindowsInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
|
@ -107,4 +108,37 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform {
|
||||||
WindowsWebViewEnvironment createPlatformWebViewEnvironmentStatic() {
|
WindowsWebViewEnvironment createPlatformWebViewEnvironmentStatic() {
|
||||||
return WindowsWebViewEnvironment.static();
|
return WindowsWebViewEnvironment.static();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new [WindowsWebStorage].
|
||||||
|
///
|
||||||
|
/// This function should only be called by the app-facing package.
|
||||||
|
/// Look at using [WebStorage] in `flutter_inappwebview` instead.
|
||||||
|
@override
|
||||||
|
WindowsWebStorage createPlatformWebStorage(
|
||||||
|
PlatformWebStorageCreationParams params,
|
||||||
|
) {
|
||||||
|
return WindowsWebStorage(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new [WindowsLocalStorage].
|
||||||
|
///
|
||||||
|
/// This function should only be called by the app-facing package.
|
||||||
|
/// Look at using [LocalStorage] in `flutter_inappwebview` instead.
|
||||||
|
@override
|
||||||
|
WindowsLocalStorage createPlatformLocalStorage(
|
||||||
|
PlatformLocalStorageCreationParams params,
|
||||||
|
) {
|
||||||
|
return WindowsLocalStorage(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new [WindowsSessionStorage].
|
||||||
|
///
|
||||||
|
/// This function should only be called by the app-facing package.
|
||||||
|
/// Look at using [SessionStorage] in `flutter_inappwebview` instead.
|
||||||
|
@override
|
||||||
|
WindowsSessionStorage createPlatformSessionStorage(
|
||||||
|
PlatformSessionStorageCreationParams params,
|
||||||
|
) {
|
||||||
|
return WindowsSessionStorage(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,37 +2,37 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSPrintJobController].
|
/// Object specifying creation parameters for creating a [WindowsPrintJobController].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformPrintJobControllerCreationParams] for
|
/// value to avoid breaking changes. See [PlatformPrintJobControllerCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSPrintJobControllerCreationParams
|
class WindowsPrintJobControllerCreationParams
|
||||||
extends PlatformPrintJobControllerCreationParams {
|
extends PlatformPrintJobControllerCreationParams {
|
||||||
/// Creates a new [MacOSPrintJobControllerCreationParams] instance.
|
/// Creates a new [WindowsPrintJobControllerCreationParams] instance.
|
||||||
const MacOSPrintJobControllerCreationParams(
|
const WindowsPrintJobControllerCreationParams(
|
||||||
{required super.id, super.onComplete});
|
{required super.id, super.onComplete});
|
||||||
|
|
||||||
/// Creates a [MacOSPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams].
|
/// Creates a [WindowsPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams].
|
||||||
factory MacOSPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams(
|
factory WindowsPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformPrintJobControllerCreationParams params) {
|
PlatformPrintJobControllerCreationParams params) {
|
||||||
return MacOSPrintJobControllerCreationParams(
|
return WindowsPrintJobControllerCreationParams(
|
||||||
id: params.id, onComplete: params.onComplete);
|
id: params.id, onComplete: params.onComplete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController}
|
///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController}
|
||||||
class MacOSPrintJobController extends PlatformPrintJobController
|
class WindowsPrintJobController extends PlatformPrintJobController
|
||||||
with ChannelController {
|
with ChannelController {
|
||||||
/// Constructs a [MacOSPrintJobController].
|
/// Constructs a [WindowsPrintJobController].
|
||||||
MacOSPrintJobController(PlatformPrintJobControllerCreationParams params)
|
WindowsPrintJobController(PlatformPrintJobControllerCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSPrintJobControllerCreationParams
|
params is WindowsPrintJobControllerCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSPrintJobControllerCreationParams
|
: WindowsPrintJobControllerCreationParams
|
||||||
.fromPlatformPrintJobControllerCreationParams(params),
|
.fromPlatformPrintJobControllerCreationParams(params),
|
||||||
) {
|
) {
|
||||||
onComplete = params.onComplete;
|
onComplete = params.onComplete;
|
||||||
|
|
|
@ -9,18 +9,18 @@ import 'web_message_port.dart';
|
||||||
/// value to avoid breaking changes. See [PlatformWebMessageChannelCreationParams] for
|
/// value to avoid breaking changes. See [PlatformWebMessageChannelCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSWebMessageChannelCreationParams
|
class WindowsWebMessageChannelCreationParams
|
||||||
extends PlatformWebMessageChannelCreationParams {
|
extends PlatformWebMessageChannelCreationParams {
|
||||||
/// Creates a new [MacOSWebMessageChannelCreationParams] instance.
|
/// Creates a new [WindowsWebMessageChannelCreationParams] instance.
|
||||||
const MacOSWebMessageChannelCreationParams(
|
const WindowsWebMessageChannelCreationParams(
|
||||||
{required super.id, required super.port1, required super.port2});
|
{required super.id, required super.port1, required super.port2});
|
||||||
|
|
||||||
/// Creates a [MacOSWebMessageChannelCreationParams] instance based on [PlatformWebMessageChannelCreationParams].
|
/// Creates a [WindowsWebMessageChannelCreationParams] instance based on [PlatformWebMessageChannelCreationParams].
|
||||||
factory MacOSWebMessageChannelCreationParams.fromPlatformWebMessageChannelCreationParams(
|
factory WindowsWebMessageChannelCreationParams.fromPlatformWebMessageChannelCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformWebMessageChannelCreationParams params) {
|
PlatformWebMessageChannelCreationParams params) {
|
||||||
return MacOSWebMessageChannelCreationParams(
|
return WindowsWebMessageChannelCreationParams(
|
||||||
id: params.id, port1: params.port1, port2: params.port2);
|
id: params.id, port1: params.port1, port2: params.port2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ class WindowsWebMessageChannel extends PlatformWebMessageChannel
|
||||||
/// Constructs a [WindowsWebMessageChannel].
|
/// Constructs a [WindowsWebMessageChannel].
|
||||||
WindowsWebMessageChannel(PlatformWebMessageChannelCreationParams params)
|
WindowsWebMessageChannel(PlatformWebMessageChannelCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSWebMessageChannelCreationParams
|
params is WindowsWebMessageChannelCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSWebMessageChannelCreationParams
|
: WindowsWebMessageChannelCreationParams
|
||||||
.fromPlatformWebMessageChannelCreationParams(params),
|
.fromPlatformWebMessageChannelCreationParams(params),
|
||||||
) {
|
) {
|
||||||
channel = MethodChannel(
|
channel = MethodChannel(
|
||||||
|
@ -48,33 +48,33 @@ class WindowsWebMessageChannel extends PlatformWebMessageChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
static final WindowsWebMessageChannel _staticValue = WindowsWebMessageChannel(
|
static final WindowsWebMessageChannel _staticValue = WindowsWebMessageChannel(
|
||||||
MacOSWebMessageChannelCreationParams(
|
WindowsWebMessageChannelCreationParams(
|
||||||
id: '',
|
id: '',
|
||||||
port1:
|
port1:
|
||||||
MacOSWebMessagePort(MacOSWebMessagePortCreationParams(index: 0)),
|
WindowsWebMessagePort(WindowsWebMessagePortCreationParams(index: 0)),
|
||||||
port2: MacOSWebMessagePort(
|
port2: WindowsWebMessagePort(
|
||||||
MacOSWebMessagePortCreationParams(index: 1))));
|
WindowsWebMessagePortCreationParams(index: 1))));
|
||||||
|
|
||||||
/// Provide static access.
|
/// Provide static access.
|
||||||
factory WindowsWebMessageChannel.static() {
|
factory WindowsWebMessageChannel.static() {
|
||||||
return _staticValue;
|
return _staticValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacOSWebMessagePort get _macosPort1 => port1 as MacOSWebMessagePort;
|
WindowsWebMessagePort get _macosPort1 => port1 as WindowsWebMessagePort;
|
||||||
|
|
||||||
MacOSWebMessagePort get _macosPort2 => port2 as MacOSWebMessagePort;
|
WindowsWebMessagePort get _macosPort2 => port2 as WindowsWebMessagePort;
|
||||||
|
|
||||||
static WindowsWebMessageChannel? _fromMap(Map<String, dynamic>? map) {
|
static WindowsWebMessageChannel? _fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var webMessageChannel = WindowsWebMessageChannel(
|
var webMessageChannel = WindowsWebMessageChannel(
|
||||||
MacOSWebMessageChannelCreationParams(
|
WindowsWebMessageChannelCreationParams(
|
||||||
id: map["id"],
|
id: map["id"],
|
||||||
port1: MacOSWebMessagePort(
|
port1: WindowsWebMessagePort(
|
||||||
MacOSWebMessagePortCreationParams(index: 0)),
|
WindowsWebMessagePortCreationParams(index: 0)),
|
||||||
port2: MacOSWebMessagePort(
|
port2: WindowsWebMessagePort(
|
||||||
MacOSWebMessagePortCreationParams(index: 1))));
|
WindowsWebMessagePortCreationParams(index: 1))));
|
||||||
webMessageChannel._macosPort1.webMessageChannel = webMessageChannel;
|
webMessageChannel._macosPort1.webMessageChannel = webMessageChannel;
|
||||||
webMessageChannel._macosPort2.webMessageChannel = webMessageChannel;
|
webMessageChannel._macosPort2.webMessageChannel = webMessageChannel;
|
||||||
return webMessageChannel;
|
return webMessageChannel;
|
||||||
|
|
|
@ -2,26 +2,26 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSWebMessageListener].
|
/// Object specifying creation parameters for creating a [WindowsWebMessageListener].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformWebMessageListenerCreationParams] for
|
/// value to avoid breaking changes. See [PlatformWebMessageListenerCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSWebMessageListenerCreationParams
|
class WindowsWebMessageListenerCreationParams
|
||||||
extends PlatformWebMessageListenerCreationParams {
|
extends PlatformWebMessageListenerCreationParams {
|
||||||
/// Creates a new [MacOSWebMessageListenerCreationParams] instance.
|
/// Creates a new [WindowsWebMessageListenerCreationParams] instance.
|
||||||
const MacOSWebMessageListenerCreationParams(
|
const WindowsWebMessageListenerCreationParams(
|
||||||
{required this.allowedOriginRules,
|
{required this.allowedOriginRules,
|
||||||
required super.jsObjectName,
|
required super.jsObjectName,
|
||||||
super.onPostMessage});
|
super.onPostMessage});
|
||||||
|
|
||||||
/// Creates a [MacOSWebMessageListenerCreationParams] instance based on [PlatformWebMessageListenerCreationParams].
|
/// Creates a [WindowsWebMessageListenerCreationParams] instance based on [PlatformWebMessageListenerCreationParams].
|
||||||
factory MacOSWebMessageListenerCreationParams.fromPlatformWebMessageListenerCreationParams(
|
factory WindowsWebMessageListenerCreationParams.fromPlatformWebMessageListenerCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformWebMessageListenerCreationParams params) {
|
PlatformWebMessageListenerCreationParams params) {
|
||||||
return MacOSWebMessageListenerCreationParams(
|
return WindowsWebMessageListenerCreationParams(
|
||||||
allowedOriginRules: params.allowedOriginRules ?? Set.from(["*"]),
|
allowedOriginRules: params.allowedOriginRules ?? Set.from(["*"]),
|
||||||
jsObjectName: params.jsObjectName,
|
jsObjectName: params.jsObjectName,
|
||||||
onPostMessage: params.onPostMessage);
|
onPostMessage: params.onPostMessage);
|
||||||
|
@ -37,14 +37,14 @@ class MacOSWebMessageListenerCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener}
|
||||||
class MacOSWebMessageListener extends PlatformWebMessageListener
|
class WindowsWebMessageListener extends PlatformWebMessageListener
|
||||||
with ChannelController {
|
with ChannelController {
|
||||||
/// Constructs a [MacOSWebMessageListener].
|
/// Constructs a [WindowsWebMessageListener].
|
||||||
MacOSWebMessageListener(PlatformWebMessageListenerCreationParams params)
|
WindowsWebMessageListener(PlatformWebMessageListenerCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSWebMessageListenerCreationParams
|
params is WindowsWebMessageListenerCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSWebMessageListenerCreationParams
|
: WindowsWebMessageListenerCreationParams
|
||||||
.fromPlatformWebMessageListenerCreationParams(params),
|
.fromPlatformWebMessageListenerCreationParams(params),
|
||||||
) {
|
) {
|
||||||
assert(!this._macosParams.allowedOriginRules.contains(""),
|
assert(!this._macosParams.allowedOriginRules.contains(""),
|
||||||
|
@ -60,8 +60,8 @@ class MacOSWebMessageListener extends PlatformWebMessageListener
|
||||||
|
|
||||||
MacOSJavaScriptReplyProxy? _replyProxy;
|
MacOSJavaScriptReplyProxy? _replyProxy;
|
||||||
|
|
||||||
MacOSWebMessageListenerCreationParams get _macosParams =>
|
WindowsWebMessageListenerCreationParams get _macosParams =>
|
||||||
params as MacOSWebMessageListenerCreationParams;
|
params as WindowsWebMessageListenerCreationParams;
|
||||||
|
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
|
@ -138,7 +138,7 @@ class MacOSJavaScriptReplyProxyCreationParams
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.JavaScriptReplyProxy}
|
///{@macro flutter_inappwebview_platform_interface.JavaScriptReplyProxy}
|
||||||
class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy {
|
class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy {
|
||||||
/// Constructs a [MacOSWebMessageListener].
|
/// Constructs a [WindowsWebMessageListener].
|
||||||
MacOSJavaScriptReplyProxy(PlatformJavaScriptReplyProxyCreationParams params)
|
MacOSJavaScriptReplyProxy(PlatformJavaScriptReplyProxyCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSJavaScriptReplyProxyCreationParams
|
params is MacOSJavaScriptReplyProxyCreationParams
|
||||||
|
@ -147,8 +147,8 @@ class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy {
|
||||||
.fromPlatformJavaScriptReplyProxyCreationParams(params),
|
.fromPlatformJavaScriptReplyProxyCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
MacOSWebMessageListener get _macosWebMessageListener =>
|
WindowsWebMessageListener get _macosWebMessageListener =>
|
||||||
params.webMessageListener as MacOSWebMessageListener;
|
params.webMessageListener as WindowsWebMessageListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> postMessage(WebMessage message) async {
|
Future<void> postMessage(WebMessage message) async {
|
||||||
|
|
|
@ -3,23 +3,23 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla
|
||||||
|
|
||||||
import 'web_message_channel.dart';
|
import 'web_message_channel.dart';
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSWebMessagePort].
|
/// Object specifying creation parameters for creating a [WindowsWebMessagePort].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformWebMessagePortCreationParams] for
|
/// value to avoid breaking changes. See [PlatformWebMessagePortCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSWebMessagePortCreationParams
|
class WindowsWebMessagePortCreationParams
|
||||||
extends PlatformWebMessagePortCreationParams {
|
extends PlatformWebMessagePortCreationParams {
|
||||||
/// Creates a new [MacOSWebMessagePortCreationParams] instance.
|
/// Creates a new [WindowsWebMessagePortCreationParams] instance.
|
||||||
const MacOSWebMessagePortCreationParams({required super.index});
|
const WindowsWebMessagePortCreationParams({required super.index});
|
||||||
|
|
||||||
/// Creates a [MacOSWebMessagePortCreationParams] instance based on [PlatformWebMessagePortCreationParams].
|
/// Creates a [WindowsWebMessagePortCreationParams] instance based on [PlatformWebMessagePortCreationParams].
|
||||||
factory MacOSWebMessagePortCreationParams.fromPlatformWebMessagePortCreationParams(
|
factory WindowsWebMessagePortCreationParams.fromPlatformWebMessagePortCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformWebMessagePortCreationParams params) {
|
PlatformWebMessagePortCreationParams params) {
|
||||||
return MacOSWebMessagePortCreationParams(index: params.index);
|
return WindowsWebMessagePortCreationParams(index: params.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -29,16 +29,16 @@ class MacOSWebMessagePortCreationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessagePort}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebMessagePort}
|
||||||
class MacOSWebMessagePort extends PlatformWebMessagePort {
|
class WindowsWebMessagePort extends PlatformWebMessagePort {
|
||||||
WebMessageCallback? _onMessage;
|
WebMessageCallback? _onMessage;
|
||||||
late WindowsWebMessageChannel _webMessageChannel;
|
late WindowsWebMessageChannel _webMessageChannel;
|
||||||
|
|
||||||
/// Constructs a [MacOSWebMessagePort].
|
/// Constructs a [WindowsWebMessagePort].
|
||||||
MacOSWebMessagePort(PlatformWebMessagePortCreationParams params)
|
WindowsWebMessagePort(PlatformWebMessagePortCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSWebMessagePortCreationParams
|
params is WindowsWebMessagePortCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSWebMessagePortCreationParams
|
: WindowsWebMessagePortCreationParams
|
||||||
.fromPlatformWebMessagePortCreationParams(params),
|
.fromPlatformWebMessagePortCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class MacOSWebMessagePort extends PlatformWebMessagePort {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension InternalWebMessagePort on MacOSWebMessagePort {
|
extension InternalWebMessagePort on WindowsWebMessagePort {
|
||||||
WebMessageCallback? get onMessage => _onMessage;
|
WebMessageCallback? get onMessage => _onMessage;
|
||||||
void set onMessage(WebMessageCallback? value) => _onMessage = value;
|
void set onMessage(WebMessageCallback? value) => _onMessage = value;
|
||||||
|
|
||||||
|
|
|
@ -4,35 +4,35 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla
|
||||||
|
|
||||||
import '../in_app_webview/in_app_webview_controller.dart';
|
import '../in_app_webview/in_app_webview_controller.dart';
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSWebStorage].
|
/// Object specifying creation parameters for creating a [WindowsWebStorage].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformWebStorageCreationParams] for
|
/// value to avoid breaking changes. See [PlatformWebStorageCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
class MacOSWebStorageCreationParams extends PlatformWebStorageCreationParams {
|
class WindowsWebStorageCreationParams extends PlatformWebStorageCreationParams {
|
||||||
/// Creates a new [MacOSWebStorageCreationParams] instance.
|
/// Creates a new [WindowsWebStorageCreationParams] instance.
|
||||||
MacOSWebStorageCreationParams(
|
WindowsWebStorageCreationParams(
|
||||||
{required super.localStorage, required super.sessionStorage});
|
{required super.localStorage, required super.sessionStorage});
|
||||||
|
|
||||||
/// Creates a [MacOSWebStorageCreationParams] instance based on [PlatformWebStorageCreationParams].
|
/// Creates a [WindowsWebStorageCreationParams] instance based on [PlatformWebStorageCreationParams].
|
||||||
factory MacOSWebStorageCreationParams.fromPlatformWebStorageCreationParams(
|
factory WindowsWebStorageCreationParams.fromPlatformWebStorageCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformWebStorageCreationParams params) {
|
PlatformWebStorageCreationParams params) {
|
||||||
return MacOSWebStorageCreationParams(
|
return WindowsWebStorageCreationParams(
|
||||||
localStorage: params.localStorage,
|
localStorage: params.localStorage,
|
||||||
sessionStorage: params.sessionStorage);
|
sessionStorage: params.sessionStorage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage}
|
||||||
class MacOSWebStorage extends PlatformWebStorage {
|
class WindowsWebStorage extends PlatformWebStorage {
|
||||||
/// Constructs a [MacOSWebStorage].
|
/// Constructs a [WindowsWebStorage].
|
||||||
MacOSWebStorage(PlatformWebStorageCreationParams params)
|
WindowsWebStorage(PlatformWebStorageCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSWebStorageCreationParams
|
params is WindowsWebStorageCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSWebStorageCreationParams
|
: WindowsWebStorageCreationParams
|
||||||
.fromPlatformWebStorageCreationParams(params),
|
.fromPlatformWebStorageCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -49,28 +49,28 @@ class MacOSWebStorage extends PlatformWebStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSStorage].
|
/// Object specifying creation parameters for creating a [WindowsStorage].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformStorageCreationParams] for
|
/// value to avoid breaking changes. See [PlatformStorageCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
class MacOSStorageCreationParams extends PlatformStorageCreationParams {
|
class WindowsStorageCreationParams extends PlatformStorageCreationParams {
|
||||||
/// Creates a new [MacOSStorageCreationParams] instance.
|
/// Creates a new [WindowsStorageCreationParams] instance.
|
||||||
MacOSStorageCreationParams(
|
WindowsStorageCreationParams(
|
||||||
{required super.controller, required super.webStorageType});
|
{required super.controller, required super.webStorageType});
|
||||||
|
|
||||||
/// Creates a [MacOSStorageCreationParams] instance based on [PlatformStorageCreationParams].
|
/// Creates a [WindowsStorageCreationParams] instance based on [PlatformStorageCreationParams].
|
||||||
factory MacOSStorageCreationParams.fromPlatformStorageCreationParams(
|
factory WindowsStorageCreationParams.fromPlatformStorageCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformStorageCreationParams params) {
|
PlatformStorageCreationParams params) {
|
||||||
return MacOSStorageCreationParams(
|
return WindowsStorageCreationParams(
|
||||||
controller: params.controller, webStorageType: params.webStorageType);
|
controller: params.controller, webStorageType: params.webStorageType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformStorage}
|
||||||
abstract class MacOSStorage implements PlatformStorage {
|
abstract class WindowsStorage implements PlatformStorage {
|
||||||
@override
|
@override
|
||||||
WindowsInAppWebViewController? controller;
|
WindowsInAppWebViewController? controller;
|
||||||
|
|
||||||
|
@ -168,40 +168,40 @@ abstract class MacOSStorage implements PlatformStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSLocalStorage].
|
/// Object specifying creation parameters for creating a [WindowsLocalStorage].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformLocalStorageCreationParams] for
|
/// value to avoid breaking changes. See [PlatformLocalStorageCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
class MacOSLocalStorageCreationParams
|
class WindowsLocalStorageCreationParams
|
||||||
extends PlatformLocalStorageCreationParams {
|
extends PlatformLocalStorageCreationParams {
|
||||||
/// Creates a new [MacOSLocalStorageCreationParams] instance.
|
/// Creates a new [WindowsLocalStorageCreationParams] instance.
|
||||||
MacOSLocalStorageCreationParams(super.params);
|
WindowsLocalStorageCreationParams(super.params);
|
||||||
|
|
||||||
/// Creates a [MacOSLocalStorageCreationParams] instance based on [PlatformLocalStorageCreationParams].
|
/// Creates a [WindowsLocalStorageCreationParams] instance based on [PlatformLocalStorageCreationParams].
|
||||||
factory MacOSLocalStorageCreationParams.fromPlatformLocalStorageCreationParams(
|
factory WindowsLocalStorageCreationParams.fromPlatformLocalStorageCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformLocalStorageCreationParams params) {
|
PlatformLocalStorageCreationParams params) {
|
||||||
return MacOSLocalStorageCreationParams(params);
|
return WindowsLocalStorageCreationParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage}
|
||||||
class MacOSLocalStorage extends PlatformLocalStorage with MacOSStorage {
|
class WindowsLocalStorage extends PlatformLocalStorage with WindowsStorage {
|
||||||
/// Constructs a [MacOSLocalStorage].
|
/// Constructs a [WindowsLocalStorage].
|
||||||
MacOSLocalStorage(PlatformLocalStorageCreationParams params)
|
WindowsLocalStorage(PlatformLocalStorageCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSLocalStorageCreationParams
|
params is WindowsLocalStorageCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSLocalStorageCreationParams
|
: WindowsLocalStorageCreationParams
|
||||||
.fromPlatformLocalStorageCreationParams(params),
|
.fromPlatformLocalStorageCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Default storage
|
/// Default storage
|
||||||
factory MacOSLocalStorage.defaultStorage(
|
factory WindowsLocalStorage.defaultStorage(
|
||||||
{required PlatformInAppWebViewController? controller}) {
|
{required PlatformInAppWebViewController? controller}) {
|
||||||
return MacOSLocalStorage(MacOSLocalStorageCreationParams(
|
return WindowsLocalStorage(WindowsLocalStorageCreationParams(
|
||||||
PlatformLocalStorageCreationParams(PlatformStorageCreationParams(
|
PlatformLocalStorageCreationParams(PlatformStorageCreationParams(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
webStorageType: WebStorageType.LOCAL_STORAGE))));
|
webStorageType: WebStorageType.LOCAL_STORAGE))));
|
||||||
|
@ -212,40 +212,40 @@ class MacOSLocalStorage extends PlatformLocalStorage with MacOSStorage {
|
||||||
params.controller as WindowsInAppWebViewController?;
|
params.controller as WindowsInAppWebViewController?;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSSessionStorage].
|
/// Object specifying creation parameters for creating a [WindowsSessionStorage].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformSessionStorageCreationParams] for
|
/// value to avoid breaking changes. See [PlatformSessionStorageCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
class MacOSSessionStorageCreationParams
|
class WindowsSessionStorageCreationParams
|
||||||
extends PlatformSessionStorageCreationParams {
|
extends PlatformSessionStorageCreationParams {
|
||||||
/// Creates a new [MacOSSessionStorageCreationParams] instance.
|
/// Creates a new [WindowsSessionStorageCreationParams] instance.
|
||||||
MacOSSessionStorageCreationParams(super.params);
|
WindowsSessionStorageCreationParams(super.params);
|
||||||
|
|
||||||
/// Creates a [MacOSSessionStorageCreationParams] instance based on [PlatformSessionStorageCreationParams].
|
/// Creates a [WindowsSessionStorageCreationParams] instance based on [PlatformSessionStorageCreationParams].
|
||||||
factory MacOSSessionStorageCreationParams.fromPlatformSessionStorageCreationParams(
|
factory WindowsSessionStorageCreationParams.fromPlatformSessionStorageCreationParams(
|
||||||
// Recommended placeholder to prevent being broken by platform interface.
|
// Recommended placeholder to prevent being broken by platform interface.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformSessionStorageCreationParams params) {
|
PlatformSessionStorageCreationParams params) {
|
||||||
return MacOSSessionStorageCreationParams(params);
|
return WindowsSessionStorageCreationParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage}
|
||||||
class MacOSSessionStorage extends PlatformSessionStorage with MacOSStorage {
|
class WindowsSessionStorage extends PlatformSessionStorage with WindowsStorage {
|
||||||
/// Constructs a [MacOSSessionStorage].
|
/// Constructs a [WindowsSessionStorage].
|
||||||
MacOSSessionStorage(PlatformSessionStorageCreationParams params)
|
WindowsSessionStorage(PlatformSessionStorageCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSSessionStorageCreationParams
|
params is WindowsSessionStorageCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSSessionStorageCreationParams
|
: WindowsSessionStorageCreationParams
|
||||||
.fromPlatformSessionStorageCreationParams(params),
|
.fromPlatformSessionStorageCreationParams(params),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Default storage
|
/// Default storage
|
||||||
factory MacOSSessionStorage.defaultStorage(
|
factory WindowsSessionStorage.defaultStorage(
|
||||||
{required PlatformInAppWebViewController? controller}) {
|
{required PlatformInAppWebViewController? controller}) {
|
||||||
return MacOSSessionStorage(MacOSSessionStorageCreationParams(
|
return WindowsSessionStorage(WindowsSessionStorageCreationParams(
|
||||||
PlatformSessionStorageCreationParams(PlatformStorageCreationParams(
|
PlatformSessionStorageCreationParams(PlatformStorageCreationParams(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
webStorageType: WebStorageType.SESSION_STORAGE))));
|
webStorageType: WebStorageType.SESSION_STORAGE))));
|
||||||
|
|
|
@ -4,37 +4,37 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
||||||
|
|
||||||
/// Object specifying creation parameters for creating a [MacOSWebStorageManager].
|
/// Object specifying creation parameters for creating a [WindowsWebStorageManager].
|
||||||
///
|
///
|
||||||
/// When adding additional fields make sure they can be null or have a default
|
/// When adding additional fields make sure they can be null or have a default
|
||||||
/// value to avoid breaking changes. See [PlatformWebStorageManagerCreationParams] for
|
/// value to avoid breaking changes. See [PlatformWebStorageManagerCreationParams] for
|
||||||
/// more information.
|
/// more information.
|
||||||
@immutable
|
@immutable
|
||||||
class MacOSWebStorageManagerCreationParams
|
class WindowsWebStorageManagerCreationParams
|
||||||
extends PlatformWebStorageManagerCreationParams {
|
extends PlatformWebStorageManagerCreationParams {
|
||||||
/// Creates a new [MacOSWebStorageManagerCreationParams] instance.
|
/// Creates a new [WindowsWebStorageManagerCreationParams] instance.
|
||||||
const MacOSWebStorageManagerCreationParams(
|
const WindowsWebStorageManagerCreationParams(
|
||||||
// This parameter prevents breaking changes later.
|
// This parameter prevents breaking changes later.
|
||||||
// ignore: avoid_unused_constructor_parameters
|
// ignore: avoid_unused_constructor_parameters
|
||||||
PlatformWebStorageManagerCreationParams params,
|
PlatformWebStorageManagerCreationParams params,
|
||||||
) : super();
|
) : super();
|
||||||
|
|
||||||
/// Creates a [MacOSWebStorageManagerCreationParams] instance based on [PlatformWebStorageManagerCreationParams].
|
/// Creates a [WindowsWebStorageManagerCreationParams] instance based on [PlatformWebStorageManagerCreationParams].
|
||||||
factory MacOSWebStorageManagerCreationParams.fromPlatformWebStorageManagerCreationParams(
|
factory WindowsWebStorageManagerCreationParams.fromPlatformWebStorageManagerCreationParams(
|
||||||
PlatformWebStorageManagerCreationParams params) {
|
PlatformWebStorageManagerCreationParams params) {
|
||||||
return MacOSWebStorageManagerCreationParams(params);
|
return WindowsWebStorageManagerCreationParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager}
|
///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager}
|
||||||
class MacOSWebStorageManager extends PlatformWebStorageManager
|
class WindowsWebStorageManager extends PlatformWebStorageManager
|
||||||
with ChannelController {
|
with ChannelController {
|
||||||
/// Creates a new [MacOSWebStorageManager].
|
/// Creates a new [WindowsWebStorageManager].
|
||||||
MacOSWebStorageManager(PlatformWebStorageManagerCreationParams params)
|
WindowsWebStorageManager(PlatformWebStorageManagerCreationParams params)
|
||||||
: super.implementation(
|
: super.implementation(
|
||||||
params is MacOSWebStorageManagerCreationParams
|
params is WindowsWebStorageManagerCreationParams
|
||||||
? params
|
? params
|
||||||
: MacOSWebStorageManagerCreationParams
|
: WindowsWebStorageManagerCreationParams
|
||||||
.fromPlatformWebStorageManagerCreationParams(params),
|
.fromPlatformWebStorageManagerCreationParams(params),
|
||||||
) {
|
) {
|
||||||
channel = const MethodChannel(
|
channel = const MethodChannel(
|
||||||
|
@ -43,15 +43,15 @@ class MacOSWebStorageManager extends PlatformWebStorageManager
|
||||||
initMethodCallHandler();
|
initMethodCallHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
static MacOSWebStorageManager? _instance;
|
static WindowsWebStorageManager? _instance;
|
||||||
|
|
||||||
///Gets the WebStorage manager shared instance.
|
///Gets the WebStorage manager shared instance.
|
||||||
static MacOSWebStorageManager instance() {
|
static WindowsWebStorageManager instance() {
|
||||||
return (_instance != null) ? _instance! : _init();
|
return (_instance != null) ? _instance! : _init();
|
||||||
}
|
}
|
||||||
|
|
||||||
static MacOSWebStorageManager _init() {
|
static WindowsWebStorageManager _init() {
|
||||||
_instance = MacOSWebStorageManager(MacOSWebStorageManagerCreationParams(
|
_instance = WindowsWebStorageManager(WindowsWebStorageManagerCreationParams(
|
||||||
const PlatformWebStorageManagerCreationParams()));
|
const PlatformWebStorageManagerCreationParams()));
|
||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,6 @@ class MacOSWebStorageManager extends PlatformWebStorageManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension InternalWebStorageManager on MacOSWebStorageManager {
|
extension InternalWebStorageManager on WindowsWebStorageManager {
|
||||||
get handleMethod => _handleMethod;
|
get handleMethod => _handleMethod;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,25 @@ class WindowsWebViewEnvironment extends PlatformWebViewEnvironment
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String?> getAvailableVersion(
|
||||||
|
{String? browserExecutableFolder}) async {
|
||||||
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('browserExecutableFolder', () => browserExecutableFolder);
|
||||||
|
return await _staticChannel.invokeMethod<String>(
|
||||||
|
'getAvailableVersion', args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<int?> compareBrowserVersions(
|
||||||
|
{required String version1, required String version2}) async {
|
||||||
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('version1', () => version1);
|
||||||
|
args.putIfAbsent('version2', () => version2);
|
||||||
|
return await _staticChannel.invokeMethod<int>(
|
||||||
|
'compareBrowserVersions', args);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
Map<String, dynamic> args = <String, dynamic>{};
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
|
|
@ -74,6 +74,7 @@ list(APPEND PLUGIN_SOURCES
|
||||||
"types/size_2d.h"
|
"types/size_2d.h"
|
||||||
"types/rect.cpp"
|
"types/rect.cpp"
|
||||||
"types/rect.h"
|
"types/rect.h"
|
||||||
|
"types/callbacks_complete.h"
|
||||||
"types/screenshot_configuration.cpp"
|
"types/screenshot_configuration.cpp"
|
||||||
"types/screenshot_configuration.h"
|
"types/screenshot_configuration.h"
|
||||||
"custom_platform_view/custom_platform_view.cc"
|
"custom_platform_view/custom_platform_view.cc"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <wrl/event.h>
|
#include <wrl/event.h>
|
||||||
|
|
||||||
#include "cookie_manager.h"
|
#include "cookie_manager.h"
|
||||||
|
#include "types/callbacks_complete.h"
|
||||||
#include "utils/flutter.h"
|
#include "utils/flutter.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
|
|
||||||
|
@ -41,6 +42,46 @@ namespace flutter_inappwebview_plugin
|
||||||
result_->Success(created);
|
result_->Success(created);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (string_equals(methodName, "getCookie")) {
|
||||||
|
auto url = get_fl_map_value<std::string>(arguments, "url");
|
||||||
|
auto name = get_fl_map_value<std::string>(arguments, "name");
|
||||||
|
getCookie(webViewEnvironment, url, name, [result_](const flutter::EncodableValue& cookie)
|
||||||
|
{
|
||||||
|
result_->Success(cookie);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (string_equals(methodName, "getCookies")) {
|
||||||
|
auto url = get_fl_map_value<std::string>(arguments, "url");
|
||||||
|
getCookies(webViewEnvironment, url, [result_](const flutter::EncodableList& cookies)
|
||||||
|
{
|
||||||
|
result_->Success(cookies);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (string_equals(methodName, "deleteCookie")) {
|
||||||
|
auto url = get_fl_map_value<std::string>(arguments, "url");
|
||||||
|
auto name = get_fl_map_value<std::string>(arguments, "name");
|
||||||
|
auto path = get_fl_map_value<std::string>(arguments, "path");
|
||||||
|
auto domain = get_optional_fl_map_value<std::string>(arguments, "domain");
|
||||||
|
deleteCookie(webViewEnvironment, url, name, path, domain, [result_](const bool& deleted)
|
||||||
|
{
|
||||||
|
result_->Success(deleted);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (string_equals(methodName, "deleteCookies")) {
|
||||||
|
auto url = get_fl_map_value<std::string>(arguments, "url");
|
||||||
|
auto path = get_fl_map_value<std::string>(arguments, "path");
|
||||||
|
auto domain = get_optional_fl_map_value<std::string>(arguments, "domain");
|
||||||
|
deleteCookies(webViewEnvironment, url, path, domain, [result_](const bool& deleted)
|
||||||
|
{
|
||||||
|
result_->Success(deleted);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (string_equals(methodName, "deleteAllCookies")) {
|
||||||
|
deleteAllCookies(webViewEnvironment, [result_](const bool& deleted)
|
||||||
|
{
|
||||||
|
result_->Success(deleted);
|
||||||
|
});
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
result_->NotImplemented();
|
result_->NotImplemented();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +98,7 @@ namespace flutter_inappwebview_plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CookieManager::setCookie(WebViewEnvironment* webViewEnvironment, const flutter::EncodableMap& map, std::function<void(bool)> completionHandler) const
|
void CookieManager::setCookie(WebViewEnvironment* webViewEnvironment, const flutter::EncodableMap& map, std::function<void(const bool&)> completionHandler) const
|
||||||
{
|
{
|
||||||
if (!plugin || !plugin->webViewEnvironmentManager) {
|
if (!plugin || !plugin->webViewEnvironmentManager) {
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
|
@ -118,6 +159,188 @@ namespace flutter_inappwebview_plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CookieManager::getCookie(WebViewEnvironment* webViewEnvironment, const std::string& url, const std::string& name, std::function<void(const flutter::EncodableValue&)> completionHandler) const
|
||||||
|
{
|
||||||
|
if (!plugin || !plugin->webViewEnvironmentManager) {
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(make_fl_value());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json parameters = {
|
||||||
|
{"urls", std::vector<std::string>{url}}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto hr = webViewEnvironment->getWebView()->CallDevToolsProtocolMethod(L"Network.getCookies", utf8_to_wide(parameters.dump()).c_str(), Callback<ICoreWebView2CallDevToolsProtocolMethodCompletedHandler>(
|
||||||
|
[completionHandler, name](HRESULT errorCode, LPCWSTR returnObjectAsJson)
|
||||||
|
{
|
||||||
|
if (succeededOrLog(errorCode)) {
|
||||||
|
nlohmann::json json = nlohmann::json::parse(wide_to_utf8(returnObjectAsJson));
|
||||||
|
auto jsonCookies = json["cookies"].get<std::vector<nlohmann::json>>();
|
||||||
|
for (auto& jsonCookie : jsonCookies) {
|
||||||
|
auto cookieName = jsonCookie["name"].get<std::string>();
|
||||||
|
if (string_equals(name, cookieName)) {
|
||||||
|
completionHandler(flutter::EncodableMap{
|
||||||
|
{"name", cookieName},
|
||||||
|
{"value", jsonCookie["value"].get<std::string>()},
|
||||||
|
{"domain", jsonCookie["domain"].get<std::string>()},
|
||||||
|
{"path", jsonCookie["path"].get<std::string>()},
|
||||||
|
{"expiresDate", jsonCookie["expires"].get<int64_t>()},
|
||||||
|
{"isHttpOnly", jsonCookie["httpOnly"].get<bool>()},
|
||||||
|
{"isSecure", jsonCookie["secure"].get<bool>()},
|
||||||
|
{"isSessionOnly", jsonCookie["session"].get<bool>()},
|
||||||
|
{"sameSite", jsonCookie.contains("sameSite") ? jsonCookie["sameSite"].get<std::string>() : make_fl_value()}
|
||||||
|
});
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(make_fl_value());
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
).Get());
|
||||||
|
|
||||||
|
if (failedAndLog(hr) && completionHandler) {
|
||||||
|
completionHandler(make_fl_value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CookieManager::getCookies(WebViewEnvironment* webViewEnvironment, const std::string& url, std::function<void(const flutter::EncodableList&)> completionHandler) const
|
||||||
|
{
|
||||||
|
if (!plugin || !plugin->webViewEnvironmentManager) {
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler({});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json parameters = {
|
||||||
|
{"urls", std::vector<std::string>{url}}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto hr = webViewEnvironment->getWebView()->CallDevToolsProtocolMethod(L"Network.getCookies", utf8_to_wide(parameters.dump()).c_str(), Callback<ICoreWebView2CallDevToolsProtocolMethodCompletedHandler>(
|
||||||
|
[completionHandler](HRESULT errorCode, LPCWSTR returnObjectAsJson)
|
||||||
|
{
|
||||||
|
std::vector<flutter::EncodableValue> cookies = {};
|
||||||
|
if (succeededOrLog(errorCode)) {
|
||||||
|
nlohmann::json json = nlohmann::json::parse(wide_to_utf8(returnObjectAsJson));
|
||||||
|
auto jsonCookies = json["cookies"].get<std::vector<nlohmann::json>>();
|
||||||
|
for (auto& jsonCookie : jsonCookies) {
|
||||||
|
cookies.push_back(flutter::EncodableMap{
|
||||||
|
{"name", jsonCookie["name"].get<std::string>()},
|
||||||
|
{"value", jsonCookie["value"].get<std::string>()},
|
||||||
|
{"domain", jsonCookie["domain"].get<std::string>()},
|
||||||
|
{"path", jsonCookie["path"].get<std::string>()},
|
||||||
|
{"expiresDate", jsonCookie["expires"].get<int64_t>()},
|
||||||
|
{"isHttpOnly", jsonCookie["httpOnly"].get<bool>()},
|
||||||
|
{"isSecure", jsonCookie["secure"].get<bool>()},
|
||||||
|
{"isSessionOnly", jsonCookie["session"].get<bool>()},
|
||||||
|
{"sameSite", jsonCookie.contains("sameSite") ? jsonCookie["sameSite"].get<std::string>() : make_fl_value()}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(cookies);
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
).Get());
|
||||||
|
|
||||||
|
if (failedAndLog(hr) && completionHandler) {
|
||||||
|
completionHandler({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CookieManager::deleteCookie(WebViewEnvironment* webViewEnvironment, const std::string& url, const std::string& name, const std::string& path, const std::optional<std::string>& domain, std::function<void(const bool&)> completionHandler) const
|
||||||
|
{
|
||||||
|
if (!plugin || !plugin->webViewEnvironmentManager) {
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json parameters = {
|
||||||
|
{"url", url},
|
||||||
|
{"name", name},
|
||||||
|
{"path", path}
|
||||||
|
};
|
||||||
|
if (domain.has_value()) {
|
||||||
|
parameters["domain"] = domain.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto hr = webViewEnvironment->getWebView()->CallDevToolsProtocolMethod(L"Network.deleteCookies", utf8_to_wide(parameters.dump()).c_str(), Callback<ICoreWebView2CallDevToolsProtocolMethodCompletedHandler>(
|
||||||
|
[completionHandler](HRESULT errorCode, LPCWSTR returnObjectAsJson)
|
||||||
|
{
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(succeededOrLog(errorCode));
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
).Get());
|
||||||
|
|
||||||
|
if (failedAndLog(hr) && completionHandler) {
|
||||||
|
completionHandler(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CookieManager::deleteCookies(WebViewEnvironment* webViewEnvironment, const std::string& url, const std::string& path, const std::optional<std::string>& domain, std::function<void(const bool&)> completionHandler) const
|
||||||
|
{
|
||||||
|
if (!plugin || !plugin->webViewEnvironmentManager) {
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCookies(webViewEnvironment, url, [this, webViewEnvironment, url, path, domain, completionHandler](const flutter::EncodableList& cookies)
|
||||||
|
{
|
||||||
|
auto callbacksComplete = std::make_shared<CallbacksComplete<bool>>(
|
||||||
|
[completionHandler](const std::vector<bool>& values)
|
||||||
|
{
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto& cookie : cookies) {
|
||||||
|
auto cookieMap = std::get<flutter::EncodableMap>(cookie);
|
||||||
|
auto name = get_fl_map_value<std::string>(cookieMap, "name");
|
||||||
|
deleteCookie(webViewEnvironment, url, name, path, domain, [callbacksComplete](const bool& deleted)
|
||||||
|
{
|
||||||
|
callbacksComplete->addValue(deleted);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CookieManager::deleteAllCookies(WebViewEnvironment* webViewEnvironment, std::function<void(const bool&)> completionHandler) const
|
||||||
|
{
|
||||||
|
if (!plugin || !plugin->webViewEnvironmentManager) {
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto hr = webViewEnvironment->getWebView()->CallDevToolsProtocolMethod(L"Network.clearBrowserCookies", L"{}", Callback<ICoreWebView2CallDevToolsProtocolMethodCompletedHandler>(
|
||||||
|
[completionHandler](HRESULT errorCode, LPCWSTR returnObjectAsJson)
|
||||||
|
{
|
||||||
|
if (completionHandler) {
|
||||||
|
completionHandler(succeededOrLog(errorCode));
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
).Get());
|
||||||
|
|
||||||
|
if (failedAndLog(hr) && completionHandler) {
|
||||||
|
completionHandler(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CookieManager::~CookieManager()
|
CookieManager::~CookieManager()
|
||||||
{
|
{
|
||||||
debugLog("dealloc CookieManager");
|
debugLog("dealloc CookieManager");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <flutter/method_channel.h>
|
#include <flutter/method_channel.h>
|
||||||
#include <flutter/standard_message_codec.h>
|
#include <flutter/standard_message_codec.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include "flutter_inappwebview_windows_plugin.h"
|
#include "flutter_inappwebview_windows_plugin.h"
|
||||||
#include "types/channel_delegate.h"
|
#include "types/channel_delegate.h"
|
||||||
|
@ -25,7 +26,12 @@ namespace flutter_inappwebview_plugin
|
||||||
const flutter::MethodCall<flutter::EncodableValue>& method_call,
|
const flutter::MethodCall<flutter::EncodableValue>& method_call,
|
||||||
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
void setCookie(WebViewEnvironment* webViewEnvironment, const flutter::EncodableMap& map, std::function<void(bool)> completionHandler) const;
|
void setCookie(WebViewEnvironment* webViewEnvironment, const flutter::EncodableMap& map, std::function<void(const bool&)> completionHandler) const;
|
||||||
|
void getCookie(WebViewEnvironment* webViewEnvironment, const std::string& url, const std::string& name, std::function<void(const flutter::EncodableValue&)> completionHandler) const;
|
||||||
|
void getCookies(WebViewEnvironment* webViewEnvironment, const std::string& url, std::function<void(const flutter::EncodableList&)> completionHandler) const;
|
||||||
|
void deleteCookie(WebViewEnvironment* webViewEnvironment, const std::string& url, const std::string& name, const std::string& path, const std::optional<std::string>& domain, std::function<void(const bool&)> completionHandler) const;
|
||||||
|
void deleteCookies(WebViewEnvironment* webViewEnvironment, const std::string& url, const std::string& path, const std::optional<std::string>& domain, std::function<void(const bool&)> completionHandler) const;
|
||||||
|
void deleteAllCookies(WebViewEnvironment* webViewEnvironment, std::function<void(const bool&)> completionHandler) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_CALLBACKS_COMPLETE_H_
|
||||||
|
#define FLUTTER_INAPPWEBVIEW_PLUGIN_CALLBACKS_COMPLETE_H_
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace flutter_inappwebview_plugin
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
class CallbacksComplete
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::function<void(const std::vector<T>&)> onComplete;
|
||||||
|
|
||||||
|
CallbacksComplete(const std::function<void(const std::vector<T>&)> onComplete)
|
||||||
|
: onComplete(onComplete)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~CallbacksComplete()
|
||||||
|
{
|
||||||
|
if (onComplete) {
|
||||||
|
onComplete(values_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void addValue(const T& value)
|
||||||
|
{
|
||||||
|
const std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
values_.push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<T> values_;
|
||||||
|
std::mutex mutex_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //FLUTTER_INAPPWEBVIEW_PLUGIN_CALLBACKS_COMPLETE_H_
|
|
@ -39,6 +39,15 @@ namespace flutter_inappwebview_plugin
|
||||||
auto settings = settingsMap.has_value() ? std::make_unique<WebViewEnvironmentSettings>(settingsMap.value()) : nullptr;
|
auto settings = settingsMap.has_value() ? std::make_unique<WebViewEnvironmentSettings>(settingsMap.value()) : nullptr;
|
||||||
createWebViewEnvironment(id, std::move(settings), std::move(result));
|
createWebViewEnvironment(id, std::move(settings), std::move(result));
|
||||||
}
|
}
|
||||||
|
else if (string_equals(methodName, "getAvailableVersion")) {
|
||||||
|
auto browserExecutableFolder = get_optional_fl_map_value<std::string>(*arguments, "browserExecutableFolder");
|
||||||
|
result->Success(make_fl_value(getAvailableVersion(browserExecutableFolder)));
|
||||||
|
}
|
||||||
|
else if (string_equals(methodName, "compareBrowserVersions")) {
|
||||||
|
auto version1 = get_fl_map_value<std::string>(*arguments, "version1");
|
||||||
|
auto version2 = get_fl_map_value<std::string>(*arguments, "version2");
|
||||||
|
result->Success(make_fl_value(compareBrowserVersions(version1, version2)));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
result->NotImplemented();
|
result->NotImplemented();
|
||||||
}
|
}
|
||||||
|
@ -89,6 +98,24 @@ namespace flutter_inappwebview_plugin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> WebViewEnvironmentManager::getAvailableVersion(std::optional<std::string> browserExecutableFolder)
|
||||||
|
{
|
||||||
|
wil::unique_cotaskmem_string versionInfo;
|
||||||
|
if (succeededOrLog(GetAvailableCoreWebView2BrowserVersionString(browserExecutableFolder.has_value() ? utf8_to_wide(browserExecutableFolder.value()).c_str() : nullptr, &versionInfo))) {
|
||||||
|
return wide_to_utf8(versionInfo.get());
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<int> WebViewEnvironmentManager::compareBrowserVersions(std::string version1, std::string version2)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
if (succeededOrLog(CompareBrowserVersions(utf8_to_wide(version1).c_str(), utf8_to_wide(version2).c_str(), &result))) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
WebViewEnvironmentManager::~WebViewEnvironmentManager()
|
WebViewEnvironmentManager::~WebViewEnvironmentManager()
|
||||||
{
|
{
|
||||||
debugLog("dealloc WebViewEnvironmentManager");
|
debugLog("dealloc WebViewEnvironmentManager");
|
||||||
|
|
|
@ -34,6 +34,9 @@ namespace flutter_inappwebview_plugin
|
||||||
{
|
{
|
||||||
return hwnd_;
|
return hwnd_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::optional<std::string> getAvailableVersion(std::optional<std::string> browserExecutableFolder);
|
||||||
|
static std::optional<int> compareBrowserVersions(std::string version1, std::string version2);
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<WebViewEnvironment> defaultEnvironment_;
|
std::unique_ptr<WebViewEnvironment> defaultEnvironment_;
|
||||||
WNDCLASS windowClass_ = {};
|
WNDCLASS windowClass_ = {};
|
||||||
|
|
Loading…
Reference in New Issue