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

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: fix test 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.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 /** @private */ 78 /** @private */
72 onCloseDialog_: function() { 79 onCloseDialog_: function() {
73 this.$.confirmDeleteDialog.close(); 80 this.$.confirmDeleteDialog.close();
74 }, 81 },
75 82
76 /** 83 /**
77 * Shows a dialog to confirm the deletion of multiple sites. 84 * Shows a dialog to confirm the deletion of multiple sites.
78 * @param {!Event} e 85 * @param {!Event} e
79 * @private 86 * @private
80 */ 87 */
81 onConfirmDeleteMultipleSites_: function(e) { 88 onRemoveAllTap_: function(e) {
82 e.preventDefault(); 89 e.preventDefault();
83 this.idToDelete_ = ''; // Delete all.
84 this.confirmationDeleteMsg_ = loadTimeData.getString( 90 this.confirmationDeleteMsg_ = loadTimeData.getString(
85 'siteSettingsCookieRemoveMultipleConfirmation'); 91 'siteSettingsCookieRemoveMultipleConfirmation');
86 this.$.confirmDeleteDialog.showModal(); 92 this.$.confirmDeleteDialog.showModal();
87 }, 93 },
88 94
89 /** 95 /**
90 * Called when deletion for a single/multiple sites has been confirmed. 96 * Called when deletion for a single/multiple sites has been confirmed.
dschuyler 2017/02/13 20:14:35 It looks like the comment needs to be updated. ma
Dan Beam 2017/02/14 04:14:03 Done.
91 * @private 97 * @private
92 */ 98 */
93 onConfirmDelete_: function() { 99 onConfirmDelete_: function() {
94 if (this.idToDelete_ != '')
95 this.onDeleteSite_();
96 else
97 this.onDeleteMultipleSites_();
98 this.$.confirmDeleteDialog.close(); 100 this.$.confirmDeleteDialog.close();
99 },
100 101
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) { 102 if (this.filterString_.length == 0) {
115 this.removeAllCookies(); 103 this.removeAllCookies();
116 } else { 104 } else {
117 var items = this.$.list.items; 105 var items = this.$.list.items;
118 for (var i = 0; i < items.length; ++i) { 106 for (var i = 0; i < items.length; ++i) {
119 if (this.showItem_(items[i])) 107 if (this.showItem_(items[i]))
120 this.browserProxy.removeCookie(items[i].id); 108 this.browserProxy.removeCookie(items[i].id);
121 } 109 }
122 // We just deleted all items found by the filter, let's reset the filter. 110 // We just deleted all items found by the filter, let's reset the filter.
123 /** @type {SettingsSubpageSearchElement} */(this.$.filter).setValue(''); 111 /** @type {SettingsSubpageSearchElement} */(this.$.filter).setValue('');
124 } 112 }
125 }, 113 },
126 114
127 /** 115 /**
116 * Deletes all site data for a given site.
117 * @param {!DomRepeatEvent} e
118 * @private
119 */
120 onRemoveSiteTap_: function(e) {
121 e.stopPropagation();
122 this.browserProxy.removeCookie(e.model.item.id);
123 },
124
125 /**
128 * @param {!{model: !{item: CookieDataSummaryItem}}} event 126 * @param {!{model: !{item: CookieDataSummaryItem}}} event
129 * @private 127 * @private
130 */ 128 */
131 onSiteTap_: function(event) { 129 onSiteTap_: function(event) {
132 settings.navigateTo(settings.Route.SITE_SETTINGS_DATA_DETAILS, 130 settings.navigateTo(settings.Route.SITE_SETTINGS_DATA_DETAILS,
133 new URLSearchParams('site=' + event.model.item.site)); 131 new URLSearchParams('site=' + event.model.item.site));
134 }, 132 },
135 }); 133 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698