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-permission' handles showing the state of one permission, such | 7 * 'site-details-permission' handles showing the state of one permission, such |
| 8 * as Geolocation, for a given origin. | 8 * as Geolocation, for a given origin. |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 this.addWebUIListener('contentSettingSitePermissionChanged', | 39 this.addWebUIListener('contentSettingSitePermissionChanged', |
| 40 this.sitePermissionChanged_.bind(this)); | 40 this.sitePermissionChanged_.bind(this)); |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Sets the site to display. | 44 * Sets the site to display. |
| 45 * @param {!SiteException} site The site to display. | 45 * @param {!SiteException} site The site to display. |
| 46 * @private | 46 * @private |
| 47 */ | 47 */ |
| 48 siteChanged_: function(site) { | 48 siteChanged_: function(site) { |
| 49 this.$.details.hidden = true; | 49 // Finish this asynchronously to give |category| a chance to be set first. |
|
michaelpg
2016/04/05 18:22:53
May be preferable to keep this synchronous by maki
Finnur
2016/04/06 00:25:19
Doh. Of course. Can't believe I overlooked that. M
| |
| 50 this.async(function() { | |
| 51 this.$.details.hidden = true; | |
| 50 | 52 |
| 51 var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); | 53 var prefsProxy = settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
| 52 prefsProxy.getExceptionList(this.category).then(function(exceptionList) { | 54 prefsProxy.getExceptionList(this.category).then(function(exceptionList) { |
| 53 for (var i = 0; i < exceptionList.length; ++i) { | 55 for (var i = 0; i < exceptionList.length; ++i) { |
| 54 if (exceptionList[i].origin == site.origin) { | 56 if (exceptionList[i].origin == site.origin) { |
| 55 // TODO(finnur): Convert to use attrForSelected. | 57 // TODO(finnur): Convert to use attrForSelected. |
| 56 this.$.permission.selected = exceptionList[i].setting == | 58 this.$.permission.selected = exceptionList[i].setting == |
| 57 settings.PermissionStringValues.ALLOW ? 0 : 1; | 59 settings.PermissionStringValues.ALLOW ? 0 : 1; |
| 58 this.$.details.hidden = false; | 60 this.$.details.hidden = false; |
| 61 } | |
| 59 } | 62 } |
| 60 } | 63 }.bind(this)); |
| 61 }.bind(this)); | 64 }); |
| 62 }, | 65 }, |
| 63 | 66 |
| 64 /** | 67 /** |
| 65 * Called when a site within a category has been changed. | 68 * Called when a site within a category has been changed. |
| 66 * @param {number} category The category that changed. | 69 * @param {number} category The category that changed. |
| 67 * @param {string} site The site that changed. | 70 * @param {string} site The site that changed. |
| 68 * @private | 71 * @private |
| 69 */ | 72 */ |
| 70 sitePermissionChanged_: function(category, site) { | 73 sitePermissionChanged_: function(category, site) { |
| 71 if (category == this.category && (site == '' || site == this.site.origin)) { | 74 if (category == this.category && (site == '' || site == this.site.origin)) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 95 // TODO(finnur): Compare with event.detail.item.dataset.permission directly | 98 // TODO(finnur): Compare with event.detail.item.dataset.permission directly |
| 96 // once attrForSelected is in use. | 99 // once attrForSelected is in use. |
| 97 var action = event.detail.item.innerText; | 100 var action = event.detail.item.innerText; |
| 98 var value = (action == this.i18n_.allowAction) ? | 101 var value = (action == this.i18n_.allowAction) ? |
| 99 settings.PermissionValues.ALLOW : | 102 settings.PermissionValues.ALLOW : |
| 100 settings.PermissionValues.BLOCK; | 103 settings.PermissionValues.BLOCK; |
| 101 this.setCategoryPermissionForOrigin( | 104 this.setCategoryPermissionForOrigin( |
| 102 this.site.origin, '', value, this.category); | 105 this.site.origin, '', value, this.category); |
| 103 }, | 106 }, |
| 104 }); | 107 }); |
| OLD | NEW |