Index: content/common/cookie.mojom |
diff --git a/content/common/cookie.mojom b/content/common/cookie.mojom |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d918d7f30bf0ebbc4ddbd2943802e784e4296654 |
--- /dev/null |
+++ b/content/common/cookie.mojom |
@@ -0,0 +1,155 @@ |
+// 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"; |
+ |
+enum CookiePriority { |
+ LOW, |
+ MEDIUM, |
+ HIGH |
+}; |
+ |
+// TODO(rdsmith): Document, if only by reference. |
+enum CookieSameSite { |
+ NO_RESTRICTION, |
+ LAX_MODE, |
+ STRICT_MODE |
+}; |
+ |
+enum CookieSameSiteFilter { |
+ INCLUDE_STRICT_AND_LAX, |
+ INCLUDE_LAX, |
+ DO_NOT_INCLUDE |
+}; |
+ |
+// Keep defaults here in sync with net/cookies/cookie_options.cc. |
+struct CookieOptions { |
+ bool exclude_httponly = true; |
+ CookieSameSiteFilter cookie_same_site_filter = DO_NOT_INCLUDE; |
+ bool update_access_time = true; |
+ mojo.common.mojom.Time? server_time; |
+}; |
+ |
+// See net/cookies/canonical_cookie.{h,cc} for documentation. |
+// Keep defaults here in sync with those files. |
+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; |
+}; |
+ |
+// Keep values here in sync with net::CookieStore::ChangeCause. |
+// (Not typemapped to avoid forcing clients to know about net::CookieStore.) |
+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 |
+}; |
+ |
+// Session cookies are cookies that expire at the end of the browser session. |
+// That is represented in canonical cookies by a null expiry time. |
+enum CookieDeletionSessionControl { |
+ IGNORE, |
+ SESSION, |
+ PERSISTENT, |
+}; |
+ |
+// All existing filters are ANDed together. I.e. if there is a value |
+// for created_after_time and there's a value for domain_blacklist, |
+// only cookies in the blacklist that have been created after the |
+// specified date would be deleted. A value for |
+// session_control of IGNORE is treated the same as optional values not |
+// being present for the other filters. |
+// Note that a whitelist should be considered a deletion filter for everything |
+// that doesn't match the whitelist; i.e. a whitelist + a created_after_time |
+// will only delete cookies that *aren't* in the whitelist AND *are* created |
+// after the specified time. |
+// If no filters are specified then 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; |
+ |
+ // Deletes cookies whose domains are not in the whitelist. |
+ array<string>? domain_whitelist; |
+ |
+ // 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 { |
+ // TODO(rdsmith): Worthwhile specifying a sort order for the getters? |
+ |
+ // 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. |
+ SetCanonicalCookie( |
+ CanonicalCookie cookie, bool secure_source, bool modify_http_only) => |
+ (bool success); |
+ |
+ // Delete a set of cookies matching the passed filter. |
+ // To delete a single cookie, use SetCanonicalCookie with an expiry |
+ // time in the past. |
+ // Returns the number of cookies deleted. |
+ DeleteCookies(CookieDeletionFilter filter) => (uint32 num_deleted); |
+ |
+ // Request a CookieChangeNotification interface over which notification |
+ // for cookie changes can be received. When the specified cookie |
+ // associated with the domain/path specified in the URL changes, a |
+ // notification will be sent to the returned interface. |
+ // |
+ // TODO(rdsmith): Should this 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); |
+ |
+ // 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); |
+}; |