Add the ability to code generated prepopulated static nested structs
[chromium-blink-merge.git] / extensions / renderer / resources / guest_view / extension_options / extension_options_attributes.js
blob5206f1dc71346c8082b515fde7b5f038b390b929
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 <extensionoptions> tag.
7 var GuestViewAttributes = require('guestViewAttributes').GuestViewAttributes;
8 var ExtensionOptionsConstants =
9     require('extensionOptionsConstants').ExtensionOptionsConstants;
10 var ExtensionOptionsImpl = require('extensionOptions').ExtensionOptionsImpl;
12 // -----------------------------------------------------------------------------
13 // ExtensionAttribute object.
15 // Attribute that handles extension binded to the extensionoptions.
16 function ExtensionAttribute(view) {
17   GuestViewAttributes.Attribute.call(
18       this, ExtensionOptionsConstants.ATTRIBUTE_EXTENSION, view);
21 ExtensionAttribute.prototype.__proto__ =
22     GuestViewAttributes.Attribute.prototype;
24 ExtensionAttribute.prototype.handleMutation = function(oldValue, newValue) {
25   // Once this attribute has been set, it cannot be unset.
26   if (!newValue && oldValue) {
27     this.setValueIgnoreMutation(oldValue);
28     return;
29   }
31   if (!newValue || !this.elementAttached)
32     return;
34   this.view.createGuest();
37 // -----------------------------------------------------------------------------
39 // Sets up all of the extensionoptions attributes.
40 ExtensionOptionsImpl.prototype.setupAttributes = function() {
41   this.attributes[ExtensionOptionsConstants.ATTRIBUTE_EXTENSION] =
42       new ExtensionAttribute(this);