Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9b66f6c
[webview_flutter_wkwebview] Implement getCookies method to retrieve c…
khaled-0 Jan 20, 2026
4f2f4e8
[webview_flutter_android] Implement getCookies method
khaled-0 Jan 20, 2026
150d9cc
[webview_flutter_android] test for getCookies
khaled-0 Jan 21, 2026
b5f94a5
[webview_flutter_wkwebview] test for getCookies
khaled-0 Jan 21, 2026
2d5a916
[webview_flutter_wkwebview] match getAllCookies function signature
khaled-0 Jan 21, 2026
0cd5df3
[webview_flutter_wkwebview] Refactor getCookies to use if let
khaled-0 Jan 25, 2026
092db6e
[webview_flutter_android][webview_flutter_wkwebview] Use CookieManage…
khaled-0 Mar 30, 2026
45fa55f
[webview_flutter_android][webview_flutter_wkwebview] make api more co…
khaled-0 Feb 8, 2026
0f9fc43
[webview_flutter_android][webview_flutter_wkwebview] Bump webview_flu…
khaled-0 Mar 30, 2026
8fcd044
[webview_flutter_android][webview_flutter_wkwebview] Regenerate pigeo…
khaled-0 Mar 30, 2026
d60c7b1
[webview_flutter_wkwebview] Update getCookies test to use getAllCookies
khaled-0 Mar 30, 2026
3ec2eb1
[webview_flutter_android][webview_flutter_wkwebview] Apply formattings
khaled-0 Mar 30, 2026
5c25776
[webview_flutter_android] Remove getCookies_returnsEmptyStringIfNull
khaled-0 Mar 30, 2026
09a5802
[webview_flutter_android][webview_flutter_wkwebview] Bump version, ad…
khaled-0 Mar 30, 2026
2f01b98
[webview_flutter_wkwebview] Follow RFC 6265 guideline for `getCookies…
khaled-0 Mar 30, 2026
ab380f1
[webview_flutter_wkwebview][webview_flutter_android] Fail early in HT…
khaled-0 Apr 12, 2026
a7bc03c
Merge branch 'main' into implementations
khaled-0 Apr 14, 2026
8ac1939
fix version bump
bparrishMines Apr 27, 2026
979af46
fix generated dart
bparrishMines Apr 28, 2026
14facae
Merge branch 'main' of github.com:flutter/packages into implementations
bparrishMines Apr 28, 2026
f1accca
fix pubspec android
bparrishMines Apr 28, 2026
f258911
fix remove test
bparrishMines Apr 28, 2026
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
4 changes: 4 additions & 0 deletions packages/webview_flutter/webview_flutter_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.12.0

* Adds support for retrieving cookies with `PlatformWebViewCookieManager.getCookies`.

## 4.11.0

* Adds support to opt out of Android inset changes. See
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.2.0), do not edit directly.
// Autogenerated from Pigeon (v26.3.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")

Expand Down Expand Up @@ -49,7 +49,7 @@ class AndroidWebKitError(
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()
/**
* Maintains instances used to communicate with the corresponding objects in Dart.
*
Expand Down Expand Up @@ -1568,6 +1568,18 @@ abstract class PigeonApiCookieManager(
accept: Boolean
)

/**
* Gets all the cookies for the given URL.
*
* This may return multiple key-value pairs if multiple cookies are associated with this URL, in
* which case each cookie will be delimited by "; " characters (semicolon followed by a space).
* Each key-value pair will be of the form "key=value".
*
* Note: Any cookies set with the "Partitioned" attribute will only be returned for the top-level
* partition of url.
*/
abstract fun getCookies(pigeon_instance: android.webkit.CookieManager, url: String): String?

companion object {
@Suppress("LocalVariableName")
fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiCookieManager?) {
Expand Down Expand Up @@ -1670,6 +1682,29 @@ abstract class PigeonApiCookieManager(
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.webview_flutter_android.CookieManager.getCookies",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as android.webkit.CookieManager
val urlArg = args[1] as String
val wrapped: List<Any?> =
try {
listOf(api.getCookies(pigeon_instanceArg, urlArg))
} catch (exception: Throwable) {
AndroidWebkitLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public void setAcceptThirdPartyCookies(
@NonNull CookieManager pigeon_instance, @NonNull WebView webView, boolean accept) {
pigeon_instance.setAcceptThirdPartyCookies(webView, accept);
}

@Override
public @NonNull String getCookies(@NonNull CookieManager pigeon_instance, @NonNull String url) {
Comment thread
khaled-0 marked this conversation as resolved.
return pigeon_instance.getCookie(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.webkit.CookieManager;
import android.webkit.ValueCallback;
Expand Down Expand Up @@ -64,4 +65,20 @@ public void setAcceptThirdPartyCookies() {

verify(instance).setAcceptThirdPartyCookies(webView, accept);
}

@Test
public void getCookies_returnsCookieString() {
final PigeonApiCookieManager api = new TestProxyApiRegistrar().getPigeonApiCookieManager();

final CookieManager instance = mock(CookieManager.class);
final String domain = "https://flutter.dev";
final String cookieValue = "session=12345";

// Mock the CookieManager to return the cookie string
when(instance.getCookie(domain)).thenReturn(cookieValue);

final String result = api.getCookies(instance, domain);

assertEquals(cookieValue, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,17 @@ class SampleMenu extends StatelessWidget {
}

Future<void> _onListCookies(BuildContext context) async {
final cookies =
await webViewController.runJavaScriptReturningResult('document.cookie')
as String;
final Uri? domain = Uri.tryParse(
(await webViewController.currentUrl()) ?? '',
);
final List<WebViewCookie> cookies;

if (domain == null) {
cookies = [];
} else {
cookies = await cookieManager.getCookies(domain);
}

if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
Expand Down Expand Up @@ -662,13 +670,12 @@ class SampleMenu extends StatelessWidget {
return webViewController.loadHtmlString(kAlertTestPage);
}

Widget _getCookieList(String cookies) {
if (cookies == '""') {
Widget _getCookieList(List<WebViewCookie> cookies) {
if (cookies.isEmpty) {
return Container();
}
final List<String> cookieList = cookies.split(';');
final Iterable<Text> cookieWidgets = cookieList.map(
(String cookie) => Text(cookie),
final Iterable<Text> cookieWidgets = cookies.map(
(WebViewCookie cookie) => Text(cookie.toString()),
);
return Column(
mainAxisAlignment: MainAxisAlignment.end,
Expand Down
Loading
Loading