| // Copyright 2020 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module network.mojom; |
| |
| import "url/mojom/url.mojom"; |
| import "services/network/public/mojom/site_for_cookies.mojom"; |
| import "services/network/public/mojom/cookie_manager.mojom"; |
| |
| struct CookieAccessDetails { |
| enum Type { |
| kRead, |
| kChange, |
| }; |
| |
| // Whether this request corresponds to a cookie read or a cookie write. |
| Type type; |
| |
| // If the cookies are accessed by a network transfer, |url| is the URL being |
| // loaded; if they're read by a script, it's the URL of window or service |
| // worker script looking them up. |
| url.mojom.Url url; |
| |
| SiteForCookies site_for_cookies; |
| // Each element of the `cookie_list` array includes a CookieInclusionStatus |
| // and a CanonicalCookie if one was successfully constructed; if we were |
| // unable to create the CanonicalCookie, then we use the cookie string |
| // instead. Note that this means we always get a CanonicalCookie for reads, |
| // but may get a cookie string on writes. |
| array<CookieOrLineWithAccessResult> cookie_list; |
| |
| // |devtools_request_id| contains the DevTools request id of the request |
| // that triggered the cookie change, if the read was triggered by a request. |
| string? devtools_request_id; |
| }; |
| |
| // Cloneable interface to observe the cookie reads or writes. |
| // The user of the NetworkService should create a dedicated |
| // CookieAccessObserver for each context it is interested in. |
| interface CookieAccessObserver { |
| // Called when an attempt has been made to access (read or write) the cookies |
| // in |details.cookie_list|, with the status indicating cookies were actually |
| // used or blocked (and if blocked gives the reason). Currently, blocked |
| // cookies are included if they are blocked by user preference, or if they |
| // warrant a console deprecation warning. |
| // The network skips sending this notification on consecutive "duplicate" |
| // access events (i.e. where the cookie and its access result remain unchanged |
| // since the previous event). |
| OnCookiesAccessed(CookieAccessDetails details); |
| |
| // Used by the NetworkService to create a copy of this observer. |
| // (e.g. when creating an observer for URLLoader from URLLoaderFactory's |
| // observer). |
| Clone(pending_receiver<CookieAccessObserver> listener); |
| }; |