mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 21:03:41 +00:00
fix: finish migration to main WebView profile library
This commit is contained in:
1 parent
adeb7a2895
commit
d1b2ae42af
534 files changed
-70217
No files matched your search
@@ -1,66 +0,0 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
|
||||
// Private host/plugin bridge. These settings never originate from extension JS.
|
||||
class WebViewProfileSettings extends InAppWebViewSettings {
|
||||
WebViewProfileSettings({required this.profileId, required bool debug, super.userAgent})
|
||||
: super(javaScriptEnabled: true, transparentBackground: true, isInspectable: debug);
|
||||
|
||||
final String profileId;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toMap() => {...super.toMap(), 'gopeedProfileId': profileId};
|
||||
}
|
||||
|
||||
class WebViewProfile {
|
||||
WebViewProfile(this.id);
|
||||
|
||||
final String id;
|
||||
static const _channel = MethodChannel('com.pichillilorenzo/flutter_inappwebview_cookiemanager');
|
||||
|
||||
Future<void> remove() async {
|
||||
await _call('gopeed.removeProfile', {});
|
||||
}
|
||||
|
||||
Future<void> prepare(String proxyUrl) async {
|
||||
await _call('gopeed.prepareProfile', {'proxyUrl': proxyUrl});
|
||||
}
|
||||
|
||||
Future<dynamic> _call(String method, Map<String, dynamic> arguments) =>
|
||||
_channel.invokeMethod(method, {...arguments, 'gopeedProfileId': id});
|
||||
|
||||
Future<List<Cookie>> getCookies({required WebUri url}) async {
|
||||
final values = await _call('getCookies', {'url': url.toString()}) as List? ?? [];
|
||||
return values.map((value) => Cookie.fromMap(Map<String, dynamic>.from(value as Map))!).toList();
|
||||
}
|
||||
|
||||
Future<void> setCookie({
|
||||
required WebUri url,
|
||||
required String name,
|
||||
required String value,
|
||||
String? domain,
|
||||
String path = '/',
|
||||
int? expiresDate,
|
||||
bool isSecure = false,
|
||||
bool isHttpOnly = false,
|
||||
}) async {
|
||||
await _call('setCookie', {
|
||||
'url': url.toString(),
|
||||
'name': name,
|
||||
'value': value,
|
||||
'domain': domain,
|
||||
'path': path,
|
||||
'expiresDate': expiresDate?.toString(),
|
||||
'isSecure': isSecure,
|
||||
'isHttpOnly': isHttpOnly,
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> deleteCookie({required WebUri url, required String name, String? domain, String path = '/'}) async {
|
||||
await _call('deleteCookie', {'url': url.toString(), 'name': name, 'domain': domain, 'path': path});
|
||||
}
|
||||
|
||||
Future<void> deleteAllCookies() async {
|
||||
await _call('deleteAllCookies', {});
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import '../../core/common/start_config.dart';
|
||||
import '../../util/log_util.dart';
|
||||
import '../../util/util.dart';
|
||||
import 'server.dart';
|
||||
import 'webview_profile.dart';
|
||||
|
||||
String buildWebViewExecuteScript({
|
||||
required String channelName,
|
||||
|
||||
Reference in new issue
Block a user