Skip to content

Commit 4b9cf65

Browse files
committed
Review Feedback 2
1 parent da64e47 commit 4b9cf65

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

specs/CookieManagement.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ScenarioCookieManagement::ScenarioCookieManagement(AppWindow* appWindow)
1717
: m_appWindow(appWindow), m_webView(appWindow->GetWebView())
1818
{
1919
//! [CookieManager]
20-
CHECK_FAILURE(m_webViewstaging->get_CookieManager(&m_cookieManager));
20+
CHECK_FAILURE(m_webView->get_CookieManager(&m_cookieManager));
2121
//! [CookieManager]
2222

2323
CHECK_FAILURE(m_webView->add_WebMessageReceived(
@@ -51,7 +51,7 @@ ScenarioCookieManagement::ScenarioCookieManagement(AppWindow* appWindow)
5151

5252
//! [AddOrUpdateCookie]
5353
wil::com_ptr<ICoreWebView2Cookie> cookie;
54-
CHECK_FAILURE(m_cookieManager->CreateCookieWithDetails(
54+
CHECK_FAILURE(m_cookieManager->CreateCookie(
5555
name.c_str(), value.c_str(), L".bing.com", L"/", &cookie));
5656
CHECK_FAILURE(m_cookieManager->AddOrUpdateCookie(cookie.get()));
5757
reply = L"{\"CookieAddedOrUpdated\":\"Cookie added or updated successfully.\"}";
@@ -174,14 +174,9 @@ void ScenarioCookieManagement::GetCookiesHelper(std::wstring uri)
174174
## .NET and WinRT
175175
176176
```c#
177-
void CookieManagementCmdsCanExecute(object sender, CanExecuteRoutedEventArgs e)
178-
{
179-
e.CanExecute = webView != null && webView.CoreWebView2 != null && webView.CoreWebView2.CookieManager != null;
180-
}
181-
182177
void AddOrUpdateCookieCmdExecuted(object target, ExecutedRoutedEventArgs e)
183178
{
184-
CoreWebView2Cookie cookie = webView.CoreWebView2.CookieManager.CreateCookieWithDetails("CookieName", "CookieValue", ".bing.com", "/");
179+
CoreWebView2Cookie cookie = webView.CoreWebView2.CookieManager.CreateCookie("CookieName", "CookieValue", ".bing.com", "/");
185180
cookie.SameSite = CoreWebView2CookieSameSiteKind.None;
186181
webView.CoreWebView2.CookieManager.AddOrUpdateCookie(cookie);
187182
}
@@ -204,7 +199,7 @@ void DeleteAllCookiesCmdExecuted(object target, ExecutedRoutedEventArgs e)
204199
205200
void DeleteCookiesCmdExecuted(object target, ExecutedRoutedEventArgs e)
206201
{
207-
webView.CoreWebView2.CookieManager.DeleteCookies("CookieName", "https://www.bing.com", "", "");
202+
webView.CoreWebView2.CookieManager.DeleteCookies("CookieName", "https://www.bing.com");
208203
}
209204
```
210205

@@ -217,7 +212,7 @@ See [API Details](#api-details) section below for API reference.
217212
## Win32 C++
218213

219214
```IDL
220-
interface ICoreWebView2;
215+
interface ICoreWebView2_2;
221216
interface ICoreWebView2Cookie;
222217
interface ICoreWebView2CookieList;
223218
interface ICoreWebView2CookieManager;
@@ -237,7 +232,9 @@ typedef enum COREWEBVIEW2_COOKIE_SAME_SITE_KIND {
237232
} COREWEBVIEW2_COOKIE_SAME_SITE_KIND;
238233
239234
[uuid(20113081-93BD-4F2A-86B9-ADF92DEAAF10), object, pointer_default(unique)]
240-
interface ICoreWebView2 : IUnknown {
235+
interface ICoreWebView2_2 : ICoreWebView2 {
236+
// ...
237+
241238
/// Gets the cookie manager object associated with this ICoreWebView2.
242239
[propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** cookieManager);
243240
}
@@ -309,11 +306,10 @@ interface ICoreWebView2CookieManager : IUnknown {
309306
[in] LPCWSTR path,
310307
[out, retval] ICoreWebView2Cookie** cookie);
311308
312-
313309
/// Creates a cookie whose params matches those of the specified cookie.
314310
HRESULT CreateCookie(
315-
[in] ICoreWebView2StagingCookie* cookieParam,
316-
[out, retval] ICoreWebView2StagingCookie** cookie);
311+
[in] ICoreWebView2Cookie* cookieParam,
312+
[out, retval] ICoreWebView2Cookie** cookie);
317313
318314
/// Gets a list of cookies matching the specific URI.
319315
/// You can modify the cookie objects, call
@@ -328,15 +324,19 @@ interface ICoreWebView2CookieManager : IUnknown {
328324
HRESULT AddOrUpdateCookie([in] ICoreWebView2Cookie* cookie);
329325
330326
/// Deletes a cookie whose params matches those of the specified cookie.
331-
HRESULT DeleteCookie([in] ICoreWebView2StagingCookie* cookie);
327+
HRESULT DeleteCookie([in] ICoreWebView2Cookie* cookie);
332328
333-
/// Deletes browser cookies with matching name and uri or domain/path pair.
329+
/// Deletes cookies with matching name and uri.
334330
/// Cookie name is required.
335331
/// If uri is specified, deletes all cookies with the given name where domain
336332
/// and path match provided URI.
333+
HRESULT DeleteCookies([in] LPCWSTR name, [in] LPCWSTR uri);
334+
335+
/// Deletes cookies with matching name and domain/path pair.
336+
/// Cookie name is required.
337337
/// If domain is specified, deletes only cookies with the exact domain.
338338
/// If path is specified, deletes only cookies with the exact path.
339-
HRESULT DeleteCookies([in] LPCWSTR name, [in] LPCWSTR uri, [in] LPCWSTR domain, [in] LPCWSTR path);
339+
HRESULT DeleteCookiesWithDomainAndPath([in] LPCWSTR name, [in] LPCWSTR domain, [in] LPCWSTR path);
340340
341341
/// Deletes all cookies under the same profile.
342342
/// This could affect other WebViews under the same user profile.
@@ -419,13 +419,17 @@ namespace Microsoft.Web.WebView2.Core
419419
/// Deletes a cookie whose params matches those of the specified cookie.
420420
void DeleteCookie(CoreWebView2Cookie cookie);
421421

422-
/// Deletes browser cookies with matching name and uri or domain/path pair.
422+
/// Deletes cookies with matching name and uri.
423423
/// Cookie name is required.
424424
/// If uri is specified, deletes all cookies with the given name where domain
425425
/// and path match provided URI.
426+
void DeleteCookies(String name, String uri);
427+
428+
/// Deletes cookies with matching name and domain/path pair.
429+
/// Cookie name is required.
426430
/// If domain is specified, deletes only cookies with the exact domain.
427431
/// If path is specified, deletes only cookies with the exact path.
428-
void DeleteCookies(String name, String uri, String Domain, String Path);
432+
void DeleteCookiesWithDomainAndPath(String name, String Domain, String Path);
429433

430434
/// Deletes all cookies under the same profile.
431435
/// This could affect other WebViews under the same user profile.
@@ -461,7 +465,7 @@ namespace Microsoft.Web.WebView2.Core
461465

462466
/// The expiration date and time for the cookie as the number of seconds since the UNIX epoch.
463467
/// The default is -1.0, which means cookies are session cookies by default.
464-
Double Expires { get; set; };
468+
Windows.Foundation.DateTime Expires { get; set; };
465469

466470
/// Whether this cookie is http-only.
467471
/// True if a page script or other active content cannot access this
@@ -480,9 +484,11 @@ namespace Microsoft.Web.WebView2.Core
480484
Boolean IsSecure { get; set; };
481485

482486
/// Converts a System.Net.Cookie to a CoreWebView2Cookie.
487+
/// This is only for the .NET API, not the WinRT API.
483488
static CoreWebView2Cookie DotNetToCoreWebView2Cookie(System.Net.Cookie dotNetCookie);
484489

485490
/// Converts a CoreWebView2Cookie to a System.Net.Cookie.
491+
/// This is only for the .NET API, not the WinRT API.
486492
static System.Net.Cookie CoreWebView2ToDotNetCookie(CoreWebView2Cookie coreWebView2Cookie);
487493
}
488494

0 commit comments

Comments
 (0)