Chromium Code Reviews| Index: content/common/cookies.mojom |
| diff --git a/content/common/cookies.mojom b/content/common/cookies.mojom |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..05634765487d43ee7f888f3946a33f1852968491 |
| --- /dev/null |
| +++ b/content/common/cookies.mojom |
| @@ -0,0 +1,142 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +module content.mojom; |
| + |
| +import "mojo/common/time.mojom"; |
| +import "url/mojo/url.mojom"; |
| + |
| +// TODO(rdsmith): Comment. |
| + |
| +enum CookiePriority { |
| + LOW, |
| + MEDIUM, |
| + HIGH |
| +}; |
| + |
| +// TODO(rdsmith): Are both of these really needed? |
| + |
| +enum CookieSameSite { |
| + NO_RESTRICTION, |
| + LAX_MODE, |
| + STRICT_MODE |
| +}; |
| + |
| +enum CookieSameSiteFilter { |
| + INCLUDE_STRICT_AND_LAX, |
| + INCLUDE_LAX, |
| + DO_NOT_INCLUDE |
| +}; |
| + |
| +struct CookieOptions { |
| + // TOOD(rdsmith): Defaults from constructor or wrapping function? |
|
yzshen1
2017/06/20 18:33:17
The default values are set by the constructor.
(Pl
|
| + bool exclude_httponly = true; |
| + CookieSameSiteFilter cookie_same_site_filter = DO_NOT_INCLUDE; |
| + bool update_access_time = true; |
| + mojo.common.mojom.Time? server_time; |
| +}; |
| + |
| +struct CanonicalCookie { |
| + string name; |
| + string value; |
| + string domain; |
| + string path; |
| + mojo.common.mojom.Time creation; |
| + mojo.common.mojom.Time expiry; |
| + mojo.common.mojom.Time last_access; |
| + bool secure = true; |
| + bool httponly = false; |
| + CookieSameSite site_restrictions = NO_RESTRICTION; |
| + CookiePriority priority = MEDIUM; |
| +}; |
| + |
| +enum CookieChangeCause { |
| + // The cookie was inserted. |
| + INSERTED, |
| + // The cookie was changed directly by a consumer's action. |
| + EXPLICIT, |
| + // The cookie was deleted, but no more details are known. |
| + UNKNOWN_DELETION, |
| + // The cookie was automatically removed due to an insert operation that |
| + // overwrote it. |
| + OVERWRITE, |
| + // The cookie was automatically removed as it expired. |
| + EXPIRED, |
| + // The cookie was automatically evicted during garbage collection. |
| + EVICTED, |
| + // The cookie was overwritten with an already-expired expiration date. |
| + EXPIRED_OVERWRITE |
| +}; |
| + |
| +enum CookieDeletionSessionControl { |
| + IGNORE, |
| + SESSION, |
| + PERSISTENT, |
| +}; |
| + |
| +// All active filters are ANDed together. I.e. if |
| +// |delete_created_after && delete_blacklist| only cookies in the blacklist |
| +// that have been created after the specified date would be deleted. |
| +// If all booleans are false (i.e there is no filter) then |
|
yzshen1
2017/06/20 18:33:17
This comment may need to be updated, it doesn't ha
|
| +// all cookies will be deleted; this can be thought of as there being a |
| +// default "match everything" filter which is ANDed in with all other filters. |
| +struct CookieDeletionFilter { |
| + // Delete cookies created after a date. |
| + mojo.common.mojom.Time? created_after_time; |
| + |
| + // Delete cookies created before a date. |
| + mojo.common.mojom.Time? created_before_time; |
| + |
| + // Delete cookies whose domains are in the blacklist. |
| + array<string>? domain_blacklist; |
| + |
| + // Delete cookies whose domains are in the whitelist. |
| + array<string>? domain_whitelist; |
|
yzshen1
2017/06/20 18:33:17
I am a little confused: do you mean *not* deleting
|
| + |
| + // Delete session/persistent cookies. |
| + CookieDeletionSessionControl session_control = IGNORE; |
| +}; |
| + |
| +interface CookieChangeNotification { |
| + // TODO(rdsmith): Should this be made a batch interface? |
| + OnCookieChanged(CanonicalCookie cookie, CookieChangeCause cause); |
| +}; |
| + |
| +interface CookieService { |
| + // Get all the cookies known to the service. |
| + GetAllCookies() => (array<CanonicalCookie> cookies); |
| + |
| + // Get all cookies for the specified URL and cookie options. |
| + GetCookieList(url.mojom.Url url, CookieOptions cookie_options) => |
| + (array<CanonicalCookie> cookies); |
| + |
| + // Set a cookie. |secure_source| indicates whether existing secure |
| + // cookies can be overwritten (secure cookies may be created from a |
| + // non-secure source). |modify_http_only| indicates whether http_only |
| + // cookies may be overwritten. |
| + // TODO(rdsmith): Might it make sense to base modify_http_only on the |
| + // http_only element of the CanonicalCookie? |
| + SetCanonicalCookie( |
| + CanonicalCookie cookie, bool secure_source, bool modify_http_only) => |
| + (bool success); |
| + |
| + // Delete a set of cookies matching the passed filter. |
| + // Returns the number of cookies deleted. |
| + DeleteCookies(CookieDeletionFilter filter) => (int32 num_deleted); |
|
yzshen1
2017/06/20 18:33:17
nit: the result could be an unsigned number, say,
|
| + |
| + // Register an interace to receive notification when the specified cookie |
| + // associated with the domain/path specified in the URL change. |
| + // TODO(rdsmith): I feel like this neeeds to have a filter to |
| + // register for a lot of notifications at once. Maybe combine with |
| + // the deletion filter? |
| + RequestNotification( |
| + url.mojom.Url url, |
| + string name, |
| + CookieChangeNotification& notification_interface) => (); |
|
yzshen1
2017/06/20 18:33:17
nit: please comment on why an empty callback is ne
|
| + |
| + // Clone the interface for use somewhere else. After this call, |
| + // requests to the same implementation may be posted to the other side |
| + // of the pipe new_interface was configured on. |
| + CloneInterface(CookieService& new_interface); |
| +}; |