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