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 23 matching lines...) Expand all Loading... | |
| 34 observers: ['siteChanged_(site, category)'], | 34 observers: ['siteChanged_(site, category)'], |
| 35 | 35 |
| 36 /** @override */ | 36 /** @override */ |
| 37 attached: function() { | 37 attached: function() { |
| 38 this.PermissionValues = settings.PermissionValues; | 38 this.PermissionValues = settings.PermissionValues; |
| 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 * Returns true if the origins match (e.g. http://google.com and | |
| 45 * http://[*.]google.com. | |
|
michaelpg
2016/06/03 13:37:14
nit: closing paren (or if parens and wildcards don
Finnur
2016/06/03 19:58:06
Done.
| |
| 46 * @param {!string} left The first origin to compare. | |
|
michaelpg
2016/06/03 13:37:14
nit here & below: by default strings are non-nulla
Finnur
2016/06/03 19:58:06
Dang. Keep forgetting. :)
| |
| 47 * @param {!string} right The second origin to compare. | |
| 48 * @return {boolean} True if the origins are the same. | |
| 49 * @private | |
| 50 */ | |
| 51 sameOrigin_: function(left, right) { | |
| 52 return this.removePatternWildcard_(left) == | |
| 53 this.removePatternWildcard_(right); | |
| 54 }, | |
| 55 | |
| 56 /** | |
| 44 * Sets the site to display. | 57 * Sets the site to display. |
| 45 * @param {!SiteException} site The site to display. | 58 * @param {!SiteException} site The site to display. |
| 46 * @private | 59 * @private |
| 47 */ | 60 */ |
| 48 siteChanged_: function(site) { | 61 siteChanged_: function(site) { |
| 49 this.$.details.hidden = true; | 62 this.$.details.hidden = true; |
| 50 | 63 |
| 51 this.browserProxy.getExceptionList(this.category).then( | 64 this.browserProxy.getExceptionList(this.category).then( |
| 52 function(exceptionList) { | 65 function(exceptionList) { |
| 53 for (var i = 0; i < exceptionList.length; ++i) { | 66 for (var i = 0; i < exceptionList.length; ++i) { |
| 54 if (exceptionList[i].origin == site.origin) { | 67 if (this.sameOrigin_(exceptionList[i].origin, site.origin)) { |
| 55 this.$.permission.selected = exceptionList[i].setting; | 68 this.$.permission.selected = exceptionList[i].setting; |
| 56 this.$.details.hidden = false; | 69 this.$.details.hidden = false; |
| 57 } | 70 } |
| 58 } | 71 } |
| 59 }.bind(this)); | 72 }.bind(this)); |
| 60 }, | 73 }, |
| 61 | 74 |
| 62 /** | 75 /** |
| 63 * Called when a site within a category has been changed. | 76 * Called when a site within a category has been changed. |
| 64 * @param {number} category The category that changed. | 77 * @param {number} category The category that changed. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 89 /** | 102 /** |
| 90 * Handles the category permission changing for this origin. | 103 * Handles the category permission changing for this origin. |
| 91 * @param {!{detail: !{item: !{dataset: !{permissionValue: string}}}}} event | 104 * @param {!{detail: !{item: !{dataset: !{permissionValue: string}}}}} event |
| 92 */ | 105 */ |
| 93 onPermissionMenuIronActivate_: function(event) { | 106 onPermissionMenuIronActivate_: function(event) { |
| 94 var value = event.detail.item.dataset.permissionValue; | 107 var value = event.detail.item.dataset.permissionValue; |
| 95 this.setCategoryPermissionForOrigin( | 108 this.setCategoryPermissionForOrigin( |
| 96 this.site.origin, '', this.category, value); | 109 this.site.origin, '', this.category, value); |
| 97 }, | 110 }, |
| 98 }); | 111 }); |
| OLD | NEW |