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

Unified Diff: chrome/browser/resources/settings/site_settings/site_data.js

Issue 2451553008: [MD settings] move cookie tree management to cookie tree behavior (Closed)
Patch Set: review changes Created 4 years, 2 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: chrome/browser/resources/settings/site_settings/site_data.js
diff --git a/chrome/browser/resources/settings/site_settings/site_data.js b/chrome/browser/resources/settings/site_settings/site_data.js
index d6505bcde07c80c6b1bb92f770c2358cc8acd52b..6b1934c298d2c425ae18aff7a8740b383b2e3a78 100644
--- a/chrome/browser/resources/settings/site_settings/site_data.js
+++ b/chrome/browser/resources/settings/site_settings/site_data.js
@@ -10,24 +10,10 @@
Polymer({
is: 'site-data',
- behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
+ behaviors: [CookieTreeBehavior],
properties: {
/**
- * A summary list of all sites and how many entities each contain.
- * @type {Array<CookieDataSummaryItem>}
- */
- sites: Array,
-
- /**
- * The cookie tree with the details needed to display individual sites and
- * their contained data.
- * @type {!settings.CookieTreeNode}
- * @private
- */
- treeNodes_: Object,
-
- /**
* The current filter applied to the cookie data list.
* @private
*/
@@ -45,21 +31,7 @@ Polymer({
/** @override */
ready: function() {
- this.addWebUIListener('onTreeItemRemoved',
- this.onTreeItemRemoved_.bind(this));
- this.treeNodes_ = new settings.CookieTreeNode(null);
- // Start the initial request.
- this.reloadCookies_();
- },
-
- /**
- * Reloads the whole cookie list.
- * @private
- */
- reloadCookies_: function() {
- this.browserProxy.reloadCookies().then(function(list) {
- this.loadChildren_(list);
- }.bind(this));
+ this.loadCookies();
},
/**
@@ -96,48 +68,6 @@ Polymer({
return loadTimeData.getString('siteSettingsCookieRemoveAllShown');
},
- /**
- * Called when the cookie list is ready to be shown.
- * @param {!CookieList} list The cookie list to show.
- * @private
- */
- loadChildren_: function(list) {
- var loadChildrenRecurse = function(list) {
- var parentId = list.id;
- var children = list.children;
- var prefix = '';
- if (parentId !== null) {
- this.treeNodes_.populateChildNodes(parentId, this.treeNodes_, children);
- prefix = parentId + ', ';
- }
- var promises = [];
- for (let child of children) {
- if (child.hasChildren) {
- promises.push(this.browserProxy.loadCookieChildren(
- prefix + child.id).then(loadChildrenRecurse.bind(this)));
- }
- }
- return Promise.all(promises);
- }.bind(this);
-
- // New root being added, clear the list and add the nodes.
- this.sites = [];
- this.treeNodes_.addChildNodes(this.treeNodes_, list.children);
- loadChildrenRecurse(list).then(function() {
- this.sites = this.treeNodes_.getSummaryList();
- }.bind(this));
- },
-
- /**
- * Called when a single item has been removed (not during delete all).
- * @param {!CookieRemovePacket} args The details about what to remove.
- * @private
- */
- onTreeItemRemoved_: function(args) {
- this.treeNodes_.removeByParentId(args.id, args.start, args.count);
- this.sites = this.treeNodes_.getSummaryList();
- },
-
/** @private */
onCloseDialog_: function() {
this.$.confirmDeleteDialog.close();
@@ -180,9 +110,7 @@ Polymer({
*/
onDeleteMultipleSites_: function() {
if (this.filterString_.length == 0) {
- this.browserProxy.removeAllCookies().then(function(list) {
- this.loadChildren_(list);
- }.bind(this));
+ this.removeAllCookies();
} else {
var items = this.$.list.items;
for (var i = 0; i < items.length; ++i) {
@@ -201,7 +129,7 @@ Polymer({
dialog.category = this.category;
this.shadowRoot.appendChild(dialog);
- var node = this.treeNodes_.fetchNodeById(event.model.item.id, false);
+ var node = this.rootCookieNode.fetchNodeById(event.model.item.id, false);
dialog.open(node);
dialog.addEventListener('close', function(event) {

Powered by Google App Engine
This is Rietveld 408576698