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

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

Issue 2686063004: MD Settings: make blowing away per-origin data (i.e. cookies) easier (Closed)
Patch Set: dschuyler@ review Created 3 years, 10 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
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' handles showing the local storage summary list for all sites. 7 * 'site-data' handles showing the local storage summary list for all sites.
8 */ 8 */
9 9
10 /**
11 * TODO(dbeam): upstream to polymer externs?
12 * @constructor
13 * @extends {Event}
14 */
15 function DomRepeatEvent() {}
16
17 /** @type {?} */
18 DomRepeatEvent.prototype.model;
19
10 Polymer({ 20 Polymer({
11 is: 'site-data', 21 is: 'site-data',
12 22
13 behaviors: [CookieTreeBehavior], 23 behaviors: [CookieTreeBehavior],
14 24
15 properties: { 25 properties: {
16 /** 26 /**
17 * The current filter applied to the cookie data list. 27 * The current filter applied to the cookie data list.
18 * @private 28 * @private
19 */ 29 */
20 filterString_: { 30 filterString_: {
21 type: String, 31 type: String,
22 value: '', 32 value: '',
23 }, 33 },
24 34
25 /** @private */ 35 /** @private */
26 confirmationDeleteMsg_: String, 36 confirmationDeleteMsg_: String,
27
28 /** @private */
29 idToDelete_: String,
30 }, 37 },
31 38
32 /** @override */ 39 /** @override */
33 ready: function() { 40 ready: function() {
34 this.loadCookies(); 41 this.loadCookies();
35 }, 42 },
36 43
37 /** 44 /**
38 * A filter function for the list. 45 * A filter function for the list.
39 * @param {!CookieDataSummaryItem} item The item to possibly filter out. 46 * @param {!CookieDataSummaryItem} item The item to possibly filter out.
40 * @return {boolean} Whether to show the item. 47 * @return {boolean} Whether to show the item.
41 * @private 48 * @private
42 */ 49 */
43 showItem_: function(item) { 50 showItem_: function(item) {
44 if (this.filterString_.length == 0) 51 if (this.filterString_.length == 0)
45 return true; 52 return true;
46 return item.site.indexOf(this.filterString_) > -1; 53 return item.site.indexOf(this.filterString_) > -1;
47 }, 54 },
48 55
49 /** @private */ 56 /** @private */
50 onSearchChanged_: function(e) { 57 onSearchChanged_: function(e) {
51 this.filterString_ = e.detail; 58 this.filterString_ = e.detail;
52 this.$.list.render(); 59 this.$.list.render();
53 }, 60 },
54 61
55 /** @private */ 62 /**
63 * @return {boolean} Whether to show the multiple site remove button.
64 * @private
65 */
56 isRemoveButtonVisible_: function(sites, renderedItemCount) { 66 isRemoveButtonVisible_: function(sites, renderedItemCount) {
57 return renderedItemCount != 0; 67 return renderedItemCount != 0;
58 }, 68 },
59 69
60 /** 70 /**
61 * Returns the string to use for the Remove label. 71 * Returns the string to use for the Remove label.
62 * @return {string} filterString The current filter string. 72 * @return {string} filterString The current filter string.
63 * @private 73 * @private
64 */ 74 */
65 computeRemoveLabel_: function(filterString) { 75 computeRemoveLabel_: function(filterString) {
66 if (filterString.length == 0) 76 if (filterString.length == 0)
67 return loadTimeData.getString('siteSettingsCookieRemoveAll'); 77 return loadTimeData.getString('siteSettingsCookieRemoveAll');
68 return loadTimeData.getString('siteSettingsCookieRemoveAllShown'); 78 return loadTimeData.getString('siteSettingsCookieRemoveAllShown');
69 }, 79 },
70 80
71 /** @private */ 81 /** @private */
72 onCloseDialog_: function() { 82 onCloseDialog_: function() {
73 this.$.confirmDeleteDialog.close(); 83 this.$.confirmDeleteDialog.close();
74 }, 84 },
75 85
76 /** 86 /**
77 * Shows a dialog to confirm the deletion of multiple sites. 87 * Shows a dialog to confirm the deletion of multiple sites.
78 * @param {!Event} e 88 * @param {!Event} e
79 * @private 89 * @private
80 */ 90 */
81 onConfirmDeleteMultipleSites_: function(e) { 91 onRemoveShowingSitesTap_: function(e) {
82 e.preventDefault(); 92 e.preventDefault();
83 this.idToDelete_ = ''; // Delete all.
84 this.confirmationDeleteMsg_ = loadTimeData.getString( 93 this.confirmationDeleteMsg_ = loadTimeData.getString(
85 'siteSettingsCookieRemoveMultipleConfirmation'); 94 'siteSettingsCookieRemoveMultipleConfirmation');
86 this.$.confirmDeleteDialog.showModal(); 95 this.$.confirmDeleteDialog.showModal();
87 }, 96 },
88 97
89 /** 98 /**
90 * Called when deletion for a single/multiple sites has been confirmed. 99 * Called when deletion for all showing sites has been confirmed.
91 * @private 100 * @private
92 */ 101 */
93 onConfirmDelete_: function() { 102 onConfirmDelete_: function() {
94 if (this.idToDelete_ != '')
95 this.onDeleteSite_();
96 else
97 this.onDeleteMultipleSites_();
98 this.$.confirmDeleteDialog.close(); 103 this.$.confirmDeleteDialog.close();
99 },
100 104
101 /**
102 * Deletes all site data for a given site.
103 * @private
104 */
105 onDeleteSite_: function() {
106 this.browserProxy.removeCookie(this.idToDelete_);
107 },
108
109 /**
110 * Deletes site data for multiple sites.
111 * @private
112 */
113 onDeleteMultipleSites_: function() {
114 if (this.filterString_.length == 0) { 105 if (this.filterString_.length == 0) {
115 this.removeAllCookies(); 106 this.removeAllCookies();
116 } else { 107 } else {
117 var items = this.$.list.items; 108 var items = this.$.list.items;
118 for (var i = 0; i < items.length; ++i) { 109 for (var i = 0; i < items.length; ++i) {
119 if (this.showItem_(items[i])) 110 if (this.showItem_(items[i]))
120 this.browserProxy.removeCookie(items[i].id); 111 this.browserProxy.removeCookie(items[i].id);
121 } 112 }
122 // We just deleted all items found by the filter, let's reset the filter. 113 // We just deleted all items found by the filter, let's reset the filter.
123 /** @type {SettingsSubpageSearchElement} */(this.$.filter).setValue(''); 114 /** @type {SettingsSubpageSearchElement} */(this.$.filter).setValue('');
124 } 115 }
125 }, 116 },
126 117
127 /** 118 /**
119 * Deletes all site data for a given site.
120 * @param {!DomRepeatEvent} e
121 * @private
122 */
123 onRemoveSiteTap_: function(e) {
124 e.stopPropagation();
125 this.browserProxy.removeCookie(e.model.item.id);
126 },
127
128 /**
128 * @param {!{model: !{item: CookieDataSummaryItem}}} event 129 * @param {!{model: !{item: CookieDataSummaryItem}}} event
129 * @private 130 * @private
130 */ 131 */
131 onSiteTap_: function(event) { 132 onSiteTap_: function(event) {
132 settings.navigateTo(settings.Route.SITE_SETTINGS_DATA_DETAILS, 133 settings.navigateTo(settings.Route.SITE_SETTINGS_DATA_DETAILS,
133 new URLSearchParams('site=' + event.model.item.site)); 134 new URLSearchParams('site=' + event.model.item.site));
134 }, 135 },
135 }); 136 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698