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

Unified Diff: third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js

Issue 2623063003: DevTools: Fix getCookies to report for all resources (Closed)
Patch Set: audit and line length fixes 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js b/third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js
index 74b1d1141472261a12a81f48b0941f407d3b4825..2643ea2caee955fef24c6ee14188cbed60d1c39c 100644
--- a/third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js
+++ b/third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js
@@ -31,7 +31,7 @@
* @unrestricted
*/
Resources.CookieItemsView = class extends UI.SimpleView {
- constructor(treeElement, cookieDomain) {
+ constructor(treeElement, target, cookieDomain) {
super(Common.UIString('Cookies'));
this.element.classList.add('storage-view');
@@ -53,6 +53,7 @@ Resources.CookieItemsView = class extends UI.SimpleView {
this._filterSeparator = new UI.ToolbarSeparator();
this._filterButton = this._filterBar.filterButton();
+ this._target = target;
this._treeElement = treeElement;
this._cookieDomain = cookieDomain;
@@ -98,14 +99,24 @@ Resources.CookieItemsView = class extends UI.SimpleView {
}
_update() {
- SDK.Cookies.getCookiesAsync(this._updateWithCookies.bind(this));
+ var resourceURLs = [];
+ var cookieDomain = this._cookieDomain;
+ function populateResourceURLs(resource) {
pfeldman 2017/01/13 02:17:34 You should annotate all function parameters for co
phulce 2017/01/18 00:52:34 Done.
+ var url = resource.documentURL.asParsedURL();
+ if (url && url.securityOrigin() === cookieDomain)
+ resourceURLs.push(resource.url);
+ }
+
+ SDK.ResourceTreeModel.fromTarget(this._target).forAllResources(populateResourceURLs);
+ SDK.Cookies.getCookiesAsync(this._target, resourceURLs, this._updateWithCookies.bind(this));
}
/**
* @param {!Array.<!SDK.Cookie>} allCookies
*/
_updateWithCookies(allCookies) {
- this._cookies = this._filterCookiesForDomain(allCookies);
+ this._cookies = allCookies;
+ this._totalSize = allCookies.reduce((size, cookie) => size + cookie.size(), 0);
pfeldman 2017/01/13 02:17:34 Not sure why total size would matter :)
phulce 2017/01/18 00:52:34 it's pre-existing, used for display
if (!this._cookies.length) {
// Nothing to show.
@@ -123,7 +134,7 @@ Resources.CookieItemsView = class extends UI.SimpleView {
new CookieTable.CookiesTable(false, this._update.bind(this), this._enableDeleteButton.bind(this));
}
- var shownCookies = this._filterCookiesForFilters(this._cookies);
+ var shownCookies = this._filterCookies(this._cookies);
this._cookiesTable.setCookies(shownCookies);
this._emptyWidget.detach();
this._cookiesTable.show(this.element);
@@ -138,7 +149,7 @@ Resources.CookieItemsView = class extends UI.SimpleView {
/**
* @param {!Array.<!SDK.Cookie>} cookies
*/
- _filterCookiesForFilters(cookies) {
+ _filterCookies(cookies) {
if (!this._filterRegex)
return cookies;
@@ -148,41 +159,6 @@ Resources.CookieItemsView = class extends UI.SimpleView {
});
}
- /**
- * @param {!Array.<!SDK.Cookie>} allCookies
- */
- _filterCookiesForDomain(allCookies) {
- var cookies = [];
- var resourceURLsForDocumentURL = [];
- this._totalSize = 0;
-
- /**
- * @this {Resources.CookieItemsView}
- */
- function populateResourcesForDocuments(resource) {
- var url = resource.documentURL.asParsedURL();
- if (url && url.securityOrigin() === this._cookieDomain)
- resourceURLsForDocumentURL.push(resource.url);
- }
- Bindings.forAllResources(populateResourcesForDocuments.bind(this));
-
- for (var i = 0; i < allCookies.length; ++i) {
- var pushed = false;
- var size = allCookies[i].size();
- for (var j = 0; j < resourceURLsForDocumentURL.length; ++j) {
- var resourceURL = resourceURLsForDocumentURL[j];
- if (SDK.Cookies.cookieMatchesResourceURL(allCookies[i], resourceURL)) {
- this._totalSize += size;
- if (!pushed) {
- pushed = true;
- cookies.push(allCookies[i]);
- }
- }
- }
- }
- return cookies;
- }
-
clear() {
this._cookiesTable.clear();
this._update();

Powered by Google App Engine
This is Rietveld 408576698