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 attributes of the <extensionview> tag.
7 var GuestViewAttributes = require('guestViewAttributes').GuestViewAttributes;
8 var ExtensionViewConstants =
9 require('extensionViewConstants').ExtensionViewConstants;
10 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl;
11 var ExtensionViewInternal =
12 require('extensionViewInternal').ExtensionViewInternal;
14 // -----------------------------------------------------------------------------
15 // ExtensionAttribute object.
17 // Attribute that handles extension binded to the extensionview.
18 function ExtensionAttribute(view) {
19 GuestViewAttributes.ReadOnlyAttribute.call(
20 this, ExtensionViewConstants.ATTRIBUTE_EXTENSION, view);
23 ExtensionAttribute.prototype.__proto__ =
24 GuestViewAttributes.ReadOnlyAttribute.prototype;
26 // -----------------------------------------------------------------------------
27 // SrcAttribute object.
29 // Attribute that handles the location and navigation of the extensionview.
30 function SrcAttribute(view) {
31 GuestViewAttributes.Attribute.call(
32 this, ExtensionViewConstants.ATTRIBUTE_SRC, view);
35 SrcAttribute.prototype.__proto__ = GuestViewAttributes.Attribute.prototype;
37 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
38 if (!newValue && oldValue) {
39 this.setValueIgnoreMutation(oldValue);
45 SrcAttribute.prototype.parse = function() {
46 if (!this.view.elementAttached || !this.getValue() ||
47 !this.view.guest.getId()) {
51 ExtensionViewInternal.navigate(this.view.guest.getId(), this.getValue());
54 // -----------------------------------------------------------------------------
56 // Sets up all of the extensionview attributes.
57 ExtensionViewImpl.prototype.setupAttributes = function() {
58 this.attributes[ExtensionViewConstants.ATTRIBUTE_EXTENSION] =
59 new ExtensionAttribute(this);
60 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] =
61 new SrcAttribute(this);