Skip to content

Commit efc180b

Browse files
committed
Review Feedback 5
1 parent 80a7b2f commit efc180b

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

specs/CookieManagement.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static std::wstring CookieToJsonString(ICoreWebView2Cookie* cookie)
8383
CHECK_FAILURE(cookie->get_Path(&path));
8484
double expires;
8585
CHECK_FAILURE(cookie->get_Expires(&expires));
86-
BOOL httpOnly;
86+
BOOL httpOnly = FALSE;
8787
CHECK_FAILURE(cookie->get_IsHttpOnly(&httpOnly));
8888
COREWEBVIEW2_COOKIE_SAME_SITE_KIND same_site;
8989
std::wstring same_site_as_string;
@@ -100,16 +100,18 @@ static std::wstring CookieToJsonString(ICoreWebView2Cookie* cookie)
100100
same_site_as_string = L"Strict";
101101
break;
102102
}
103-
BOOL secure;
103+
BOOL secure = FALSE;
104104
CHECK_FAILURE(cookie->get_IsSecure(&secure));
105+
BOOL isSession = FALSE;
106+
CHECK_FAILURE(cookie->get_IsSession(&isSession));
105107

106108
std::wstring result = L"{";
107109
result += L"\"Name\": " + EncodeQuote(name.get()) + L", " + L"\"Value\": " +
108110
EncodeQuote(value.get()) + L", " + L"\"Domain\": " + EncodeQuote(domain.get()) +
109111
L", " + L"\"Path\": " + EncodeQuote(path.get()) + L", " + L"\"HttpOnly\": " +
110112
BoolToString(httpOnly) + L", " + L"\"Secure\": " + BoolToString(secure) + L", " +
111113
L"\"SameSite\": " + EncodeQuote(same_site_as_string) + L", " + L"\"Expires\": ";
112-
if (expires == -1)
114+
if (!!isSession)
113115
{
114116
result += L"This is a session cookie.";
115117
}
@@ -183,12 +185,12 @@ void AddOrUpdateCookieCmdExecuted(object target, ExecutedRoutedEventArgs e)
183185
184186
async void GetCookiesCmdExecuted(object target, ExecutedRoutedEventArgs e)
185187
{
186-
CoreWebView2CookieList cookieList = await webView.CoreWebView2.CookieManager.GetCookiesAsync("https://www.bing.com");
187-
for (int i = 0; i < cookieList.Count; ++i)
188+
IList<CoreWebView2Cookie> cookieList = await webView.CoreWebView2.CookieManager.GetCookiesAsync("https://www.bing.com");
189+
for (uint i = 0; i < cookieList.Count; ++i)
188190
{
189191
CoreWebView2Cookie cookie = cookieList[i];
190-
System.Net.Cookie dotNetCookie = CoreWebView2Cookie.CoreWebView2ToDotNetCookie(cookie);
191-
Console.WriteLine(dotNetCookie.ToString());
192+
Cookie systemNetCookie = cookie.ToSystemNetCookie();
193+
Console.WriteLine(systemNetCookie.ToString());
192194
}
193195
}
194196
@@ -271,9 +273,9 @@ interface ICoreWebView2Cookie : IUnknown {
271273
/// Whether this cookie is http-only.
272274
/// True if a page script or other active content cannot access this
273275
/// cookie. The default is false.
274-
[propget] HRESULT IsHttpOnly([out, retval] BOOL* httpOnly);
275-
/// Set the HttpOnly property.
276-
[propput] HRESULT IsHttpOnly([in] BOOL httpOnly);
276+
[propget] HRESULT IsHttpOnly([out, retval] BOOL* isHttpOnly);
277+
/// Set the IsHttpOnly property.
278+
[propput] HRESULT IsHttpOnly([in] BOOL isHttpOnly);
277279
278280
/// SameSite status of the cookie which represents the enforcement mode of the cookie.
279281
/// The default is COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX.
@@ -286,9 +288,12 @@ interface ICoreWebView2Cookie : IUnknown {
286288
/// The default is false.
287289
/// Note that cookie that requests COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE but
288290
/// is not marked Secure will be rejected.
289-
[propget] HRESULT IsSecure([out, retval] BOOL* secure);
290-
/// Set the Secure property.
291-
[propput] HRESULT IsSecure([in] BOOL secure);
291+
[propget] HRESULT IsSecure([out, retval] BOOL* isSecure);
292+
/// Set the IsSecure property.
293+
[propput] HRESULT IsSecure([in] BOOL isSecure);
294+
295+
/// Whether this is a session cookie. The default is false.
296+
[propget] HRESULT IsSession([out, retval] BOOL* isSession);
292297
}
293298
294299
/// Creates, adds or updates, gets, or or view the cookies. The changes would
@@ -444,16 +449,6 @@ namespace Microsoft.Web.WebView2.Core
444449
void DeleteAllCookies();
445450
}
446451

447-
/// A list of cookie objects.
448-
runtimeclass CoreWebView2CookieList : Windows.Foundation.Collections.IVector<CoreWebView2Cookie>
449-
{
450-
/// The number of cookies contained in the CoreWebView2CookieList.
451-
uint Size { get; };
452-
453-
/// Get the cookie object at the given index.
454-
CoreWebView2Cookie GetAt(uint index);
455-
}
456-
457452
/// Provides a set of properties that are used to manage a CoreWebView2Cookie.
458453
runtimeclass CoreWebView2Cookie
459454
{
@@ -493,13 +488,16 @@ namespace Microsoft.Web.WebView2.Core
493488
/// is not marked Secure will be rejected.
494489
Boolean IsSecure { get; set; };
495490

491+
/// Whether this is a session cookie. The default is false.
492+
Boolean IsSession { get; };
493+
496494
/// Converts a System.Net.Cookie to a CoreWebView2Cookie.
497495
/// This is only for the .NET API, not the WinRT API.
498-
static CoreWebView2Cookie DotNetToCoreWebView2Cookie(System.Net.Cookie dotNetCookie);
496+
static CoreWebView2Cookie FromSystemNetCookie(System.Net.Cookie dotNetCookie);
499497

500498
/// Converts a CoreWebView2Cookie to a System.Net.Cookie.
501499
/// This is only for the .NET API, not the WinRT API.
502-
static System.Net.Cookie CoreWebView2ToDotNetCookie(CoreWebView2Cookie coreWebView2Cookie);
500+
System.Net.Cookie ToSystemNetCookie(CoreWebView2Cookie coreWebView2Cookie);
503501
}
504502

505503
// ...

0 commit comments

Comments
 (0)