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

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

Issue 2623063003: DevTools: Fix getCookies to report for all resources (Closed)
Patch Set: rebase master Created 3 years, 11 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 | « third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 * @enum {number} 358 * @enum {number}
359 */ 359 */
360 SDK.Cookie.Type = { 360 SDK.Cookie.Type = {
361 Request: 0, 361 Request: 0,
362 Response: 1 362 Response: 1
363 }; 363 };
364 364
365 SDK.Cookies = {}; 365 SDK.Cookies = {};
366 366
367 /** 367 /**
368 * @param {!SDK.Target} target
369 * @param {!Array.<string>} urls
368 * @param {function(!Array.<!SDK.Cookie>)} callback 370 * @param {function(!Array.<!SDK.Cookie>)} callback
369 */ 371 */
370 SDK.Cookies.getCookiesAsync = function(callback) { 372 SDK.Cookies.getCookiesAsync = function(target, urls, callback) {
371 var allCookies = []; 373 target.networkAgent().getCookies(urls, (err, cookies) => {
372 /** 374 if (err) {
373 * @param {!SDK.Target} target 375 console.error(err);
374 * @param {?Protocol.Error} error 376 return callback([]);
375 * @param {!Array.<!Protocol.Network.Cookie>} cookies
376 */
377 function mycallback(target, error, cookies) {
378 if (error) {
379 console.error(error);
380 return;
381 } 377 }
382 for (var i = 0; i < cookies.length; ++i)
383 allCookies.push(SDK.Cookies._parseProtocolCookie(target, cookies[i]));
384 }
385 378
386 var barrier = new CallbackBarrier(); 379 callback(cookies.map(cookie => SDK.Cookies._parseProtocolCookie(target, cook ie)));
387 for (var target of SDK.targetManager.targets(SDK.Target.Capability.Network)) 380 });
388 target.networkAgent().getCookies(barrier.createCallback(mycallback.bind(null , target)));
389 barrier.callWhenDone(callback.bind(null, allCookies));
390 }; 381 };
391 382
392 /** 383 /**
393 * @param {!SDK.Target} target 384 * @param {!SDK.Target} target
394 * @param {!Protocol.Network.Cookie} protocolCookie 385 * @param {!Protocol.Network.Cookie} protocolCookie
395 * @return {!SDK.Cookie} 386 * @return {!SDK.Cookie}
396 */ 387 */
397 SDK.Cookies._parseProtocolCookie = function(target, protocolCookie) { 388 SDK.Cookies._parseProtocolCookie = function(target, protocolCookie) {
398 var cookie = new SDK.Cookie(target, protocolCookie.name, protocolCookie.value, null); 389 var cookie = new SDK.Cookie(target, protocolCookie.name, protocolCookie.value, null);
399 cookie.addAttribute('domain', protocolCookie['domain']); 390 cookie.addAttribute('domain', protocolCookie['domain']);
(...skipping 28 matching lines...) Expand all
428 /** 419 /**
429 * @param {string} cookieDomain 420 * @param {string} cookieDomain
430 * @param {string} resourceDomain 421 * @param {string} resourceDomain
431 * @return {boolean} 422 * @return {boolean}
432 */ 423 */
433 SDK.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceD omain) { 424 SDK.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceD omain) {
434 if (cookieDomain.charAt(0) !== '.') 425 if (cookieDomain.charAt(0) !== '.')
435 return resourceDomain === cookieDomain; 426 return resourceDomain === cookieDomain;
436 return !!resourceDomain.match(new RegExp('^([^\\.]+\\.)*' + cookieDomain.subst ring(1).escapeForRegExp() + '$', 'i')); 427 return !!resourceDomain.match(new RegExp('^([^\\.]+\\.)*' + cookieDomain.subst ring(1).escapeForRegExp() + '$', 'i'));
437 }; 428 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698