| 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 // This module implements the base attributes of the GuestView tags. | 5 // This module implements the base attributes of the GuestView tags. |
| 6 | 6 |
| 7 // ----------------------------------------------------------------------------- | 7 // ----------------------------------------------------------------------------- |
| 8 // Attribute object. | 8 // Attribute object. |
| 9 | 9 |
| 10 // Default implementation of a GuestView attribute. | 10 // Default implementation of a GuestView attribute. |
| 11 function Attribute(name, view) { | 11 function Attribute(name, view) { |
| 12 this.dirty = false; | 12 this.dirty = false; |
| 13 this.ignoreMutation = false; | 13 this.ignoreMutation = false; |
| 14 this.name = name; | 14 this.name = name; |
| 15 this.view = view; | 15 this.view = view; |
| 16 | 16 |
| 17 this.defineProperty(); | 17 this.defineProperty(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 // Prevent GuestViewEvents inadvertently inheritng code from the global Object, |
| 21 // allowing a pathway for unintended execution of user code. |
| 22 // TODO(wjmaclean): Use utils.expose() here instead, track down other issues |
| 23 // of Object inheritance. https://crbug.com/701034 |
| 24 Attribute.prototype.__proto__ = null; |
| 25 |
| 20 // Retrieves and returns the attribute's value. | 26 // Retrieves and returns the attribute's value. |
| 21 Attribute.prototype.getValue = function() { | 27 Attribute.prototype.getValue = function() { |
| 22 return this.view.element.getAttribute(this.name) || ''; | 28 return this.view.element.getAttribute(this.name) || ''; |
| 23 }; | 29 }; |
| 24 | 30 |
| 25 // Retrieves and returns the attribute's value if it has been dirtied since | 31 // Retrieves and returns the attribute's value if it has been dirtied since |
| 26 // the last time this method was called. Returns null otherwise. | 32 // the last time this method was called. Returns null otherwise. |
| 27 Attribute.prototype.getValueIfDirty = function() { | 33 Attribute.prototype.getValueIfDirty = function() { |
| 28 if (!this.dirty) | 34 if (!this.dirty) |
| 29 return null; | 35 return null; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 139 |
| 134 var GuestViewAttributes = { | 140 var GuestViewAttributes = { |
| 135 Attribute: Attribute, | 141 Attribute: Attribute, |
| 136 BooleanAttribute: BooleanAttribute, | 142 BooleanAttribute: BooleanAttribute, |
| 137 IntegerAttribute: IntegerAttribute, | 143 IntegerAttribute: IntegerAttribute, |
| 138 ReadOnlyAttribute: ReadOnlyAttribute | 144 ReadOnlyAttribute: ReadOnlyAttribute |
| 139 }; | 145 }; |
| 140 | 146 |
| 141 // Exports. | 147 // Exports. |
| 142 exports.$set('GuestViewAttributes', GuestViewAttributes); | 148 exports.$set('GuestViewAttributes', GuestViewAttributes); |
| OLD | NEW |