OLD | NEW |
---|---|
(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 // TODO(rdsmith): Comment. | |
11 | |
12 enum CookiePriority { | |
13 LOW, | |
14 MEDIUM, | |
15 HIGH | |
16 }; | |
17 | |
18 // TODO(rdsmith): Are both of these really needed? | |
19 | |
20 enum CookieSameSite { | |
21 NO_RESTRICTION, | |
22 LAX_MODE, | |
23 STRICT_MODE | |
24 }; | |
25 | |
26 enum CookieSameSiteFilter { | |
27 INCLUDE_STRICT_AND_LAX, | |
28 INCLUDE_LAX, | |
29 DO_NOT_INCLUDE | |
30 }; | |
31 | |
32 struct CookieOptions { | |
33 // TOOD(rdsmith): Defaults from constructor or wrapping function? | |
yzshen1
2017/06/20 18:33:17
The default values are set by the constructor.
(Pl
| |
34 bool exclude_httponly = true; | |
35 CookieSameSiteFilter cookie_same_site_filter = DO_NOT_INCLUDE; | |
36 bool update_access_time = true; | |
37 mojo.common.mojom.Time? server_time; | |
38 }; | |
39 | |
40 struct CanonicalCookie { | |
41 string name; | |
42 string value; | |
43 string domain; | |
44 string path; | |
45 mojo.common.mojom.Time creation; | |
46 mojo.common.mojom.Time expiry; | |
47 mojo.common.mojom.Time last_access; | |
48 bool secure = true; | |
49 bool httponly = false; | |
50 CookieSameSite site_restrictions = NO_RESTRICTION; | |
51 CookiePriority priority = MEDIUM; | |
52 }; | |
53 | |
54 enum CookieChangeCause { | |
55 // The cookie was inserted. | |
56 INSERTED, | |
57 // The cookie was changed directly by a consumer's action. | |
58 EXPLICIT, | |
59 // The cookie was deleted, but no more details are known. | |
60 UNKNOWN_DELETION, | |
61 // The cookie was automatically removed due to an insert operation that | |
62 // overwrote it. | |
63 OVERWRITE, | |
64 // The cookie was automatically removed as it expired. | |
65 EXPIRED, | |
66 // The cookie was automatically evicted during garbage collection. | |
67 EVICTED, | |
68 // The cookie was overwritten with an already-expired expiration date. | |
69 EXPIRED_OVERWRITE | |
70 }; | |
71 | |
72 enum CookieDeletionSessionControl { | |
73 IGNORE, | |
74 SESSION, | |
75 PERSISTENT, | |
76 }; | |
77 | |
78 // All active filters are ANDed together. I.e. if | |
79 // |delete_created_after && delete_blacklist| only cookies in the blacklist | |
80 // that have been created after the specified date would be deleted. | |
81 // 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
| |
82 // all cookies will be deleted; this can be thought of as there being a | |
83 // default "match everything" filter which is ANDed in with all other filters. | |
84 struct CookieDeletionFilter { | |
85 // Delete cookies created after a date. | |
86 mojo.common.mojom.Time? created_after_time; | |
87 | |
88 // Delete cookies created before a date. | |
89 mojo.common.mojom.Time? created_before_time; | |
90 | |
91 // Delete cookies whose domains are in the blacklist. | |
92 array<string>? domain_blacklist; | |
93 | |
94 // Delete cookies whose domains are in the whitelist. | |
95 array<string>? domain_whitelist; | |
yzshen1
2017/06/20 18:33:17
I am a little confused: do you mean *not* deleting
| |
96 | |
97 // Delete session/persistent cookies. | |
98 CookieDeletionSessionControl session_control = IGNORE; | |
99 }; | |
100 | |
101 interface CookieChangeNotification { | |
102 // TODO(rdsmith): Should this be made a batch interface? | |
103 OnCookieChanged(CanonicalCookie cookie, CookieChangeCause cause); | |
104 }; | |
105 | |
106 interface CookieService { | |
107 // Get all the cookies known to the service. | |
108 GetAllCookies() => (array<CanonicalCookie> cookies); | |
109 | |
110 // Get all cookies for the specified URL and cookie options. | |
111 GetCookieList(url.mojom.Url url, CookieOptions cookie_options) => | |
112 (array<CanonicalCookie> cookies); | |
113 | |
114 // Set a cookie. |secure_source| indicates whether existing secure | |
115 // cookies can be overwritten (secure cookies may be created from a | |
116 // non-secure source). |modify_http_only| indicates whether http_only | |
117 // cookies may be overwritten. | |
118 // TODO(rdsmith): Might it make sense to base modify_http_only on the | |
119 // http_only element of the CanonicalCookie? | |
120 SetCanonicalCookie( | |
121 CanonicalCookie cookie, bool secure_source, bool modify_http_only) => | |
122 (bool success); | |
123 | |
124 // Delete a set of cookies matching the passed filter. | |
125 // Returns the number of cookies deleted. | |
126 DeleteCookies(CookieDeletionFilter filter) => (int32 num_deleted); | |
yzshen1
2017/06/20 18:33:17
nit: the result could be an unsigned number, say,
| |
127 | |
128 // Register an interace to receive notification when the specified cookie | |
129 // associated with the domain/path specified in the URL change. | |
130 // TODO(rdsmith): I feel like this neeeds to have a filter to | |
131 // register for a lot of notifications at once. Maybe combine with | |
132 // the deletion filter? | |
133 RequestNotification( | |
134 url.mojom.Url url, | |
135 string name, | |
136 CookieChangeNotification& notification_interface) => (); | |
yzshen1
2017/06/20 18:33:17
nit: please comment on why an empty callback is ne
| |
137 | |
138 // Clone the interface for use somewhere else. After this call, | |
139 // requests to the same implementation may be posted to the other side | |
140 // of the pipe new_interface was configured on. | |
141 CloneInterface(CookieService& new_interface); | |
142 }; | |
OLD | NEW |