Chromium Code Reviews| Index: extensions/renderer/resources/guest_view/extension_view.js |
| diff --git a/extensions/renderer/resources/guest_view/extension_view.js b/extensions/renderer/resources/guest_view/extension_view.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2023e2c153f350e1a929a4bc3ed495e29c011e61 |
| --- /dev/null |
| +++ b/extensions/renderer/resources/guest_view/extension_view.js |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This module implements the ExtensionView <extensionview>. |
| + |
| +var GuestViewContainer = require('guestViewContainer').GuestViewContainer; |
| +var ExtensionViewConstants = |
| + require('extensionViewConstants').ExtensionViewConstants; |
| +var ExtensionViewInternal = |
| + require('extensionViewInternal').ExtensionViewInternal; |
| + |
| +function ExtensionViewImpl(extensionviewElement) { |
| + GuestViewContainer.call(this, extensionviewElement, 'extensionview'); |
| + this.createGuest(); |
|
Fady Samuel
2015/01/26 12:52:02
This means you create the guest as soon as you cre
apacible
2015/01/26 22:12:33
Done.
|
| + this.setupExtensionViewAttributes(); |
| +} |
| + |
| +ExtensionViewImpl.prototype.__proto__ = GuestViewContainer.prototype; |
| + |
| +ExtensionViewImpl.VIEW_TYPE = 'ExtensionView'; |
| + |
| +ExtensionViewImpl.setupElement = function(proto) { |
| + var apiMethods = [ |
| + 'navigate' |
| + ]; |
| + |
| + GuestViewContainer.forwardApiMethods(proto, apiMethods); |
| +}; |
| + |
| +ExtensionViewImpl.prototype.createGuest = function() { |
| + var params = { |
| + 'src': this.element.src |
| + }; |
| + |
| + this.guest.create(params, function() { |
|
Fady Samuel
2015/01/26 12:52:02
Use buildParams() which calls buildContainerParams
apacible
2015/01/26 22:12:33
Done.
|
| + this.attachWindow(); |
| + }.bind(this)); |
| +}; |
| + |
| +ExtensionViewImpl.prototype.onElementAttached = function() { |
| + this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC].parse(); |
| +}; |
| + |
| +ExtensionViewImpl.prototype.buildAttachParams = function() { |
|
Fady Samuel
2015/01/26 12:52:02
Use buildContainerParams now. Also, given you have
apacible
2015/01/26 22:12:33
Done.
|
| + var params = { |
| + 'src': this.element.src |
| + }; |
| + |
| + return params; |
| +}; |
| + |
| +// This observer monitors mutations to attributes of the <extensionview>. |
| +ExtensionViewImpl.prototype.handleAttributeMutation = function( |
| + attributeName, oldValue, newValue) { |
| + if (!this.attributes[attributeName] || |
| + this.attributes[attributeName].ignoreMutation) { |
|
Fady Samuel
2015/01/26 12:52:02
I'd move this ignoreMutation check into SrcAttribu
apacible
2015/01/26 22:12:33
Done.
|
| + return; |
| + } |
| + |
| + // Let the changed attribute handle its own mutation; |
| + this.attributes[attributeName].handleMutation(oldValue, newValue); |
| +}; |
| + |
| +ExtensionViewImpl.prototype.onElementDetached = function() { |
|
Fady Samuel
2015/01/26 12:52:02
I believe the default behavior in GuestViewContain
apacible
2015/01/26 22:12:33
Keeping since I'm added to onElementDetached.
|
| + this.guest.destroy(); |
| +}; |
| + |
| +GuestViewContainer.registerElement(ExtensionViewImpl); |
| + |
| +// Exports. |
| +exports.ExtensionViewImpl = ExtensionViewImpl; |