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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js

Issue 2567873002: DevTools: Add ability to add and edit cookies (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 244
245 /** 245 /**
246 * @return {boolean} 246 * @return {boolean}
247 */ 247 */
248 secure() { 248 secure() {
249 return 'secure' in this._attributes; 249 return 'secure' in this._attributes;
250 } 250 }
251 251
252 /** 252 /**
253 * @return {string} 253 * @return {!Protocol.Network.CookieSameSite<string>}
254 */ 254 */
255 sameSite() { 255 sameSite() {
256 return this._attributes['samesite']; 256 return this._attributes['samesite'];
257 } 257 }
258 258
259 /** 259 /**
260 * @return {boolean} 260 * @return {boolean}
261 */ 261 */
262 session() { 262 session() {
263 // RFC 2965 suggests using Discard attribute to mark session cookies, but th is does not seem to be widely used. 263 // RFC 2965 suggests using Discard attribute to mark session cookies, but th is does not seem to be widely used.
(...skipping 16 matching lines...) Expand all
280 } 280 }
281 281
282 /** 282 /**
283 * @return {string} 283 * @return {string}
284 */ 284 */
285 domain() { 285 domain() {
286 return this._attributes['domain']; 286 return this._attributes['domain'];
287 } 287 }
288 288
289 /** 289 /**
290 * @return {string} 290 * @return {number}
291 */ 291 */
292 expires() { 292 expires() {
293 return this._attributes['expires']; 293 return this._attributes['expires'];
294 } 294 }
295 295
296 /** 296 /**
297 * @return {string} 297 * @return {string}
298 */ 298 */
299 maxAge() { 299 maxAge() {
300 return this._attributes['max-age']; 300 return this._attributes['max-age'];
301 } 301 }
302 302
303 /** 303 /**
304 * @return {number} 304 * @return {number}
305 */ 305 */
306 size() { 306 size() {
307 return this._size; 307 return this._size;
308 } 308 }
309 309
310 url() {
311 return (this.secure() ? 'https://' : 'http://') + this.domain() + this.path( );
312 }
313
310 /** 314 /**
311 * @param {number} size 315 * @param {number} size
312 */ 316 */
313 setSize(size) { 317 setSize(size) {
314 this._size = size; 318 this._size = size;
315 } 319 }
316 320
317 /** 321 /**
318 * @return {?Date} 322 * @return {?Date}
319 */ 323 */
(...skipping 12 matching lines...) Expand all
332 336
333 /** 337 /**
334 * @return {!Object} 338 * @return {!Object}
335 */ 339 */
336 attributes() { 340 attributes() {
337 return this._attributes; 341 return this._attributes;
338 } 342 }
339 343
340 /** 344 /**
341 * @param {string} key 345 * @param {string} key
342 * @param {string=} value 346 * @param {string|number=} value
343 */ 347 */
344 addAttribute(key, value) { 348 addAttribute(key, value) {
345 this._attributes[key.toLowerCase()] = value; 349 this._attributes[key.toLowerCase()] = value;
346 } 350 }
347 351
348 /** 352 /**
349 * @param {function(?Protocol.Error)=} callback 353 * @param {function(?Protocol.Error)=} callback
350 */ 354 */
351 remove(callback) { 355 remove(callback) {
352 this._target.networkAgent().deleteCookie( 356 this._target.networkAgent().deleteCookie(this.name(), this.url(), callback);
353 this.name(), (this.secure() ? 'https://' : 'http://') + this.domain() + this.path(), callback); 357 }
358
359 /**
360 * @param {function(?Protocol.Error)=} callback
361 */
362 save(callback) {
363 var domain = this.domain();
364 // for cookies targeting single domain and no sub domains 'domain' field sho uld be sent empty
365 if (!domain.startsWith('.'))
kdzwinel 2016/12/11 22:07:07 @allada:
366 domain = '';
367 this._target.networkAgent().setCookie(this.url(), this.name(), this.value(), domain, this.path(), this.secure(),
368 this.httpOnly(), this.sameSite(), this.expires(), callback);
354 } 369 }
355 }; 370 };
356 371
357 /** 372 /**
358 * @enum {number} 373 * @enum {number}
359 */ 374 */
360 SDK.Cookie.Type = { 375 SDK.Cookie.Type = {
361 Request: 0, 376 Request: 0,
362 Response: 1 377 Response: 1
363 }; 378 };
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 /** 445 /**
431 * @param {string} cookieDomain 446 * @param {string} cookieDomain
432 * @param {string} resourceDomain 447 * @param {string} resourceDomain
433 * @return {boolean} 448 * @return {boolean}
434 */ 449 */
435 SDK.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceD omain) { 450 SDK.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceD omain) {
436 if (cookieDomain.charAt(0) !== '.') 451 if (cookieDomain.charAt(0) !== '.')
437 return resourceDomain === cookieDomain; 452 return resourceDomain === cookieDomain;
438 return !!resourceDomain.match(new RegExp('^([^\\.]+\\.)*' + cookieDomain.subst ring(1).escapeForRegExp() + '$', 'i')); 453 return !!resourceDomain.match(new RegExp('^([^\\.]+\\.)*' + cookieDomain.subst ring(1).escapeForRegExp() + '$', 'i'));
439 }; 454 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698