Skip to content

Add spec for CookieManagement.md#463

Merged
peiche-ms merged 13 commits intoapi-cookie-management-interimfrom
api-cookie-management
Oct 2, 2020
Merged

Add spec for CookieManagement.md#463
peiche-ms merged 13 commits intoapi-cookie-management-interimfrom
api-cookie-management

Conversation

@peiche-ms
Copy link
Copy Markdown
Collaborator

This is a review for the new Cookie Management APIs.

@peiche-ms peiche-ms added the API Proposal Review WebView2 API Proposal for review. label Sep 21, 2020
@peiche-ms peiche-ms changed the base branch from master to api-cookie-management-interim September 23, 2020 00:28
@MichaelKetting
Copy link
Copy Markdown

Thank you, looks good to me.
(#4)

@ukandrewc
Copy link
Copy Markdown

So it's easier to handle your own downloads, can there be a function to convert to .Net cookie.
Thanks

Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
@MysteriousGreenBean
Copy link
Copy Markdown

There is HttpOnly property, so for sure we can create HttpOnly cookies, which is good thing. Will GetCookiesAsync return HttpOnly cookies as well?

Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated

void SetCookieCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
CoreWebView2Cookie cookie = _cookieManager.CreateCookie("CookieName", "CookieValue", ".bing.com", "/");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the '.' at the start of .bing.com necessary or have special meaning? The parameter is named 'domain' and I wouldn't offhand expect I need to put a '.' at the start of the parameter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary for CDP

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what does it mean? Does it just mean 'bing.com'? AFAIK the empty domain name label is only valid for the root and is not allowed elsewhere in a domain name. Is this syntax specific to CDP? I don't see anything about this in the cookie spec. I also don't see anything about it in CDP docs (but that doesn't necessarily mean anything)

Comment thread specs/CookieManagement.md Outdated
}

/// A list of cookie objects.
runtimeclass CoreWebView2CookieList
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In COM I understand having our own list type, but for .NET and WinRT can we use existing types from those languages/runtimes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For .NET, CoreWebView2CookieList should implement System.Collections.Generic.IList<CoreWebView2Cookie>; for WinRT, CoreWebView2CookieList should implement Windows.Foundation.Collections.IVector<CoreWebView2Cookie>.

Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
/// The default is the host that this cookie has been received from.
String Domain { get; };

/// The path for which the cookie is valid. If not specified, this cookie
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'not specified' here means empty string or null I guess right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Should say it explicitly in the comment?

Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated

void AddOrUpdateCookieCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
CoreWebView2Cookie cookie = webView.CoreWebView2.CookieManager.CreateCookieWithDetails("CookieName", "CookieValue", ".bing.com", "/");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with the prefix '.' on 'bing.com'? Is '.bing.com' different from 'bing.com'? If so, this needs a comment in the API documentation

Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
@RichardSteele
Copy link
Copy Markdown

ICoreWebView2CookieManager::GetCookies wants to have a uri. What if I don't know it or want to get all cookies? Let's say that I'd like to delete session cookies only.

Comment thread specs/CookieManagement.md
/// The expiration date and time for the cookie as the number of seconds since the UNIX epoch.
/// The default is -1.0, which means cookies are session cookies by default.
Double Expires { get; set; };
Windows.Foundation.DateTime Expires { get; set; };
Copy link
Copy Markdown

@Symbai Symbai Oct 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work in WPF/Winforms? I believe Windows.Foundation.DateTime is UWP only, isn't it? In case it is, then we should revert back to Double as the WebView2 control is available on WPF and on Winforms too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use Windows.Foundation.DateTime for WinRT API only, and we use Double for .NET API.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a datetime type in .NET also right? Can't we use the appropriate datetime type for .NET?

@peiche-ms
Copy link
Copy Markdown
Collaborator Author

ICoreWebView2CookieManager::GetCookies wants to have a uri. What if I don't know it or want to get all cookies? Let's say that I'd like to delete session cookies only.

Updated ICoreWebView2CookieManager::GetCookies to return all cookies under the same user profile if uri is not specified,

Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Comment thread specs/CookieManagement.md Outdated
Copy link
Copy Markdown
Contributor

@david-risney david-risney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ready for api review. Please open PR to master. Thanks!

@peiche-ms peiche-ms merged commit 09ec2cf into api-cookie-management-interim Oct 2, 2020
@peiche-ms peiche-ms deleted the api-cookie-management branch October 17, 2022 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Proposal Review WebView2 API Proposal for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants