Chromium Code Reviews| 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} | 18 * @private |
| 19 */ | 19 */ |
| 20 site: { | 20 origin: { |
|
raymes
2017/06/19 04:13:12
site looks like it may be referred to in the .html
Patti Lor
2017/06/20 08:25:54
Oops, you're right, thank you. I just removed it,
| |
| 21 type: Object, | 21 type: String, |
| 22 observer: 'onSiteChanged_', | 22 observer: 'onOriginChanged_', |
| 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 * @private |
| 28 */ | 28 */ |
| 29 storedData_: { | 29 storedData_: { |
| 30 type: String, | 30 type: String, |
| 31 value: '', | 31 value: '', |
| 32 }, | 32 }, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * settings.RouteObserverBehavior | 54 * settings.RouteObserverBehavior |
| 55 * @param {!settings.Route} route | 55 * @param {!settings.Route} route |
| 56 * @protected | 56 * @protected |
| 57 */ | 57 */ |
| 58 currentRouteChanged: function(route) { | 58 currentRouteChanged: function(route) { |
| 59 var site = settings.getQueryParameters().get('site'); | 59 var site = settings.getQueryParameters().get('site'); |
| 60 if (!site) | 60 if (!site) |
| 61 return; | 61 return; |
| 62 this.browserProxy.getSiteDetails(site).then(function(siteInfo) { | 62 this.origin = site; |
| 63 this.site = this.expandSiteException(siteInfo); | |
| 64 }.bind(this)); | |
| 65 }, | 63 }, |
| 66 | 64 |
| 67 /** | 65 /** |
| 68 * Handler for when the origin changes. | 66 * Handler for when the origin changes. |
| 69 * @private | 67 * @private |
| 70 */ | 68 */ |
| 71 onSiteChanged_: function() { | 69 onOriginChanged_: function() { |
| 72 // origin may be initially undefined if the user follows a direct | 70 this.$.usageApi.fetchUsageTotal(this.toUrl(this.origin).hostname); |
| 73 // link (URL) to this page. | 71 |
| 74 var origin = this.site.origin; | 72 // Retrieve the setting for each category shown. |
| 75 if (origin !== undefined) | 73 Array.prototype.forEach.call( |
| 76 this.$.usageApi.fetchUsageTotal(this.toUrl(origin).hostname); | 74 this.root.querySelectorAll('site-details-permission'), |
| 75 function(element) { | |
| 76 this.browserProxy | |
| 77 .getCategoryPermissionForOrigin( | |
| 78 element.category, this.origin, this.origin) | |
| 79 .then(function(permissionResult) { | |
| 80 element.site = element.expandSiteException(permissionResult); | |
| 81 }.bind(element)); | |
| 82 }.bind(this)); | |
| 77 }, | 83 }, |
| 78 | 84 |
| 79 /** @private */ | 85 /** @private */ |
| 80 onCloseDialog_: function() { | 86 onCloseDialog_: function() { |
| 81 this.$.confirmDeleteDialog.close(); | 87 this.$.confirmDeleteDialog.close(); |
| 82 }, | 88 }, |
| 83 | 89 |
| 84 /** | 90 /** |
| 85 * Confirms the deletion of storage for a site. | 91 * Confirms the deletion of storage for a site. |
| 86 * @param {!Event} e | 92 * @param {!Event} e |
| 87 * @private | 93 * @private |
| 88 */ | 94 */ |
| 89 onConfirmClearStorage_: function(e) { | 95 onConfirmClearStorage_: function(e) { |
| 90 e.preventDefault(); | 96 e.preventDefault(); |
| 91 this.confirmationDeleteMsg_ = loadTimeData.getStringF( | 97 this.confirmationDeleteMsg_ = loadTimeData.getStringF( |
| 92 'siteSettingsSiteRemoveConfirmation', | 98 'siteSettingsSiteRemoveConfirmation', this.toUrl(this.origin).href); |
| 93 this.toUrl(this.site.origin).href); | |
| 94 this.$.confirmDeleteDialog.showModal(); | 99 this.$.confirmDeleteDialog.showModal(); |
| 95 }, | 100 }, |
| 96 | 101 |
| 97 /** | 102 /** |
| 98 * Clears all data stored for the current origin. | 103 * Clears all data stored for the current origin. |
| 99 * @private | 104 * @private |
| 100 */ | 105 */ |
| 101 onClearStorage_: function() { | 106 onClearStorage_: function() { |
| 102 this.$.usageApi.clearUsage( | 107 this.$.usageApi.clearUsage(this.toUrl(this.origin).href, this.storageType_); |
| 103 this.toUrl(this.site.origin).href, this.storageType_); | |
| 104 }, | 108 }, |
| 105 | 109 |
| 106 /** | 110 /** |
| 107 * Called when usage has been deleted for an origin. | 111 * Called when usage has been deleted for an origin. |
| 108 * @param {!{detail: !{origin: string}}} event | 112 * @param {!{detail: !{origin: string}}} event |
| 109 * @private | 113 * @private |
| 110 */ | 114 */ |
| 111 onUsageDeleted_: function(event) { | 115 onUsageDeleted_: function(event) { |
| 112 if (event.detail.origin == this.toUrl(this.site.origin).href) { | 116 if (event.detail.origin == this.toUrl(this.origin).href) { |
| 113 this.storedData_ = ''; | 117 this.storedData_ = ''; |
| 114 this.navigateBackIfNoData_(); | 118 this.navigateBackIfNoData_(); |
| 115 } | 119 } |
| 116 }, | 120 }, |
| 117 | 121 |
| 118 /** | 122 /** |
| 119 * Resets all permissions and clears all data stored for the current origin. | 123 * Resets all permissions and clears all data stored for the current origin. |
| 120 * @private | 124 * @private |
| 121 */ | 125 */ |
| 122 onClearAndReset_: function() { | 126 onClearAndReset_: function() { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 142 /** | 146 /** |
| 143 * Returns true if one or more permission is showing. | 147 * Returns true if one or more permission is showing. |
| 144 * @private | 148 * @private |
| 145 */ | 149 */ |
| 146 permissionShowing_: function() { | 150 permissionShowing_: function() { |
| 147 return Array.prototype.some.call( | 151 return Array.prototype.some.call( |
| 148 this.root.querySelectorAll('site-details-permission'), | 152 this.root.querySelectorAll('site-details-permission'), |
| 149 function(element) { return element.offsetHeight > 0; }); | 153 function(element) { return element.offsetHeight > 0; }); |
| 150 }, | 154 }, |
| 151 }); | 155 }); |
| OLD | NEW |