| 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({ |
| 11 is: 'site-details-permission', | 11 is: 'site-details-permission', |
| 12 | 12 |
| 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], | 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], |
| 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: Object, | 20 site: Object, |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 observers: ['siteChanged_(site, category)'], | 23 observers: ['siteChanged_(site, category)'], |
| 24 | 24 |
| 25 /** @override */ | 25 /** @override */ |
| 26 attached: function() { | 26 attached: function() { |
| 27 this.addWebUIListener('contentSettingSitePermissionChanged', | 27 this.addWebUIListener( |
| 28 'contentSettingSitePermissionChanged', |
| 28 this.sitePermissionChanged_.bind(this)); | 29 this.sitePermissionChanged_.bind(this)); |
| 29 }, | 30 }, |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * Returns true if the origins match, e.g. http://google.com and | 33 * Returns true if the origins match, e.g. http://google.com and |
| 33 * http://[*.]google.com. | 34 * http://[*.]google.com. |
| 34 * @param {string} left The first origin to compare. | 35 * @param {string} left The first origin to compare. |
| 35 * @param {string} right The second origin to compare. | 36 * @param {string} right The second origin to compare. |
| 36 * @return {boolean} True if the origins are the same. | 37 * @return {boolean} True if the origins are the same. |
| 37 * @private | 38 * @private |
| 38 */ | 39 */ |
| 39 sameOrigin_: function(left, right) { | 40 sameOrigin_: function(left, right) { |
| 40 return this.removePatternWildcard(left) == | 41 return this.removePatternWildcard(left) == |
| 41 this.removePatternWildcard(right); | 42 this.removePatternWildcard(right); |
| 42 }, | 43 }, |
| 43 | 44 |
| 44 /** @private */ | 45 /** @private */ |
| 45 isCookiesCategory_: function(category) { | 46 isCookiesCategory_: function(category) { |
| 46 return category == settings.ContentSettingsTypes.COOKIES; | 47 return category == settings.ContentSettingsTypes.COOKIES; |
| 47 }, | 48 }, |
| 48 | 49 |
| 49 /** | 50 /** |
| 50 * Sets the site to display. | 51 * Sets the site to display. |
| 51 * @param {!SiteException} site The site to display. | 52 * @param {!SiteException} site The site to display. |
| 52 * @private | 53 * @private |
| 53 */ | 54 */ |
| 54 siteChanged_: function(site) { | 55 siteChanged_: function(site) { |
| 55 this.$.details.hidden = true; | 56 this.$.details.hidden = true; |
| 56 | 57 |
| 57 this.browserProxy.getExceptionList(this.category).then( | 58 this.browserProxy.getExceptionList(this.category) |
| 58 function(exceptionList) { | 59 .then(function(exceptionList) { |
| 59 for (var i = 0; i < exceptionList.length; ++i) { | 60 for (var i = 0; i < exceptionList.length; ++i) { |
| 60 if (exceptionList[i].embeddingOrigin == site.embeddingOrigin && | 61 if (exceptionList[i].embeddingOrigin == site.embeddingOrigin && |
| 61 this.sameOrigin_(exceptionList[i].origin, site.origin)) { | 62 this.sameOrigin_(exceptionList[i].origin, site.origin)) { |
| 62 this.$.permission.value = exceptionList[i].setting; | 63 this.$.permission.value = exceptionList[i].setting; |
| 63 this.$.details.hidden = false; | 64 this.$.details.hidden = false; |
| 64 break; | 65 break; |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 }.bind(this)); | 68 }.bind(this)); |
| 68 }, | 69 }, |
| 69 | 70 |
| 70 /** | 71 /** |
| 71 * Called when a site within a category has been changed. | 72 * Called when a site within a category has been changed. |
| 72 * @param {number} category The category that changed. | 73 * @param {number} category The category that changed. |
| 73 * @param {string} origin The origin of the site that changed. | 74 * @param {string} origin The origin of the site that changed. |
| 74 * @param {string} embeddingOrigin The embedding origin of the site that | 75 * @param {string} embeddingOrigin The embedding origin of the site that |
| 75 * changed. | 76 * changed. |
| 76 * @private | 77 * @private |
| 77 */ | 78 */ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 100 /** | 101 /** |
| 101 * Handles the category permission changing for this origin. | 102 * Handles the category permission changing for this origin. |
| 102 * @private | 103 * @private |
| 103 */ | 104 */ |
| 104 onPermissionSelectionChange_: function() { | 105 onPermissionSelectionChange_: function() { |
| 105 this.browserProxy.setCategoryPermissionForOrigin( | 106 this.browserProxy.setCategoryPermissionForOrigin( |
| 106 this.site.origin, this.site.embeddingOrigin, this.category, | 107 this.site.origin, this.site.embeddingOrigin, this.category, |
| 107 this.$.permission.value, this.site.incognito); | 108 this.$.permission.value, this.site.incognito); |
| 108 }, | 109 }, |
| 109 }); | 110 }); |
| OLD | NEW |