OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This module implements the ExtensionView <extensionview>. |
| 6 |
| 7 var GuestViewContainer = require('guestViewContainer').GuestViewContainer; |
| 8 var ExtensionViewConstants = |
| 9 require('extensionViewConstants').ExtensionViewConstants; |
| 10 var ExtensionViewInternal = |
| 11 require('extensionViewInternal').ExtensionViewInternal; |
| 12 |
| 13 function ExtensionViewImpl(extensionviewElement) { |
| 14 GuestViewContainer.call(this, extensionviewElement, 'extensionview'); |
| 15 this.setupExtensionViewAttributes(); |
| 16 } |
| 17 |
| 18 ExtensionViewImpl.prototype.__proto__ = GuestViewContainer.prototype; |
| 19 |
| 20 ExtensionViewImpl.VIEW_TYPE = 'ExtensionView'; |
| 21 |
| 22 ExtensionViewImpl.setupElement = function(proto) { |
| 23 var apiMethods = [ |
| 24 'navigate' |
| 25 ]; |
| 26 |
| 27 GuestViewContainer.forwardApiMethods(proto, apiMethods); |
| 28 }; |
| 29 |
| 30 ExtensionViewImpl.prototype.createGuest = function() { |
| 31 this.guest.create(this.buildParams(), function() { |
| 32 this.attachWindow(); |
| 33 }.bind(this)); |
| 34 }; |
| 35 |
| 36 ExtensionViewImpl.prototype.onElementAttached = function() { |
| 37 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC].parse(); |
| 38 }; |
| 39 |
| 40 ExtensionViewImpl.prototype.buildContainerParams = function() { |
| 41 var params = {}; |
| 42 for (var i in this.attributes) { |
| 43 params[i] = this.attributes[i].getValue(); |
| 44 } |
| 45 return params; |
| 46 }; |
| 47 |
| 48 // This observer monitors mutations to attributes of the <extensionview>. |
| 49 ExtensionViewImpl.prototype.handleAttributeMutation = function( |
| 50 attributeName, oldValue, newValue) { |
| 51 if (!this.attributes[attributeName]) |
| 52 return; |
| 53 |
| 54 // Let the changed attribute handle its own mutation; |
| 55 this.attributes[attributeName].handleMutation(oldValue, newValue); |
| 56 }; |
| 57 |
| 58 ExtensionViewImpl.prototype.onElementDetached = function() { |
| 59 this.guest.destroy(); |
| 60 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC].reset(); |
| 61 }; |
| 62 |
| 63 GuestViewContainer.registerElement(ExtensionViewImpl); |
| 64 |
| 65 // Exports. |
| 66 exports.ExtensionViewImpl = ExtensionViewImpl; |
OLD | NEW |