Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: content/common/cookie.mojom

Issue 2908443002: Initial implementation of Cookie service.
Patch Set: Partially written test. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/cookie.typemap » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 module content.mojom;
6
7 import "mojo/common/time.mojom";
8 import "url/mojo/url.mojom";
9
10 enum CookiePriority {
11 LOW,
12 MEDIUM,
13 HIGH
14 };
15
16 // TODO(rdsmith): Document, if only by reference.
17 enum CookieSameSite {
18 NO_RESTRICTION,
19 LAX_MODE,
20 STRICT_MODE
21 };
22
23 enum CookieSameSiteFilter {
24 INCLUDE_STRICT_AND_LAX,
25 INCLUDE_LAX,
26 DO_NOT_INCLUDE
27 };
28
29 // Keep defaults here in sync with net/cookies/cookie_options.cc.
30 struct CookieOptions {
31 bool exclude_httponly = true;
32 CookieSameSiteFilter cookie_same_site_filter = DO_NOT_INCLUDE;
33 bool update_access_time = true;
34 mojo.common.mojom.Time? server_time;
35 };
36
37 // See net/cookies/canonical_cookie.{h,cc} for documentation.
38 // Keep defaults here in sync with those files.
39 struct CanonicalCookie {
40 string name;
41 string value;
42 string domain;
43 string path;
44 mojo.common.mojom.Time? creation;
45 mojo.common.mojom.Time? expiry;
46 mojo.common.mojom.Time? last_access;
47 bool secure = true;
48 bool httponly = false;
49 CookieSameSite site_restrictions = NO_RESTRICTION;
50 CookiePriority priority = MEDIUM;
51 };
52
53 // Keep values here in sync with net::CookieStore::ChangeCause.
54 // (Not typemapped to avoid forcing clients to know about net::CookieStore.)
55 enum CookieChangeCause {
56 // The cookie was inserted.
57 INSERTED,
58 // The cookie was changed directly by a consumer's action.
59 EXPLICIT,
60 // The cookie was deleted, but no more details are known.
61 UNKNOWN_DELETION,
62 // The cookie was automatically removed due to an insert operation that
63 // overwrote it.
64 OVERWRITE,
65 // The cookie was automatically removed as it expired.
66 EXPIRED,
67 // The cookie was automatically evicted during garbage collection.
68 EVICTED,
69 // The cookie was overwritten with an already-expired expiration date.
70 EXPIRED_OVERWRITE
71 };
72
73 // Session cookies are cookies that expire at the end of the browser session.
74 // That is represented in canonical cookies by a null expiry time.
75 enum CookieDeletionSessionControl {
76 IGNORE,
77 SESSION,
78 PERSISTENT,
79 };
80
81 // All existing filters are ANDed together. I.e. if there is a value
82 // for created_after_time and there's a value for domain_blacklist,
83 // only cookies in the blacklist that have been created after the
84 // specified date would be deleted. A value for
85 // session_control of IGNORE is treated the same as optional values not
86 // being present for the other filters.
87 // Note that a whitelist should be considered a deletion filter for everything
88 // that doesn't match the whitelist; i.e. a whitelist + a created_after_time
89 // will only delete cookies that *aren't* in the whitelist AND *are* created
90 // after the specified time.
91 // If no filters are specified then all cookies will be deleted; this can be
92 // thought of as there being a default "match everything" filter which
93 // is ANDed in with all other filters.
94 struct CookieDeletionFilter {
95 // Delete cookies created after a date.
96 mojo.common.mojom.Time? created_after_time;
97
98 // Delete cookies created before a date.
99 mojo.common.mojom.Time? created_before_time;
100
101 // Delete cookies whose domains are in the blacklist.
102 array<string>? domain_blacklist;
103
104 // Deletes cookies whose domains are not in the whitelist.
105 array<string>? domain_whitelist;
106
107 // Delete session/persistent cookies.
108 CookieDeletionSessionControl session_control = IGNORE;
109 };
110
111 interface CookieChangeNotification {
112 // TODO(rdsmith): Should this be made a batch interface?
113 OnCookieChanged(CanonicalCookie cookie, CookieChangeCause cause);
114 };
115
116 interface CookieService {
117 // TODO(rdsmith): Worthwhile specifying a sort order for the getters?
118
119 // Get all the cookies known to the service.
120 GetAllCookies() => (array<CanonicalCookie> cookies);
121
122 // Get all cookies for the specified URL and cookie options.
123 GetCookieList(url.mojom.Url url, CookieOptions cookie_options) =>
124 (array<CanonicalCookie> cookies);
125
126 // Set a cookie. |secure_source| indicates whether existing secure
127 // cookies can be overwritten (secure cookies may be created from a
128 // non-secure source). |modify_http_only| indicates whether http_only
129 // cookies may be overwritten.
130 SetCanonicalCookie(
131 CanonicalCookie cookie, bool secure_source, bool modify_http_only) =>
132 (bool success);
133
134 // Delete a set of cookies matching the passed filter.
135 // To delete a single cookie, use SetCanonicalCookie with an expiry
136 // time in the past.
137 // Returns the number of cookies deleted.
138 DeleteCookies(CookieDeletionFilter filter) => (uint32 num_deleted);
139
140 // Request a CookieChangeNotification interface over which notification
141 // for cookie changes can be received. When the specified cookie
142 // associated with the domain/path specified in the URL changes, a
143 // notification will be sent to the returned interface.
144 //
145 // TODO(rdsmith): Should this have a filter to register for a lot of
146 // notifications at once? Maybe combine with the deletion filter?
147 RequestNotification(
148 url.mojom.Url url,
149 string name) => (CookieChangeNotification& notification_interface);
150
151 // Clone the interface for use somewhere else. After this call,
152 // requests to the same implementation may be posted to the other side
153 // of the pipe new_interface was configured on.
154 CloneInterface(CookieService& new_interface);
155 };
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/cookie.typemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698