1 // Copyright (c) 2012 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 [ 6 { 7 "namespace": "cookies", 8 "description": "Use the <code>chrome.cookies</code> API to query and modify cookies, and to be notified when they change.", 9 "types": [ 10 { 11 "id": "Cookie", 12 "type": "object", 13 "description": "Represents information about an HTTP cookie.", 14 "properties": { 15 "name": {"type": "string", "description": "The name of the cookie."}, 16 "value": {"type": "string", "description": "The value of the cookie."}, 17 "domain": {"type": "string", "description": "The domain of the cookie (e.g. \"www.google.com\", \"example.com\")."}, 18 "hostOnly": {"type": "boolean", "description": "True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie)."}, 19 "path": {"type": "string", "description": "The path of the cookie."}, 20 "secure": {"type": "boolean", "description": "True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS)."}, 21 "httpOnly": {"type": "boolean", "description": "True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts)."}, 22 "session": {"type": "boolean", "description": "True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date."}, 23 "expirationDate": {"type": "number", "optional": true, "description": "The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies."}, 24 "storeId": {"type": "string", "description": "The ID of the cookie store containing this cookie, as provided in getAllCookieStores()."} 25 } 26 }, 27 { 28 "id": "CookieStore", 29 "type": "object", 30 "description": "Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window.", 31 "properties": { 32 "id": {"type": "string", "description": "The unique identifier for the cookie store."}, 33 "tabIds": {"type": "array", "items": {"type": "integer"}, "description": "Identifiers of all the browser tabs that share this cookie store."} 34 } 35 } 36 ], 37 "functions": [ 38 { 39 "name": "get", 40 "type": "function", 41 "description": "Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned.", 42 "parameters": [ 43 { 44 "type": "object", 45 "name": "details", 46 "description": "Details to identify the cookie being retrieved.", 47 "properties": { 48 "url": {"type": "string", "description": "The URL with which the cookie to retrieve is associated. This argument may be a full URL, in which case any data following the URL path (e.g. the query string) is simply ignored. If host permissions for this URL are not specified in the manifest file, the API call will fail."}, 49 "name": {"type": "string", "description": "The name of the cookie to retrieve."}, 50 "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store in which to look for the cookie. By default, the current execution context's cookie store will be used."} 51 } 52 }, 53 { 54 "type": "function", 55 "name": "callback", 56 "parameters": [ 57 { 58 "name": "cookie", "$ref": "Cookie", "optional": true, "description": "Contains details about the cookie. This parameter is null if no such cookie was found." 59 } 60 ] 61 } 62 ] 63 }, 64 { 65 "name": "getAll", 66 "type": "function", 67 "description": "Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first.", 68 "parameters": [ 69 { 70 "type": "object", 71 "name": "details", 72 "description": "Information to filter the cookies being retrieved.", 73 "properties": { 74 "url": {"type": "string", "optional": true, "description": "Restricts the retrieved cookies to those that would match the given URL."}, 75 "name": {"type": "string", "optional": true, "description": "Filters the cookies by name."}, 76 "domain": {"type": "string", "optional": true, "description": "Restricts the retrieved cookies to those whose domains match or are subdomains of this one."}, 77 "path": {"type": "string", "optional": true, "description": "Restricts the retrieved cookies to those whose path exactly matches this string."}, 78 "secure": {"type": "boolean", "optional": true, "description": "Filters the cookies by their Secure property."}, 79 "session": {"type": "boolean", "optional": true, "description": "Filters out session vs. persistent cookies."}, 80 "storeId": {"type": "string", "optional": true, "description": "The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used."} 81 } 82 }, 83 { 84 "type": "function", 85 "name": "callback", 86 "parameters": [ 87 { 88 "name": "cookies", "type": "array", "items": {"$ref": "Cookie"}, "description": "All the existing, unexpired cookies that match the given cookie info." 89 } 90 ] 91 } 92 ] 93 }, 94 { 95 "name": "set", 96 "type": "function", 97 "description": "Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.", 98 "parameters": [ 99 { 100 "type": "object", 101 "name": "details", 102 "description": "Details about the cookie being set.", 103 "properties": { 104 "url": {"type": "string", "description": "The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail."}, 105 "name": {"type": "string", "optional": true, "description": "The name of the cookie. Empty by default if omitted."}, 106 "value": {"type": "string", "optional": true, "description": "The value of the cookie. Empty by default if omitted."}, 107 "domain": {"type": "string", "optional": true, "description": "The domain of the cookie. If omitted, the cookie becomes a host-only cookie."}, 108 "path": {"type": "string", "optional": true, "description": "The path of the cookie. Defaults to the path portion of the url parameter."}, 109 "secure": {"type": "boolean", "optional": true, "description": "Whether the cookie should be marked as Secure. Defaults to false."}, 110 "httpOnly": {"type": "boolean", "optional": true, "description": "Whether the cookie should be marked as HttpOnly. Defaults to false."}, 111 "expirationDate": {"type": "number", "optional": true, "description": "The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie."}, 112 "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store."} 113 } 114 }, 115 { 116 "type": "function", 117 "name": "callback", 118 "optional": true, 119 "min_version": "11.0.674.0", 120 "parameters": [ 121 { 122 "name": "cookie", "$ref": "Cookie", "optional": true, "description": "Contains details about the cookie that's been set. If setting failed for any reason, this will be \"null\", and \"chrome.runtime.lastError\" will be set." 123 } 124 ] 125 } 126 ] 127 }, 128 { 129 "name": "remove", 130 "type": "function", 131 "description": "Deletes a cookie by name.", 132 "parameters": [ 133 { 134 "type": "object", 135 "name": "details", 136 "description": "Information to identify the cookie to remove.", 137 "properties": { 138 "url": {"type": "string", "description": "The URL associated with the cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail."}, 139 "name": {"type": "string", "description": "The name of the cookie to remove."}, 140 "storeId": {"type": "string", "optional": true, "description": "The ID of the cookie store to look in for the cookie. If unspecified, the cookie is looked for by default in the current execution context's cookie store."} 141 } 142 }, 143 { 144 "type": "function", 145 "name": "callback", 146 "optional": true, 147 "min_version": "11.0.674.0", 148 "parameters": [ 149 { 150 "name": "details", 151 "type": "object", 152 "description": "Contains details about the cookie that's been removed. If removal failed for any reason, this will be \"null\", and \"chrome.runtime.lastError\" will be set.", 153 "optional": true, 154 "properties": { 155 "url": {"type": "string", "description": "The URL associated with the cookie that's been removed."}, 156 "name": {"type": "string", "description": "The name of the cookie that's been removed."}, 157 "storeId": {"type": "string", "description": "The ID of the cookie store from which the cookie was removed."} 158 } 159 } 160 ] 161 } 162 ] 163 }, 164 { 165 "name": "getAllCookieStores", 166 "type": "function", 167 "description": "Lists all existing cookie stores.", 168 "parameters": [ 169 { 170 "type": "function", 171 "name": "callback", 172 "parameters": [ 173 { 174 "name": "cookieStores", "type": "array", "items": {"$ref": "CookieStore"}, "description": "All the existing cookie stores." 175 } 176 ] 177 } 178 ] 179 } 180 ], 181 "events": [ 182 { 183 "name": "onChanged", 184 "type": "function", 185 "description": "Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with \"cause\" of \"overwrite\" . Afterwards, a new cookie is written with the updated values, generating a second notification with \"cause\" \"explicit\".", 186 "parameters": [ 187 { 188 "type": "object", 189 "name": "changeInfo", 190 "properties": { 191 "removed": {"type": "boolean", "description": "True if a cookie was removed."}, 192 "cookie": {"$ref": "Cookie", "description": "Information about the cookie that was set or removed."}, 193 "cause": {"min_version": "12.0.707.0", "type": "string", "enum": ["evicted", "expired", "explicit", "expired_overwrite", "overwrite"], "description": "The underlying reason behind the cookie's change. If a cookie was inserted, or removed via an explicit call to \"chrome.cookies.remove\", \"cause\" will be \"explicit\". If a cookie was automatically removed due to expiry, \"cause\" will be \"expired\". If a cookie was removed due to being overwritten with an already-expired expiration date, \"cause\" will be set to \"expired_overwrite\". If a cookie was automatically removed due to garbage collection, \"cause\" will be \"evicted\". If a cookie was automatically removed due to a \"set\" call that overwrote it, \"cause\" will be \"overwrite\". Plan your response accordingly."} 194 } 195 } 196 ] 197 } 198 ] 199 } 200 ] 201