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 attributes of the <extensionview> tag. | 5 // This module implements the attributes of the <extensionview> tag. |
6 | 6 |
7 var GuestViewInternal = | 7 var GuestViewInternal = |
8 require('binding').Binding.create('guestViewInternal').generate(); | 8 require('binding').Binding.create('guestViewInternal').generate(); |
9 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl; | 9 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl; |
10 var ExtensionViewConstants = | 10 var ExtensionViewConstants = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return this.getValue(); | 48 return this.getValue(); |
49 }.bind(this), | 49 }.bind(this), |
50 set: function(value) { | 50 set: function(value) { |
51 this.setValue(value); | 51 this.setValue(value); |
52 }.bind(this), | 52 }.bind(this), |
53 enumerable: true | 53 enumerable: true |
54 }); | 54 }); |
55 }; | 55 }; |
56 | 56 |
57 // Called when the attribute's value changes. | 57 // Called when the attribute's value changes. |
| 58 ExtensionViewAttribute.prototype.maybeHandleMutation = |
| 59 function(oldValue, newValue) { |
| 60 if (this.ignoreMutation) { |
| 61 return; |
| 62 } |
| 63 |
| 64 this.handleMutation(oldValue, newValue); |
| 65 } |
| 66 |
| 67 // Called when a change that isn't ignored occurs to the attribute's value. |
58 ExtensionViewAttribute.prototype.handleMutation = | 68 ExtensionViewAttribute.prototype.handleMutation = |
59 function(oldValue, newValue) {}; | 69 function(oldValue, newValue) {}; |
60 | 70 |
61 // Attribute that handles the location and navigation of the extensionview. | 71 // Attribute that handles the location and navigation of the extensionview. |
62 function SrcAttribute(extensionViewImpl) { | 72 function SrcAttribute(extensionViewImpl) { |
63 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC, | 73 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC, |
64 extensionViewImpl); | 74 extensionViewImpl); |
65 this.setupMutationObserver(); | 75 this.setupMutationObserver(); |
66 this.beforeFirstNavigation = true; | 76 this.beforeFirstNavigation = true; |
67 } | 77 } |
68 | 78 |
69 SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; | 79 SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; |
70 | 80 |
71 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { | 81 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { |
72 this.observer.takeRecords(); | 82 this.observer.takeRecords(); |
73 this.ignoreMutation = true; | 83 this.ignoreMutation = true; |
74 this.extensionViewImpl.element.setAttribute(this.name, value || ''); | 84 this.extensionViewImpl.element.setAttribute(this.name, value || ''); |
75 this.ignoreMutation = false; | 85 this.ignoreMutation = false; |
76 } | 86 } |
77 | 87 |
78 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { | 88 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { |
79 if (this.attributes[attributeName].ignoreMutation) | |
80 return; | |
81 | |
82 if (!newValue && oldValue) { | 89 if (!newValue && oldValue) { |
83 this.setValueIgnoreMutation(oldValue); | 90 this.setValueIgnoreMutation(oldValue); |
84 return; | 91 return; |
85 } | 92 } |
86 this.parse(); | 93 this.parse(); |
87 }; | 94 }; |
88 | 95 |
89 SrcAttribute.prototype.setupMutationObserver = | 96 SrcAttribute.prototype.setupMutationObserver = |
90 function() { | 97 function() { |
91 this.observer = new MutationObserver(function(mutations) { | 98 this.observer = new MutationObserver(function(mutations) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 }; | 134 }; |
128 | 135 |
129 // ----------------------------------------------------------------------------- | 136 // ----------------------------------------------------------------------------- |
130 | 137 |
131 // Sets up all of the extensionview attributes. | 138 // Sets up all of the extensionview attributes. |
132 ExtensionViewImpl.prototype.setupExtensionViewAttributes = function() { | 139 ExtensionViewImpl.prototype.setupExtensionViewAttributes = function() { |
133 this.attributes = {}; | 140 this.attributes = {}; |
134 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] = | 141 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] = |
135 new SrcAttribute(this); | 142 new SrcAttribute(this); |
136 }; | 143 }; |
OLD | NEW |