Skip to content

Add ProxyController support for Windows (WebView2)#2806

Open
StarProxima wants to merge 9 commits into
pichillilorenzo:masterfrom
StarProxima:feat/windows-proxy-controller
Open

Add ProxyController support for Windows (WebView2)#2806
StarProxima wants to merge 9 commits into
pichillilorenzo:masterfrom
StarProxima:feat/windows-proxy-controller

Conversation

@StarProxima

Copy link
Copy Markdown

Closes #2805

Summary

Adds ProxyController implementation for Windows using WebView2's --proxy-server browser argument.

Changes:

  • C++ ProxyManager (proxy_manager.h/.cpp) — handles setProxyOverride/clearProxyOverride method channel calls, converts ProxySettings to --proxy-server and --proxy-bypass-list args
  • Proxy injection in WebViewEnvironment::create() — proxy args are appended to additionalBrowserArguments when creating the WebView2 environment
  • Default env routing (in_app_webview.cpp) — fallback from raw CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, nullptr) to WebViewEnvironmentManager::createOrGetDefaultWebViewEnvironment() so proxy args are picked up
  • Dart WindowsProxyController — extends PlatformProxyController with MethodChannel bridge, registered in WindowsInAppWebViewPlatform
  • Platform InterfaceWindowsPlatform added to @SupportedPlatforms for ProxyController, ProxySettings, and related methods/properties
  • Local path deps — all sub-packages use local path: dependencies for flutter_inappwebview_platform_interface

Limitations

  • Proxy is set at WebView2 environment creation time via browser args — cannot be changed at runtime (WebView2 limitation)
  • setProxyOverride() must be called before WebView creation

Test plan

  • Unit tests for WindowsProxyController (9 tests: method channel calls, ProxySettings roundtrip, isClassSupported)
  • Manual test on Windows: set proxy, open WebView, verify traffic goes through proxy
  • Verify Android/iOS/macOS/Linux ProxyController still works (no regressions)

StarProxima and others added 8 commits March 18, 2026 02:38
Для работы через git submodule - все sub-packages ссылаются
на локальный flutter_inappwebview_platform_interface вместо pub.dev.
…erface

WindowsPlatform добавлен в @SupportedPlatforms для ProxyController,
ProxySettings, setProxyOverride, clearProxyOverride, bypassRules, proxyRules.
Обновлён .g.dart с TargetPlatform.windows в isClassSupported/isMethodSupported.
ProxyManager хранит proxy settings из Dart method channel и инжектит
--proxy-server/--proxy-bypass-list в WebView2 additionalBrowserArguments
при создании environment. Поддерживает per-scheme прокси и bypass rules.
WindowsProxyController с MethodChannel bridge, зарегистрирован
в WindowsInAppWebViewPlatform. Убрана заглушка _PlatformProxyController.
…Manager

InAppWebView без явного webViewEnvironment создавал env напрямую через
CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, nullptr),
минуя WebViewEnvironment::create() где живёт proxy injection.
Теперь fallback идёт через createOrGetDefaultWebViewEnvironment().
9 тестов: method channel вызовы (setProxyOverride, clearProxyOverride),
ProxySettings toMap/fromMap roundtrip, isClassSupported для всех платформ.
- proxy_manager.cpp: добавлены #include <algorithm> и <cctype>
  для std::transform/std::tolower
- in_app_webview.cpp: добавлен #include webview_environment_manager.h
  для доступа к createOrGetDefaultWebViewEnvironment()
Pass the plugin into the shared WebViewEnvironment factory so Windows webviews can reuse the proxy-aware default environment without breaking compilation.

Made-with: Cursor
@probot-autolabeler probot-autolabeler Bot added android iOS linux Linux platform macOS macOS platform platform_interface Platform Interface plugin flutter_inappwebview plugin web windows Windows platform labels Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android iOS linux Linux platform macOS macOS platform platform_interface Platform Interface plugin flutter_inappwebview plugin web windows Windows platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ProxyController support for Windows (WebView2)

2 participants