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

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

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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 24 matching lines...) Expand all
35 // which is in a format slightly different from Set-Cookie and is normally 35 // which is in a format slightly different from Set-Cookie and is normally
36 // only required on the server side. 36 // only required on the server side.
37 37
38 /** 38 /**
39 * @constructor 39 * @constructor
40 * @param {!WebInspector.Target} target 40 * @param {!WebInspector.Target} target
41 */ 41 */
42 WebInspector.CookieParser = function(target) 42 WebInspector.CookieParser = function(target)
43 { 43 {
44 this._target = target; 44 this._target = target;
45 } 45 };
46 46
47 /** 47 /**
48 * @constructor 48 * @constructor
49 * @param {string} key 49 * @param {string} key
50 * @param {string|undefined} value 50 * @param {string|undefined} value
51 * @param {number} position 51 * @param {number} position
52 */ 52 */
53 WebInspector.CookieParser.KeyValue = function(key, value, position) 53 WebInspector.CookieParser.KeyValue = function(key, value, position)
54 { 54 {
55 this.key = key; 55 this.key = key;
56 this.value = value; 56 this.value = value;
57 this.position = position; 57 this.position = position;
58 } 58 };
59 59
60 WebInspector.CookieParser.prototype = { 60 WebInspector.CookieParser.prototype = {
61 /** 61 /**
62 * @return {!Array.<!WebInspector.Cookie>} 62 * @return {!Array.<!WebInspector.Cookie>}
63 */ 63 */
64 cookies: function() 64 cookies: function()
65 { 65 {
66 return this._cookies; 66 return this._cookies;
67 }, 67 },
68 68
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 }; 181 };
182 182
183 /** 183 /**
184 * @param {!WebInspector.Target} target 184 * @param {!WebInspector.Target} target
185 * @param {string|undefined} header 185 * @param {string|undefined} header
186 * @return {?Array.<!WebInspector.Cookie>} 186 * @return {?Array.<!WebInspector.Cookie>}
187 */ 187 */
188 WebInspector.CookieParser.parseCookie = function(target, header) 188 WebInspector.CookieParser.parseCookie = function(target, header)
189 { 189 {
190 return (new WebInspector.CookieParser(target)).parseCookie(header); 190 return (new WebInspector.CookieParser(target)).parseCookie(header);
191 } 191 };
192 192
193 /** 193 /**
194 * @param {!WebInspector.Target} target 194 * @param {!WebInspector.Target} target
195 * @param {string|undefined} header 195 * @param {string|undefined} header
196 * @return {?Array.<!WebInspector.Cookie>} 196 * @return {?Array.<!WebInspector.Cookie>}
197 */ 197 */
198 WebInspector.CookieParser.parseSetCookie = function(target, header) 198 WebInspector.CookieParser.parseSetCookie = function(target, header)
199 { 199 {
200 return (new WebInspector.CookieParser(target)).parseSetCookie(header); 200 return (new WebInspector.CookieParser(target)).parseSetCookie(header);
201 } 201 };
202 202
203 /** 203 /**
204 * @constructor 204 * @constructor
205 * @param {!WebInspector.Target} target 205 * @param {!WebInspector.Target} target
206 * @param {string} name 206 * @param {string} name
207 * @param {string} value 207 * @param {string} value
208 * @param {?WebInspector.Cookie.Type} type 208 * @param {?WebInspector.Cookie.Type} type
209 */ 209 */
210 WebInspector.Cookie = function(target, name, value, type) 210 WebInspector.Cookie = function(target, name, value, type)
211 { 211 {
212 this._target = target; 212 this._target = target;
213 this._name = name; 213 this._name = name;
214 this._value = value; 214 this._value = value;
215 this._type = type; 215 this._type = type;
216 this._attributes = {}; 216 this._attributes = {};
217 } 217 };
218 218
219 WebInspector.Cookie.prototype = { 219 WebInspector.Cookie.prototype = {
220 /** 220 /**
221 * @return {string} 221 * @return {string}
222 */ 222 */
223 name: function() 223 name: function()
224 { 224 {
225 return this._name; 225 return this._name;
226 }, 226 },
227 227
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 this._attributes[key.toLowerCase()] = value; 365 this._attributes[key.toLowerCase()] = value;
366 }, 366 },
367 367
368 /** 368 /**
369 * @param {function(?Protocol.Error)=} callback 369 * @param {function(?Protocol.Error)=} callback
370 */ 370 */
371 remove: function(callback) 371 remove: function(callback)
372 { 372 {
373 this._target.networkAgent().deleteCookie(this.name(), (this.secure() ? " https://" : "http://") + this.domain() + this.path(), callback); 373 this._target.networkAgent().deleteCookie(this.name(), (this.secure() ? " https://" : "http://") + this.domain() + this.path(), callback);
374 } 374 }
375 } 375 };
376 376
377 /** 377 /**
378 * @enum {number} 378 * @enum {number}
379 */ 379 */
380 WebInspector.Cookie.Type = { 380 WebInspector.Cookie.Type = {
381 Request: 0, 381 Request: 0,
382 Response: 1 382 Response: 1
383 }; 383 };
384 384
385 WebInspector.Cookies = {} 385 WebInspector.Cookies = {};
386 386
387 /** 387 /**
388 * @param {function(!Array.<!WebInspector.Cookie>)} callback 388 * @param {function(!Array.<!WebInspector.Cookie>)} callback
389 */ 389 */
390 WebInspector.Cookies.getCookiesAsync = function(callback) 390 WebInspector.Cookies.getCookiesAsync = function(callback)
391 { 391 {
392 var allCookies = []; 392 var allCookies = [];
393 /** 393 /**
394 * @param {!WebInspector.Target} target 394 * @param {!WebInspector.Target} target
395 * @param {?Protocol.Error} error 395 * @param {?Protocol.Error} error
396 * @param {!Array.<!NetworkAgent.Cookie>} cookies 396 * @param {!Array.<!NetworkAgent.Cookie>} cookies
397 */ 397 */
398 function mycallback(target, error, cookies) 398 function mycallback(target, error, cookies)
399 { 399 {
400 if (error) { 400 if (error) {
401 console.error(error); 401 console.error(error);
402 return; 402 return;
403 } 403 }
404 for (var i = 0; i < cookies.length; ++i) 404 for (var i = 0; i < cookies.length; ++i)
405 allCookies.push(WebInspector.Cookies._parseProtocolCookie(target, co okies[i])); 405 allCookies.push(WebInspector.Cookies._parseProtocolCookie(target, co okies[i]));
406 } 406 }
407 407
408 var barrier = new CallbackBarrier(); 408 var barrier = new CallbackBarrier();
409 for (var target of WebInspector.targetManager.targets(WebInspector.Target.Ca pability.Network)) 409 for (var target of WebInspector.targetManager.targets(WebInspector.Target.Ca pability.Network))
410 target.networkAgent().getCookies(barrier.createCallback(mycallback.bind( null, target))); 410 target.networkAgent().getCookies(barrier.createCallback(mycallback.bind( null, target)));
411 barrier.callWhenDone(callback.bind(null, allCookies)); 411 barrier.callWhenDone(callback.bind(null, allCookies));
412 } 412 };
413 413
414 /** 414 /**
415 * @param {!WebInspector.Target} target 415 * @param {!WebInspector.Target} target
416 * @param {!NetworkAgent.Cookie} protocolCookie 416 * @param {!NetworkAgent.Cookie} protocolCookie
417 * @return {!WebInspector.Cookie} 417 * @return {!WebInspector.Cookie}
418 */ 418 */
419 WebInspector.Cookies._parseProtocolCookie = function(target, protocolCookie) 419 WebInspector.Cookies._parseProtocolCookie = function(target, protocolCookie)
420 { 420 {
421 var cookie = new WebInspector.Cookie(target, protocolCookie.name, protocolCo okie.value, null); 421 var cookie = new WebInspector.Cookie(target, protocolCookie.name, protocolCo okie.value, null);
422 cookie.addAttribute("domain", protocolCookie["domain"]); 422 cookie.addAttribute("domain", protocolCookie["domain"]);
423 cookie.addAttribute("path", protocolCookie["path"]); 423 cookie.addAttribute("path", protocolCookie["path"]);
424 cookie.addAttribute("port", protocolCookie["port"]); 424 cookie.addAttribute("port", protocolCookie["port"]);
425 if (protocolCookie["expires"]) 425 if (protocolCookie["expires"])
426 cookie.addAttribute("expires", protocolCookie["expires"]); 426 cookie.addAttribute("expires", protocolCookie["expires"]);
427 if (protocolCookie["httpOnly"]) 427 if (protocolCookie["httpOnly"])
428 cookie.addAttribute("httpOnly"); 428 cookie.addAttribute("httpOnly");
429 if (protocolCookie["secure"]) 429 if (protocolCookie["secure"])
430 cookie.addAttribute("secure"); 430 cookie.addAttribute("secure");
431 if (protocolCookie["sameSite"]) 431 if (protocolCookie["sameSite"])
432 cookie.addAttribute("sameSite", protocolCookie["sameSite"]); 432 cookie.addAttribute("sameSite", protocolCookie["sameSite"]);
433 cookie.setSize(protocolCookie["size"]); 433 cookie.setSize(protocolCookie["size"]);
434 return cookie; 434 return cookie;
435 } 435 };
436 436
437 /** 437 /**
438 * @param {!WebInspector.Cookie} cookie 438 * @param {!WebInspector.Cookie} cookie
439 * @param {string} resourceURL 439 * @param {string} resourceURL
440 * @return {boolean} 440 * @return {boolean}
441 */ 441 */
442 WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL) 442 WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL)
443 { 443 {
444 var url = resourceURL.asParsedURL(); 444 var url = resourceURL.asParsedURL();
445 if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.d omain(), url.host)) 445 if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.d omain(), url.host))
446 return false; 446 return false;
447 return (url.path.startsWith(cookie.path()) 447 return (url.path.startsWith(cookie.path())
448 && (!cookie.port() || url.port === cookie.port()) 448 && (!cookie.port() || url.port === cookie.port())
449 && (!cookie.secure() || url.scheme === "https")); 449 && (!cookie.secure() || url.scheme === "https"));
450 } 450 };
451 451
452 /** 452 /**
453 * @param {string} cookieDomain 453 * @param {string} cookieDomain
454 * @param {string} resourceDomain 454 * @param {string} resourceDomain
455 * @return {boolean} 455 * @return {boolean}
456 */ 456 */
457 WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain) 457 WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain)
458 { 458 {
459 if (cookieDomain.charAt(0) !== ".") 459 if (cookieDomain.charAt(0) !== ".")
460 return resourceDomain === cookieDomain; 460 return resourceDomain === cookieDomain;
461 return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)*" + cookieDomain.sub string(1).escapeForRegExp() + "$", "i")); 461 return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)*" + cookieDomain.sub string(1).escapeForRegExp() + "$", "i"));
462 } 462 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698