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

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_data_details_dialog.js

Issue 2451553008: [MD settings] move cookie tree management to cookie tree behavior (Closed)
Patch Set: review changes 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'site-data-details-dialog' provides a dialog to show details of site data 7 * 'site-data-details-dialog' provides a dialog to show details of site data
8 * stored by a given site. 8 * stored by a given site.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (dialog.open) 71 if (dialog.open)
72 dialog.close(); 72 dialog.close();
73 }, 73 },
74 74
75 /** 75 /**
76 * Populates the dialog with the data about the site. 76 * Populates the dialog with the data about the site.
77 * @private 77 * @private
78 */ 78 */
79 populateDialog_: function() { 79 populateDialog_: function() {
80 this.title_ = loadTimeData.getStringF('siteSettingsCookieDialog', 80 this.title_ = loadTimeData.getStringF('siteSettingsCookieDialog',
81 this.site_.data_.title); 81 this.site_.data.title);
82 82
83 this.entries_ = this.site_.getCookieList(); 83 this.entries_ = this.site_.getCookieList();
84 if (this.entries_.length < 2) { 84 if (this.entries_.length < 2) {
85 // When there's only one item to show, hide the picker and change the 85 // When there's only one item to show, hide the picker and change the
86 // 'Remove All' button to read 'Remove' instead. 86 // 'Remove All' button to read 'Remove' instead.
87 this.$.container.hidden = true; 87 this.$.container.hidden = true;
88 this.$.clear.textContent = 88 this.$.clear.textContent =
89 loadTimeData.getString('siteSettingsCookieRemove'); 89 loadTimeData.getString('siteSettingsCookieRemove');
90 } else { 90 } else {
91 this.$.picker.value = this.entries_[0].id; 91 this.$.picker.value = this.entries_[0].id;
92 this.lastSelectedIndex_ = 0; 92 this.lastSelectedIndex_ = 0;
93 } 93 }
94 94
95 this.populateItem_(this.entries_[0].id, this.site_); 95 this.populateItem_(this.entries_[0].id, this.site_);
96 }, 96 },
97 97
98 /** 98 /**
99 * Recursively look up a node path for a leaf node with a given id. 99 * Recursively look up a node path for a leaf node with a given id.
100 * @param {!settings.CookieTreeNode} node The node to start with. 100 * @param {!settings.CookieTreeNode} node The node to start with.
101 * @param {string} currentPath The path constructed so far. 101 * @param {string} currentPath The path constructed so far.
102 * @param {string} targetId The id of the target leaf node to look for. 102 * @param {string} targetId The id of the target leaf node to look for.
103 * @return {string} The path of the node returned (or blank if not found). 103 * @return {string} The path of the node returned (or blank if not found).
104 * @private 104 * @private
105 */ 105 */
106 nodePath_: function(node, currentPath, targetId) { 106 nodePath_: function(node, currentPath, targetId) {
107 if (node.data_.id == targetId) 107 if (node.data.id == targetId)
108 return currentPath; 108 return currentPath;
109 109
110 for (var i = 0; i < node.children_.length; ++i) { 110 for (var i = 0; i < node.children_.length; ++i) {
111 var child = node.children_[i]; 111 var child = node.children_[i];
112 var path = this.nodePath_( 112 var path = this.nodePath_(
113 child, currentPath + ',' + child.data_.id, targetId); 113 child, currentPath + ',' + child.data.id, targetId);
114 if (path.length > 0) 114 if (path.length > 0)
115 return path; 115 return path;
116 } 116 }
117 117
118 return ''; 118 return '';
119 }, 119 },
120 120
121 /** 121 /**
122 * Add the cookie data to the content section of this dialog. 122 * Add the cookie data to the content section of this dialog.
123 * @param {string} id The id of the cookie node to display. 123 * @param {string} id The id of the cookie node to display.
124 * @param {!settings.CookieTreeNode} site The current site. 124 * @param {!settings.CookieTreeNode} site The current site.
125 * @private 125 * @private
126 */ 126 */
127 populateItem_: function(id, site) { 127 populateItem_: function(id, site) {
128 var node = site.fetchNodeById(id, true); 128 var node = site.fetchNodeById(id, true);
129 if (node) 129 if (node)
130 this.cookieNodes_ = site.getCookieData(node); 130 this.cookieNodes_ = getCookieData(node.data);
131 }, 131 },
132 132
133 /** 133 /**
134 * Called when a single item has been removed. 134 * Called when a single item has been removed.
135 * @param {!CookieRemovePacket} args The details about what to remove. 135 * @param {!CookieRemovePacket} args The details about what to remove.
136 * @private 136 * @private
137 */ 137 */
138 onTreeItemRemoved_: function(args) { 138 onTreeItemRemoved_: function(args) {
139 this.entries_ = this.site_.getCookieList(); 139 this.entries_ = this.site_.getCookieList();
140 if (this.site_.children_.length == 0 || this.entries_.length == 0) { 140 if (this.site_.children_.length == 0 || this.entries_.length == 0) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 return getCookieDataCategoryText(item.data.type, item.data.totalUsage); 177 return getCookieDataCategoryText(item.data.type, item.data.totalUsage);
178 }, 178 },
179 179
180 /** 180 /**
181 * A handler for when the user opts to remove a single cookie. 181 * A handler for when the user opts to remove a single cookie.
182 * @private 182 * @private
183 */ 183 */
184 onRemove_: function(event) { 184 onRemove_: function(event) {
185 this.browserProxy.removeCookie(this.nodePath_( 185 this.browserProxy.removeCookie(this.nodePath_(
186 this.site_, this.site_.data_.id, this.$.picker.value)); 186 this.site_, this.site_.data.id, this.$.picker.value));
187 }, 187 },
188 188
189 /** 189 /**
190 * A handler for when the user opts to remove all cookies. 190 * A handler for when the user opts to remove all cookies.
191 * @private 191 * @private
192 */ 192 */
193 onRemoveAll_: function(event) { 193 onRemoveAll_: function(event) {
194 cr.removeWebUIListener(this.listener_); 194 cr.removeWebUIListener(this.listener_);
195 this.browserProxy.removeCookie(this.site_.data_.id); 195 this.browserProxy.removeCookie(this.site_.data.id);
196 this.close(); 196 this.close();
197 }, 197 },
198 198
199 /** @private */ 199 /** @private */
200 onCancelTap_: function() { 200 onCancelTap_: function() {
201 this.$.dialog.cancel(); 201 this.$.dialog.cancel();
202 }, 202 },
203 }); 203 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698