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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 /** | 31 /** |
32 * Returns true if the origins match, e.g. http://google.com and | 32 * Returns true if the origins match, e.g. http://google.com and |
33 * http://[*.]google.com. | 33 * http://[*.]google.com. |
34 * @param {string} left The first origin to compare. | 34 * @param {string} left The first origin to compare. |
35 * @param {string} right The second origin to compare. | 35 * @param {string} right The second origin to compare. |
36 * @return {boolean} True if the origins are the same. | 36 * @return {boolean} True if the origins are the same. |
37 * @private | 37 * @private |
38 */ | 38 */ |
39 sameOrigin_: function(left, right) { | 39 sameOrigin_: function(left, right) { |
40 return this.removePatternWildcard_(left) == | 40 return this.removePatternWildcard(left) == |
41 this.removePatternWildcard_(right); | 41 this.removePatternWildcard(right); |
42 }, | 42 }, |
43 | 43 |
44 /** | 44 /** |
45 * Sets the site to display. | 45 * Sets the site to display. |
46 * @param {!SiteException} site The site to display. | 46 * @param {!SiteException} site The site to display. |
47 * @private | 47 * @private |
48 */ | 48 */ |
49 siteChanged_: function(site) { | 49 siteChanged_: function(site) { |
50 this.$.details.hidden = true; | 50 this.$.details.hidden = true; |
51 | 51 |
52 this.browserProxy.getExceptionList(this.category).then( | 52 this.browserProxy.getExceptionList(this.category).then( |
53 function(exceptionList) { | 53 function(exceptionList) { |
54 for (var i = 0; i < exceptionList.length; ++i) { | 54 for (var i = 0; i < exceptionList.length; ++i) { |
55 if (this.sameOrigin_(exceptionList[i].origin, site.origin)) { | 55 if (exceptionList[i].embeddingOrigin == site.embeddingOrigin && |
| 56 this.sameOrigin_(exceptionList[i].origin, site.origin)) { |
56 this.$.permission.selected = exceptionList[i].setting; | 57 this.$.permission.selected = exceptionList[i].setting; |
57 this.$.details.hidden = false; | 58 this.$.details.hidden = false; |
| 59 break; |
58 } | 60 } |
59 } | 61 } |
60 }.bind(this)); | 62 }.bind(this)); |
61 }, | 63 }, |
62 | 64 |
63 /** | 65 /** |
64 * Called when a site within a category has been changed. | 66 * Called when a site within a category has been changed. |
65 * @param {number} category The category that changed. | 67 * @param {number} category The category that changed. |
66 * @param {string} site The site that changed. | 68 * @param {string} origin The origin of the site that changed. |
| 69 * @param {string} embeddingOrigin The embedding origin of the site that |
| 70 * changed. |
67 * @private | 71 * @private |
68 */ | 72 */ |
69 sitePermissionChanged_: function(category, site) { | 73 sitePermissionChanged_: function(category, origin, embeddingOrigin) { |
70 if (category == this.category && (site == '' || site == this.site.origin)) { | 74 if (this.site === undefined) |
71 // TODO(finnur): Send down the full SiteException, not just a string. | 75 return; |
72 this.siteChanged_({ | 76 if (category != this.category) |
73 origin: site, | 77 return; |
74 originForDisplay: '', | 78 |
75 embeddingOrigin: '', | 79 if (origin == '' || (origin == this.site.origin && |
76 setting: '', | 80 embeddingOrigin == this.site.embeddingOrigin)) { |
77 source: '', | 81 this.siteChanged_(this.site); |
78 }); | |
79 } | 82 } |
80 }, | 83 }, |
81 | 84 |
82 /** | 85 /** |
83 * Resets the category permission for this origin. | 86 * Resets the category permission for this origin. |
84 */ | 87 */ |
85 resetPermission: function() { | 88 resetPermission: function() { |
86 this.resetCategoryPermissionForOrigin(this.site.origin, '', this.category); | 89 this.resetCategoryPermissionForOrigin( |
| 90 this.site.origin, this.site.embeddingOrigin, this.category); |
87 this.$.details.hidden = true; | 91 this.$.details.hidden = true; |
88 }, | 92 }, |
89 | 93 |
90 /** | 94 /** |
91 * Handles the category permission changing for this origin. | 95 * Handles the category permission changing for this origin. |
92 * @param {!{detail: !{item: !{dataset: !{permissionValue: string}}}}} event | 96 * @param {!{detail: !{item: !{dataset: !{permissionValue: string}}}}} event |
93 */ | 97 */ |
94 onPermissionMenuIronActivate_: function(event) { | 98 onPermissionMenuIronActivate_: function(event) { |
95 var value = event.detail.item.dataset.permissionValue; | 99 var value = event.detail.item.dataset.permissionValue; |
96 this.setCategoryPermissionForOrigin( | 100 this.setCategoryPermissionForOrigin( |
97 this.site.origin, '', this.category, value); | 101 this.site.origin, this.site.embeddingOrigin, this.category, value); |
98 }, | 102 }, |
99 }); | 103 }); |
OLD | NEW |