@@ -53,6 +53,147 @@ See [API Details](#api-details) section below for API reference.
5353
5454# API Details
5555
56+ ## Win32 C++
57+
58+ ``` IDL
59+ interface ICoreWebView2;
60+ interface ICoreWebView2Cookie;
61+ interface ICoreWebView2CookieList;
62+ interface ICoreWebView2CookieManager;
63+ interface ICoreWebView2GetCookiesCompletedHandler;
64+
65+ /// Kind of cookie SameSite status used in the ICoreWebView2Cookie interface.
66+ /// These fields match those as specified in https://developer.mozilla.org/docs/Web/HTTP/Cookies#.
67+ /// Learn more about SameSite cookies here: https://tools.ietf.org/html/draft-west-first-party-cookies-07
68+ [v1_enum]
69+ typedef enum COREWEBVIEW2_COOKIE_SAME_SITE_KIND {
70+ /// None SameSite type. No restrictions on cross-site requests.
71+ COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE,
72+ /// Lax SameSite type. The cookie will be sent with "same-site" requests, and with "cross-site" top level navigation.
73+ COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX,
74+ /// Strict SameSite type. The cookie will only be sent along with "same-site" requests.
75+ COREWEBVIEW2_COOKIE_SAME_SITE_KIND_STRICT,
76+ } COREWEBVIEW2_COOKIE_SAME_SITE_KIND;
77+
78+ [uuid(20113081-93BD-4F2A-86B9-ADF92DEAAF10), object, pointer_default(unique)]
79+ interface ICoreWebView2 : IUnknown {
80+ /// Create a new cookie manager object. See ICoreWebView2CookieManager.
81+ HRESULT CreateCookieManager([out, retval] ICoreWebView2CookieManager** cookieManager);
82+ }
83+
84+ /// Provides a set of properties that are used to manage an
85+ /// ICoreWebView2Cookie.
86+ [uuid(0AD66B3B-316F-4F54-8472-F5FF54360A60), object, pointer_default(unique)]
87+ interface ICoreWebView2Cookie : IUnknown {
88+ /// Cookie name.
89+ [propget] HRESULT Name([out, retval] LPWSTR* name);
90+
91+ /// Cookie value.
92+ [propget] HRESULT Value([out, retval] LPWSTR* value);
93+ /// Set the cookie value property.
94+ [propput] HRESULT Value([in] LPCWSTR value);
95+
96+ /// The domain for which the cookie is valid.
97+ /// The default is the host that this cookie has been received from.
98+ [propget] HRESULT Domain([out, retval] LPWSTR* domain);
99+
100+ /// The path for which the cookie is valid. If not specified, this cookie
101+ /// will be sent to all pages on the Domain.
102+ [propget] HRESULT Path([out, retval] LPWSTR* path);
103+
104+ /// The expiration date and time for the cookie as the number of seconds since the UNIX epoch.
105+ /// The default is -1.0, which means cookies are session cookies by default.
106+ [propget] HRESULT Expires([out, retval] double* expires);
107+ /// Set the Expires property. Cookies are session cookies
108+ /// and will not be persistent if Expires is negative.
109+ [propput] HRESULT Expires([in] double expires);
110+
111+ /// Whether this cookie is http-only.
112+ /// True if a page script or other active content cannot access this
113+ /// cookie. The default is false.
114+ [propget] HRESULT HttpOnly([out, retval] BOOL* httpOnly);
115+ /// Set the HttpOnly property.
116+ [propput] HRESULT HttpOnly([in] BOOL httpOnly);
117+
118+ /// SameSite status of the cookie which represents the enforcement mode of the cookie.
119+ /// The default is COREWEBVIEW2_COOKIE_SAME_SITE_KIND_LAX.
120+ [propget] HRESULT SameSite([out, retval] COREWEBVIEW2_COOKIE_SAME_SITE_KIND* sameSite);
121+ /// Set the SameSite property.
122+ [propput] HRESULT SameSite([in] COREWEBVIEW2_COOKIE_SAME_SITE_KIND sameSite);
123+
124+ /// The security level of this cookie. True if the client is only to return
125+ /// the cookie in subsequent requests if those requests use HTTPS.
126+ /// The default is false.
127+ /// Note that cookie that requests COREWEBVIEW2_COOKIE_SAME_SITE_KIND_NONE but
128+ /// is not marked Secure will be rejected.
129+ [propget] HRESULT Secure([out, retval] BOOL* secure);
130+ /// Set the Secure property.
131+ [propput] HRESULT Secure([in] BOOL secure);
132+ }
133+
134+ /// Add or delete an ICoreWebView2Cookie or ICoreWebView2Cookies,
135+ /// or view the cookies. The changes would apply to the context of the user profile.
136+ /// That is, other WebViews under the same user profile could be affected.
137+ [uuid(588C8A15-A28A-4FFD-926B-5E6EE7449E7C), object, pointer_default(unique)]
138+ interface ICoreWebView2CookieManager : IUnknown {
139+ /// Create a cookie object with a specified name, value, domain, and path.
140+ /// One can set other optional properties after cookie creation.
141+ /// See ICoreWebView2Cookie for more details.
142+ HRESULT CreateCookie(
143+ [in] LPCWSTR name,
144+ [in] LPCWSTR value,
145+ [in] LPCWSTR domain,
146+ [in] LPCWSTR path,
147+ [out, retval] ICoreWebView2Cookie** cookie);
148+
149+ /// Gets a list of cookies matching the specific URI.
150+ /// You can modify the cookie objects, call
151+ /// ICoreWebView2CookieManager::SetCookie, and the changes
152+ /// will be applied to the webview.
153+ HRESULT GetCookies(
154+ [in] LPCWSTR uri,
155+ [in] ICoreWebView2GetCookiesCompletedHandler* handler);
156+
157+ /// Sets a cookie with the given cookie data; may overwrite equivalent cookies
158+ /// if they exist.
159+ HRESULT SetCookie([in] ICoreWebView2Cookie* cookie);
160+
161+ /// Deletes browser cookies with matching name and uri or domain/path pair.
162+ /// Cookie name is required.
163+ /// If uri is specified, deletes all cookies with the given name where domain
164+ /// and path match provided URI.
165+ /// If domain is specified, deletes only cookies with the exact domain.
166+ /// If path is specified, deletes only cookies with the exact path.
167+ HRESULT DeleteCookies([in] LPCWSTR name, [in] LPCWSTR uri, [in] LPCWSTR domain, [in] LPCWSTR path);
168+
169+ /// Clears all cookies under the same profile.
170+ /// This could affect other WebViews under the same user profile.
171+ HRESULT ClearAllCookies();
172+ }
173+
174+ /// A list of cookie objects. See ICoreWebView2Cookie.
175+ [uuid(02F758AF-2F1C-4263-A5F8-37CA875B40D1), object, pointer_default(unique)]
176+ interface ICoreWebView2CookieList : IUnknown {
177+ /// The number of cookies contained in the ICoreWebView2CookieList.
178+ [propget] HRESULT Size([out, retval] UINT* size);
179+
180+ /// Get the cookie object at the given index.
181+ HRESULT GetValueAtIndex([in] UINT index, [out, retval] ICoreWebView2Cookie** cookie);
182+ }
183+
184+ /// The caller implements this method to receive the result of the
185+ /// GetCookies method. The result is written to the cookie list provided in
186+ /// the GetCookies method call.
187+ [uuid(0AD3D432-69E9-4223-9CC4-460C20BDCEF5), object, pointer_default(unique)]
188+ interface ICoreWebView2GetCookiesCompletedHandler : IUnknown {
189+ /// Called to provide the implementer with the completion status
190+ /// of the corresponding asynchronous method call.
191+ HRESULT Invoke(HRESULT result, ICoreWebView2CookieList* cookieList);
192+ }
193+ ```
194+
195+ ## .NET and WinRT
196+
56197``` c#
57198namespace Microsoft .Web .WebView2 .Core
58199{
0 commit comments