OLD | NEW |
---|---|
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 origin that this widget is showing details for. |
18 * @type {SiteException} | |
19 */ | 18 */ |
20 site: { | 19 origin: { |
21 type: Object, | 20 type: String, |
22 observer: 'onSiteChanged_', | 21 observer: 'onOriginChanged_', |
23 }, | 22 }, |
24 | 23 |
25 /** | 24 /** |
26 * The amount of data stored for the origin. | 25 * The amount of data stored for the origin. |
27 * @private | 26 * @private |
28 */ | 27 */ |
29 storedData_: { | 28 storedData_: { |
30 type: String, | 29 type: String, |
31 value: '', | 30 value: '', |
32 }, | 31 }, |
(...skipping 19 matching lines...) Expand all Loading... | |
52 | 51 |
53 /** | 52 /** |
54 * settings.RouteObserverBehavior | 53 * settings.RouteObserverBehavior |
55 * @param {!settings.Route} route | 54 * @param {!settings.Route} route |
56 * @protected | 55 * @protected |
57 */ | 56 */ |
58 currentRouteChanged: function(route) { | 57 currentRouteChanged: function(route) { |
59 var site = settings.getQueryParameters().get('site'); | 58 var site = settings.getQueryParameters().get('site'); |
60 if (!site) | 59 if (!site) |
61 return; | 60 return; |
62 this.browserProxy.getSiteDetails(site).then(function(siteInfo) { | 61 this.origin = site; |
63 this.site = this.expandSiteException(siteInfo); | |
64 }.bind(this)); | |
65 }, | 62 }, |
66 | 63 |
67 /** | 64 /** |
68 * Handler for when the origin changes. | 65 * Handler for when the origin changes. |
69 * @private | 66 * @private |
70 */ | 67 */ |
71 onSiteChanged_: function() { | 68 onOriginChanged_: function() { |
72 // origin may be initially undefined if the user follows a direct | 69 // origin may be initially undefined if the user follows a direct |
73 // link (URL) to this page. | 70 // link (URL) to this page. |
74 var origin = this.site.origin; | 71 if (this.origin === undefined) |
tsergeant
2017/06/16 03:11:40
This check shouldn't be necessary anymore. Polymer
Patti Lor
2017/06/20 08:25:54
Done.
| |
75 if (origin !== undefined) | 72 return; |
76 this.$.usageApi.fetchUsageTotal(this.toUrl(origin).hostname); | 73 |
74 this.$.usageApi.fetchUsageTotal(this.toUrl(this.origin).hostname); | |
75 | |
76 // Retrieve the setting for each category shown. | |
77 Array.prototype.forEach.call( | |
78 this.root.querySelectorAll('site-details-permission'), | |
tsergeant
2017/06/16 03:11:40
Because it's the future (Chrome 51+), NodeList has
Patti Lor
2017/06/20 08:25:54
Ohh, I was kinda confused about this. Thanks for t
| |
79 function(element) { | |
80 this.browserProxy | |
81 .getCategoryPermissionForOrigin( | |
82 element.category, this.origin, this.origin) | |
83 .then(function(permission_result) { | |
tsergeant
2017/06/16 03:11:39
JS Style uses camelCase rather than snake_case
Patti Lor
2017/06/20 08:25:54
Done.
| |
84 element.site = element.expandSiteException(permission_result); | |
85 }.bind(element)); | |
86 }.bind(this)); | |
77 }, | 87 }, |
78 | 88 |
79 /** @private */ | 89 /** @private */ |
80 onCloseDialog_: function() { | 90 onCloseDialog_: function() { |
81 this.$.confirmDeleteDialog.close(); | 91 this.$.confirmDeleteDialog.close(); |
82 }, | 92 }, |
83 | 93 |
84 /** | 94 /** |
85 * Confirms the deletion of storage for a site. | 95 * Confirms the deletion of storage for a site. |
86 * @param {!Event} e | 96 * @param {!Event} e |
87 * @private | 97 * @private |
88 */ | 98 */ |
89 onConfirmClearStorage_: function(e) { | 99 onConfirmClearStorage_: function(e) { |
90 e.preventDefault(); | 100 e.preventDefault(); |
91 this.confirmationDeleteMsg_ = loadTimeData.getStringF( | 101 this.confirmationDeleteMsg_ = loadTimeData.getStringF( |
92 'siteSettingsSiteRemoveConfirmation', | 102 'siteSettingsSiteRemoveConfirmation', this.toUrl(this.origin).href); |
93 this.toUrl(this.site.origin).href); | |
94 this.$.confirmDeleteDialog.showModal(); | 103 this.$.confirmDeleteDialog.showModal(); |
95 }, | 104 }, |
96 | 105 |
97 /** | 106 /** |
98 * Clears all data stored for the current origin. | 107 * Clears all data stored for the current origin. |
99 * @private | 108 * @private |
100 */ | 109 */ |
101 onClearStorage_: function() { | 110 onClearStorage_: function() { |
102 this.$.usageApi.clearUsage( | 111 this.$.usageApi.clearUsage(this.toUrl(this.origin).href, this.storageType_); |
103 this.toUrl(this.site.origin).href, this.storageType_); | |
104 }, | 112 }, |
105 | 113 |
106 /** | 114 /** |
107 * Called when usage has been deleted for an origin. | 115 * Called when usage has been deleted for an origin. |
108 * @param {!{detail: !{origin: string}}} event | 116 * @param {!{detail: !{origin: string}}} event |
109 * @private | 117 * @private |
110 */ | 118 */ |
111 onUsageDeleted_: function(event) { | 119 onUsageDeleted_: function(event) { |
112 if (event.detail.origin == this.toUrl(this.site.origin).href) { | 120 if (event.detail.origin == this.toUrl(this.origin).href) { |
113 this.storedData_ = ''; | 121 this.storedData_ = ''; |
114 this.navigateBackIfNoData_(); | 122 this.navigateBackIfNoData_(); |
115 } | 123 } |
116 }, | 124 }, |
117 | 125 |
118 /** | 126 /** |
119 * Resets all permissions and clears all data stored for the current origin. | 127 * Resets all permissions and clears all data stored for the current origin. |
120 * @private | 128 * @private |
121 */ | 129 */ |
122 onClearAndReset_: function() { | 130 onClearAndReset_: function() { |
(...skipping 19 matching lines...) Expand all Loading... | |
142 /** | 150 /** |
143 * Returns true if one or more permission is showing. | 151 * Returns true if one or more permission is showing. |
144 * @private | 152 * @private |
145 */ | 153 */ |
146 permissionShowing_: function() { | 154 permissionShowing_: function() { |
147 return Array.prototype.some.call( | 155 return Array.prototype.some.call( |
148 this.root.querySelectorAll('site-details-permission'), | 156 this.root.querySelectorAll('site-details-permission'), |
149 function(element) { return element.offsetHeight > 0; }); | 157 function(element) { return element.offsetHeight > 0; }); |
150 }, | 158 }, |
151 }); | 159 }); |
OLD | NEW |