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.
5 // This module implements the ExtensionView <extensionview>.
7 var GuestViewContainer = require('guestViewContainer').GuestViewContainer;
8 var ExtensionViewConstants =
9 require('extensionViewConstants').ExtensionViewConstants;
10 var ExtensionViewEvents = require('extensionViewEvents').ExtensionViewEvents;
11 var ExtensionViewInternal =
12 require('extensionViewInternal').ExtensionViewInternal;
14 function ExtensionViewImpl(extensionviewElement) {
15 GuestViewContainer.call(this, extensionviewElement, 'extensionview');
16 this.setupExtensionViewAttributes();
18 new ExtensionViewEvents(this, this.viewInstanceId);
21 ExtensionViewImpl.prototype.__proto__ = GuestViewContainer.prototype;
23 ExtensionViewImpl.VIEW_TYPE = 'ExtensionView';
25 ExtensionViewImpl.setupElement = function(proto) {
26 var apiMethods = ExtensionViewImpl.getApiMethods();
28 GuestViewContainer.forwardApiMethods(proto, apiMethods);
31 ExtensionViewImpl.prototype.createGuest = function() {
32 this.guest.create(this.buildParams(), function() {
37 ExtensionViewImpl.prototype.buildContainerParams = function() {
39 for (var i in this.attributes) {
40 params[i] = this.attributes[i].getValue();
45 // This observer monitors mutations to attributes of the <extensionview>.
46 ExtensionViewImpl.prototype.handleAttributeMutation = function(
47 attributeName, oldValue, newValue) {
48 if (!this.attributes[attributeName])
51 // Let the changed attribute handle its own mutation.
52 this.attributes[attributeName].maybeHandleMutation(oldValue, newValue);
55 ExtensionViewImpl.prototype.onElementDetached = function() {
58 // Reset all attributes.
59 for (var i in this.attributes) {
60 this.attributes[i].reset();
64 // Updates src upon loadcommit.
65 ExtensionViewImpl.prototype.onLoadCommit = function(url) {
66 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC].
67 setValueIgnoreMutation(url);
70 GuestViewContainer.registerElement(ExtensionViewImpl);
73 exports.ExtensionViewImpl = ExtensionViewImpl;