Repository navigation
Expose a generic callDevToolsProtocolMethod on WebviewController - #332
Open
diligent176 wants to merge 1 commit into
Open
diligent176 wants to merge 1 commit into
diligent176 wants to merge 1 commit into
Conversation
This plugin surfaces no cookie API, so the Chrome DevTools Protocol is currently the only route to operations such as Storage.getCookies / Storage.setCookies. clearCookies() and clearCache() already call CallDevToolsProtocolMethod internally; this exposes the general form and, unlike those two fire-and-forget helpers, returns the JSON result object.
diligent176
force-pushed
the
upstream/call-devtools-protocol-method
branch
from
August 20, 2026 13:02
8bb7117 to
79f92ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
webview_windowscurrently surfaces no way to read or write cookies, and no general escape hatch to the Chrome DevTools Protocol.executeScriptcannot fill the gap either:HttpOnlycookies are invisible todocument.cookie, which is exactly the class of cookie that matters when driving a signed-in session.The plugin already calls
ICoreWebView2::CallDevToolsProtocolMethodinternally -clearCookies()isNetwork.clearBrowserCookiesandclearCache()isNetwork.clearBrowserCache. This PR exposes the general form of that call. Unlike those two fire-and-forget helpers, it returns the JSON result object, which is what makes read operations such asStorage.getCookiespossible.Why this rather than a cookie API
There are already several requests and PRs for cookie access (#221, #256, #299).
ICoreWebView2CookieManageris the idiomatic route for those, and if you'd prefer to expose it directly that is clearly the better-typed answer - I'm not arguing against it.The case for this one is scope. It's ~100 lines that cover reading cookies, writing cookies, and every other CDP domain, without committing the plugin to a cookie model it then has to maintain and version. It also preserves the full cookie record -
domain,path,expires,httpOnly,secure,sameSite- because callers get the raw CDP result rather than a flattened representation. If a first-classCookieManagerAPI lands later, this stays useful and doesn't conflict with it.Changes
lib/src/webview.dart-callDevToolsProtocolMethod(String method, [String parametersAsJson = '{}']), returningFuture<String?>, with the same_isDisposed/value.isInitializedguards the neighbouring methods use.windows/webview.cc/webview.h-CallDevToolsProtocolMethodonWebview, taking a completion callback that receives the returned JSON.windows/webview_bridge.cc- method-channel handler, mirroring the existing argument-validation and error-reply style.CHANGELOG.md- anUnreleasedentry. Happy to drop this if you'd rather write changelog entries at release time.Additive only - no existing behaviour or public API is changed.
Testing
The example app builds on Windows (the CI job here). The change has been running in a shipping Flutter desktop app for several weeks, using
Storage.getCookiesandStorage.setCookiesagainst a live WebView2 session.Happy to adjust the naming, the parameter shape (a
Mapinstead of a JSON string), or the return type if you'd prefer something different.