Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions flutter_inappwebview/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_android: ^1.2.0-beta.3
# path: ../flutter_inappwebview_android
flutter_inappwebview_ios: ^1.2.0-beta.3
# path: ../flutter_inappwebview_ios
flutter_inappwebview_macos: ^1.2.0-beta.3
# path: ../flutter_inappwebview_macos
flutter_inappwebview_web: ^1.2.0-beta.3
# path: ../flutter_inappwebview_web
flutter_inappwebview_windows: ^0.7.0-beta.3
# path: ../flutter_inappwebview_windows
flutter_inappwebview_linux: ^0.1.0-beta.1
# path: ../flutter_inappwebview_linux
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_android:
path: ../flutter_inappwebview_android
flutter_inappwebview_ios:
path: ../flutter_inappwebview_ios
flutter_inappwebview_macos:
path: ../flutter_inappwebview_macos
flutter_inappwebview_web:
path: ../flutter_inappwebview_web
flutter_inappwebview_windows:
path: ../flutter_inappwebview_windows
flutter_inappwebview_linux:
path: ../flutter_inappwebview_linux

dev_dependencies:
flutter_test:
Expand Down
4 changes: 2 additions & 2 deletions flutter_inappwebview_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface

dev_dependencies:
flutter_test:
Expand Down
4 changes: 2 additions & 2 deletions flutter_inappwebview_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface

dev_dependencies:
flutter_test:
Expand Down
4 changes: 2 additions & 2 deletions flutter_inappwebview_linux/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface

dev_dependencies:
flutter_test:
Expand Down
4 changes: 2 additions & 2 deletions flutter_inappwebview_macos/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ part 'platform_proxy_controller.g.dart';
IOSPlatform(),
MacOSPlatform(),
LinuxPlatform(),
WindowsPlatform(),
],
)
@immutable
Expand Down Expand Up @@ -76,6 +77,14 @@ class PlatformProxyControllerCreationParams {
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/struct.NetworkProxySettings.html',
),
WindowsPlatform(
apiName: 'WebView2 --proxy-server',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions',
note:
'Proxy is set via --proxy-server browser argument when creating WebView2 environment. '
'Must be set before WebView creation; runtime changes require recreating the environment.',
),
],
)
abstract class PlatformProxyController extends PlatformInterface {
Expand Down Expand Up @@ -158,6 +167,13 @@ abstract class PlatformProxyController extends PlatformInterface {
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.NetworkSession.set_proxy_settings.html',
),
WindowsPlatform(
apiName: 'WebView2 --proxy-server',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions',
note:
'Stores proxy settings for subsequent WebView2 environment creation via --proxy-server argument.',
),
],
)
Future<void> setProxyOverride({required ProxySettings settings}) {
Expand Down Expand Up @@ -197,6 +213,12 @@ abstract class PlatformProxyController extends PlatformInterface {
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.NetworkSession.set_proxy_settings.html',
),
WindowsPlatform(
apiName: 'WebView2 --proxy-server',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions',
note: 'Clears stored proxy settings.',
),
],
)
Future<void> clearProxyOverride() {
Expand Down Expand Up @@ -250,6 +272,7 @@ abstract class PlatformProxyController extends PlatformInterface {
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/struct.NetworkProxySettings.html',
),
WindowsPlatform(),
],
)
@ExchangeableObject(copyMethod: true)
Expand All @@ -269,6 +292,10 @@ class ProxySettings_ {
note:
'Mapped to ignore_hosts; bypass rules are passed as host patterns to WebKitNetworkProxySettings.',
),
WindowsPlatform(
note:
'Mapped to --proxy-bypass-list browser argument.',
),
],
)
List<String> bypassRules;
Expand All @@ -293,6 +320,7 @@ class ProxySettings_ {
IOSPlatform(),
MacOSPlatform(),
LinuxPlatform(),
WindowsPlatform(),
],
)
List<ProxyRule_> proxyRules;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flutter_inappwebview_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ dependencies:
flutter_web_plugins:
sdk: flutter
web: ^1.0.0
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface

dev_dependencies:
flutter_test:
Expand Down
27 changes: 15 additions & 12 deletions flutter_inappwebview_windows/lib/src/inappwebview_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'in_app_browser/in_app_browser.dart';
import 'in_app_webview/headless_in_app_webview.dart';
import 'in_app_webview/in_app_webview.dart';
import 'in_app_webview/in_app_webview_controller.dart';
import 'proxy_controller.dart';
import 'web_message/web_message_channel.dart';
import 'web_message/web_message_listener.dart';
import 'web_message/web_message_port.dart';
Expand Down Expand Up @@ -352,13 +353,24 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform {
return _PlatformProcessGlobalConfig.static();
}

