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

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

Issue 2391253002: Site Settings Desktop: Polish the Site Data section. (Closed)
Patch Set: One more confirmation message 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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-details' show the details (permissions and usage) for a given origin 7 * 'site-details' show the details (permissions and usage) for a given origin
8 * under Site Settings. 8 * under Site Settings.
9 */ 9 */
10 Polymer({ 10 Polymer({
11 is: 'site-details', 11 is: 'site-details',
12 12
13 behaviors: [SiteSettingsBehavior, settings.RouteObserverBehavior], 13 behaviors: [SiteSettingsBehavior, settings.RouteObserverBehavior],
14 14
15 properties: { 15 properties: {
16 /** 16 /**
17 * The site that this widget is showing details for. 17 * The site that this widget is showing details for.
18 * @type {SiteException} 18 * @type {SiteException}
19 */ 19 */
20 site: { 20 site: {
21 type: Object, 21 type: Object,
22 observer: 'onSiteChanged_', 22 observer: 'onSiteChanged_',
23 }, 23 },
24 24
25 /** 25 /**
26 * The amount of data stored for the origin. 26 * The amount of data stored for the origin.
27 * @private
27 */ 28 */
28 storedData_: { 29 storedData_: {
29 type: String, 30 type: String,
30 value: '', 31 value: '',
31 }, 32 },
32 33
33 /** 34 /**
34 * The type of storage for the origin. 35 * The type of storage for the origin.
36 * @private
35 */ 37 */
36 storageType_: Number, 38 storageType_: Number,
39
40 /** @private */
41 confirmationDeleteMsg_: String,
37 }, 42 },
38 43
39 listeners: { 44 listeners: {
40 'usage-deleted': 'onUsageDeleted', 45 'usage-deleted': 'onUsageDeleted',
41 }, 46 },
42 47
43 ready: function() { 48 ready: function() {
44 this.ContentSettingsTypes = settings.ContentSettingsTypes; 49 this.ContentSettingsTypes = settings.ContentSettingsTypes;
45 }, 50 },
46 51
47 /** 52 /**
48 * settings.RouteObserverBehavior 53 * settings.RouteObserverBehavior
49 * @param {!settings.Route} route 54 * @param {!settings.Route} route
50 * @protected 55 * @protected
51 */ 56 */
52 currentRouteChanged: function(route) { 57 currentRouteChanged: function(route) {
53 var site = settings.getQueryParameters().get('site'); 58 var site = settings.getQueryParameters().get('site');
54 if (!site) 59 if (!site)
55 return; 60 return;
56 this.browserProxy.getSiteDetails(site).then(function(siteInfo) { 61 this.browserProxy.getSiteDetails(site).then(function(siteInfo) {
57 this.site = this.expandSiteException(siteInfo); 62 this.site = this.expandSiteException(siteInfo);
58 }.bind(this)); 63 }.bind(this));
59 }, 64 },
60 65
61 /** 66 /**
62 * Handler for when the origin changes. 67 * Handler for when the origin changes.
68 * @private
63 */ 69 */
64 onSiteChanged_: function() { 70 onSiteChanged_: function() {
65 // originForDisplay may be initially undefined if the user follows a direct 71 // originForDisplay may be initially undefined if the user follows a direct
66 // link (URL) to this page. 72 // link (URL) to this page.
67 if (this.site.originForDisplay !== undefined) { 73 if (this.site.originForDisplay !== undefined) {
68 // Using originForDisplay avoids the [*.] prefix that some exceptions use. 74 // Using originForDisplay avoids the [*.] prefix that some exceptions use.
69 var url = new URL(this.ensureUrlHasScheme(this.site.originForDisplay)); 75 var url = new URL(this.ensureUrlHasScheme(this.site.originForDisplay));
70 this.$.usageApi.fetchUsageTotal(url.hostname); 76 this.$.usageApi.fetchUsageTotal(url.hostname);
71 } 77 }
72 }, 78 },
73 79
80 /** @private */
81 onCloseDialog_: function() {
82 this.$.confirmDeleteDialog.close();
83 },
84
85 /**
86 * Confirms the deletion of storage for a site.
87 * @param {!{model: !{item: CookieDataSummaryItem}}} event
88 * @private
89 */
90 onConfirmClearStorage_: function(event) {
91 this.confirmationDeleteMsg_ = loadTimeData.getStringF(
92 'siteSettingsSiteRemoveConfirmation',
93 this.toUrl(this.site.origin).href);
94 this.$.confirmDeleteDialog.showModal();
95 },
96
74 /** 97 /**
75 * Clears all data stored for the current origin. 98 * Clears all data stored for the current origin.
99 * @private
76 */ 100 */
77 onClearStorage_: function() { 101 onClearStorage_: function() {
78 this.$.usageApi.clearUsage( 102 this.$.usageApi.clearUsage(
79 this.toUrl(this.site.origin).href, this.storageType_); 103 this.toUrl(this.site.origin).href, this.storageType_);
80 }, 104 },
81 105
82 /** 106 /**
83 * Called when usage has been deleted for an origin. 107 * Called when usage has been deleted for an origin.
108 * @private
84 */ 109 */
85 onUsageDeleted: function(event) { 110 onUsageDeleted: function(event) {
86 if (event.detail.origin == this.toUrl(this.site.origin).href) { 111 if (event.detail.origin == this.toUrl(this.site.origin).href) {
87 this.storedData_ = ''; 112 this.storedData_ = '';
88 this.navigateBackIfNoData_(); 113 this.navigateBackIfNoData_();
89 } 114 }
90 }, 115 },
91 116
92 /** 117 /**
93 * Resets all permissions and clears all data stored for the current origin. 118 * Resets all permissions and clears all data stored for the current origin.
119 * @private
94 */ 120 */
95 onClearAndReset_: function() { 121 onClearAndReset_: function() {
96 Array.prototype.forEach.call( 122 Array.prototype.forEach.call(
97 this.root.querySelectorAll('site-details-permission'), 123 this.root.querySelectorAll('site-details-permission'),
98 function(element) { element.resetPermission(); }); 124 function(element) { element.resetPermission(); });
99 125
100 if (this.storedData_ != '') 126 if (this.storedData_ != '')
101 this.onClearStorage_(); 127 this.onClearStorage_();
102 else 128 else
103 this.navigateBackIfNoData_(); 129 this.navigateBackIfNoData_();
104 }, 130 },
105 131
106 /** 132 /**
107 * Navigate back if the UI is empty (everything been cleared). 133 * Navigate back if the UI is empty (everything been cleared).
134 * @private
108 */ 135 */
109 navigateBackIfNoData_: function() { 136 navigateBackIfNoData_: function() {
110 if (this.storedData_ == '' && !this.permissionShowing_()) 137 if (this.storedData_ == '' && !this.permissionShowing_())
111 settings.navigateToPreviousRoute(); 138 settings.navigateToPreviousRoute();
112 }, 139 },
113 140
114 /** 141 /**
115 * Returns true if one or more permission is showing. 142 * Returns true if one or more permission is showing.
143 * @private
116 */ 144 */
117 permissionShowing_: function() { 145 permissionShowing_: function() {
118 return Array.prototype.some.call( 146 return Array.prototype.some.call(
119 this.root.querySelectorAll('site-details-permission'), 147 this.root.querySelectorAll('site-details-permission'),
120 function(element) { return element.offsetHeight > 0; }); 148 function(element) { return element.offsetHeight > 0; });
121 }, 149 },
122 }); 150 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698