| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = | 58 ExtensionViewAttribute.prototype.maybeHandleMutation = |
| 59 function(oldValue, newValue) { | 59 function(oldValue, newValue) { |
| 60 if (this.ignoreMutation) { | 60 if (this.ignoreMutation) |
| 61 return; | 61 return; |
| 62 } | |
| 63 | 62 |
| 64 this.handleMutation(oldValue, newValue); | 63 this.handleMutation(oldValue, newValue); |
| 65 } | 64 } |
| 66 | 65 |
| 67 // Called when a change that isn't ignored occurs to the attribute's value. | 66 // Called when a change that isn't ignored occurs to the attribute's value. |
| 68 ExtensionViewAttribute.prototype.handleMutation = | 67 ExtensionViewAttribute.prototype.handleMutation = |
| 69 function(oldValue, newValue) {}; | 68 function(oldValue, newValue) {}; |
| 70 | 69 |
| 70 ExtensionViewAttribute.prototype.reset = function() { |
| 71 this.setValueIgnoreMutation(); |
| 72 } |
| 73 |
| 74 // Attribute that handles extension binded to the extensionview. |
| 75 function ExtensionAttribute(extensionViewImpl) { |
| 76 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_EXTENSION, |
| 77 extensionViewImpl); |
| 78 } |
| 79 |
| 80 ExtensionAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; |
| 81 |
| 82 ExtensionAttribute.prototype.handleMutation = function(oldValue, newValue) { |
| 83 this.setValueIgnoreMutation(oldValue); |
| 84 } |
| 85 |
| 71 // Attribute that handles the location and navigation of the extensionview. | 86 // Attribute that handles the location and navigation of the extensionview. |
| 72 function SrcAttribute(extensionViewImpl) { | 87 function SrcAttribute(extensionViewImpl) { |
| 73 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC, | 88 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC, |
| 74 extensionViewImpl); | 89 extensionViewImpl); |
| 75 this.setupMutationObserver(); | 90 this.setupMutationObserver(); |
| 76 this.beforeFirstNavigation = true; | |
| 77 } | 91 } |
| 78 | 92 |
| 79 SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; | 93 SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; |
| 80 | 94 |
| 81 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { | 95 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { |
| 82 this.observer.takeRecords(); | 96 this.observer.takeRecords(); |
| 83 ExtensionViewAttribute.prototype.setValueIgnoreMutation.call(this, value); | 97 ExtensionViewAttribute.prototype.setValueIgnoreMutation.call(this, value); |
| 84 } | 98 } |
| 85 | 99 |
| 86 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { | 100 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 108 attributeOldValue: true, | 122 attributeOldValue: true, |
| 109 attributeFilter: [this.name] | 123 attributeFilter: [this.name] |
| 110 }; | 124 }; |
| 111 this.observer.observe(this.extensionViewImpl.element, params); | 125 this.observer.observe(this.extensionViewImpl.element, params); |
| 112 }; | 126 }; |
| 113 | 127 |
| 114 SrcAttribute.prototype.parse = function() { | 128 SrcAttribute.prototype.parse = function() { |
| 115 if (!this.extensionViewImpl.elementAttached || !this.getValue()) | 129 if (!this.extensionViewImpl.elementAttached || !this.getValue()) |
| 116 return; | 130 return; |
| 117 | 131 |
| 118 if (!this.extensionViewImpl.guest.getId()) { | 132 if (!this.extensionViewImpl.guest.getId()) |
| 119 if (this.beforeFirstNavigation) { | |
| 120 this.beforeFirstNavigation = false; | |
| 121 this.extensionViewImpl.createGuest(); | |
| 122 } | |
| 123 return; | 133 return; |
| 124 } | |
| 125 | 134 |
| 126 ExtensionViewInternal.navigate(this.extensionViewImpl.guest.getId(), | 135 ExtensionViewInternal.navigate(this.extensionViewImpl.guest.getId(), |
| 127 this.getValue()); | 136 this.getValue()); |
| 128 }; | 137 }; |
| 129 | 138 |
| 130 SrcAttribute.prototype.reset = function() { | |
| 131 this.beforeFirstNavigation = true; | |
| 132 }; | |
| 133 | |
| 134 // ----------------------------------------------------------------------------- | 139 // ----------------------------------------------------------------------------- |
| 135 | 140 |
| 136 // Sets up all of the extensionview attributes. | 141 // Sets up all of the extensionview attributes. |
| 137 ExtensionViewImpl.prototype.setupExtensionViewAttributes = function() { | 142 ExtensionViewImpl.prototype.setupExtensionViewAttributes = function() { |
| 138 this.attributes = {}; | 143 this.attributes = {}; |
| 144 this.attributes[ExtensionViewConstants.ATTRIBUTE_EXTENSION] = |
| 145 new ExtensionAttribute(this); |
| 139 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] = | 146 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] = |
| 140 new SrcAttribute(this); | 147 new SrcAttribute(this); |
| 141 }; | 148 }; |
| OLD | NEW |