/// Creates a new empty [PlatformProxyController] to access static methods.
/// Creates a new [WindowsProxyController].
///
/// This function should only be called by the app-facing package.
/// Look at using [ProxyController] in `flutter_inappwebview` instead.
@override
PlatformProxyController createPlatformProxyControllerStatic() {
return _PlatformProxyController.static();
WindowsProxyController createPlatformProxyController(
PlatformProxyControllerCreationParams params,
) {
return WindowsProxyController(params);
}

/// Creates a new empty [WindowsProxyController] to access static methods.
///
/// This function should only be called by the app-facing package.
/// Look at using [ProxyController] in `flutter_inappwebview` instead.
@override
WindowsProxyController createPlatformProxyControllerStatic() {
return WindowsProxyController.static();
}

/// Creates a new empty [PlatformServiceWorkerController] to access static methods.
Expand Down Expand Up @@ -511,15 +523,6 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig {
factory _PlatformProcessGlobalConfig.static() => _staticValue;
}

class _PlatformProxyController extends PlatformProxyController {
_PlatformProxyController(PlatformProxyControllerCreationParams params)
: super.implementation(params);
static final _PlatformProxyController _staticValue = _PlatformProxyController(
const PlatformProxyControllerCreationParams(),
);

factory _PlatformProxyController.static() => _staticValue;
}

class _PlatformServiceWorkerController extends PlatformServiceWorkerController {
_PlatformServiceWorkerController(
Expand Down
1 change: 1 addition & 0 deletions flutter_inappwebview_windows/lib/src/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export 'in_app_webview/main.dart';
export 'in_app_browser/main.dart';
export 'web_storage/main.dart';
export 'cookie_manager.dart' hide InternalCookieManager;
export 'proxy_controller.dart' hide InternalProxyController;
export 'http_auth_credentials_database.dart'
hide InternalHttpAuthCredentialDatabase;
export 'print_job/main.dart';
Expand Down
99 changes: 99 additions & 0 deletions flutter_inappwebview_windows/lib/src/proxy_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';

/// Object specifying creation parameters for creating a [WindowsProxyController].
///
/// When adding additional fields make sure they can be null or have a default
/// value to avoid breaking changes. See [PlatformProxyControllerCreationParams] for
/// more information.
@immutable
class WindowsProxyControllerCreationParams
extends PlatformProxyControllerCreationParams {
/// Creates a new [WindowsProxyControllerCreationParams] instance.
const WindowsProxyControllerCreationParams(
// This parameter prevents breaking changes later.
// ignore: avoid_unused_constructor_parameters
PlatformProxyControllerCreationParams params,
) : super();

/// Creates a [WindowsProxyControllerCreationParams] instance based on [PlatformProxyControllerCreationParams].
factory WindowsProxyControllerCreationParams.fromPlatformProxyControllerCreationParams(
PlatformProxyControllerCreationParams params,
) {
return WindowsProxyControllerCreationParams(params);
}
}

///{@macro flutter_inappwebview_platform_interface.PlatformProxyController}
class WindowsProxyController extends PlatformProxyController
with ChannelController {
/// Creates a new [WindowsProxyController].
WindowsProxyController(PlatformProxyControllerCreationParams params)
: super.implementation(
params is WindowsProxyControllerCreationParams
? params
: WindowsProxyControllerCreationParams.fromPlatformProxyControllerCreationParams(
params,
),
) {
channel = const MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_proxycontroller',
);
handler = handleMethod;
initMethodCallHandler();
}

static WindowsProxyController? _instance;

///Gets the [WindowsProxyController] shared instance.
static WindowsProxyController instance() {
return (_instance != null) ? _instance! : _init();
}

static WindowsProxyController _init() {
_instance = WindowsProxyController(
WindowsProxyControllerCreationParams(
const PlatformProxyControllerCreationParams(),
),
);
return _instance!;
}

static final WindowsProxyController _staticValue = WindowsProxyController(
WindowsProxyControllerCreationParams(
const PlatformProxyControllerCreationParams(),
),
);

/// Provide static access.
factory WindowsProxyController.static() {
return _staticValue;
}

Future<dynamic> _handleMethod(MethodCall call) async {}

@override
Future<void> setProxyOverride({required ProxySettings settings}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("settings", () => settings.toMap());
await channel?.invokeMethod('setProxyOverride', args);
}

@override
Future<void> clearProxyOverride() async {
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('clearProxyOverride', args);
}

@override
void dispose() {
// empty
}
}

extension InternalProxyController on WindowsProxyController {
get handleMethod => _handleMethod;
}
4 changes: 2 additions & 2 deletions flutter_inappwebview_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_inappwebview_platform_interface: ^1.4.0-beta.3
# path: ../flutter_inappwebview_platform_interface
flutter_inappwebview_platform_interface:
path: ../flutter_inappwebview_platform_interface

dev_dependencies:
flutter_test:
Expand Down
Loading