Chromium Code Reviews| Index: chrome/renderer/resources/extensions/extension_options.js |
| diff --git a/chrome/renderer/resources/extensions/extension_options.js b/chrome/renderer/resources/extensions/extension_options.js |
| index cc42d7fb4b156bcff285dafd53e8e03a7e999bbb..df64d745ea42b6a68eb2e7f56cf4fb985e7c7d95 100644 |
| --- a/chrome/renderer/resources/extensions/extension_options.js |
| +++ b/chrome/renderer/resources/extensions/extension_options.js |
| @@ -8,6 +8,15 @@ var ExtensionOptionsEvents = |
| var GuestViewInternal = |
| require('binding').Binding.create('guestViewInternal').generate(); |
| var IdGenerator = requireNative('id_generator'); |
| +var utils = require('utils'); |
| + |
| +var EXTENSION_OPTIONS_ATTRIBUTES = { |
| + 'autosize': 'on', |
| + 'maxheight': 600, |
| + 'maxwidth': 800, |
| + 'minheight': 32, |
| + 'minwidth': 80 |
| +}; |
| function ExtensionOptionsInternal(extensionoptionsNode) { |
| privates(extensionoptionsNode).internal = this; |
| @@ -35,6 +44,16 @@ ExtensionOptionsInternal.prototype.attachWindow = function(instanceId) { |
| ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() { |
| var browserPluginNode = new ExtensionOptionsInternal.BrowserPlugin(); |
| privates(browserPluginNode).internal = this; |
| + |
| + utils.forEach(EXTENSION_OPTIONS_ATTRIBUTES, function(attributeName, value) { |
| + if (this.extensionoptionsNode.hasAttribute(attributeName)) { |
| + browserPluginNode.setAttribute( |
| + attributeName, this.extensionoptionsNode.getAttribute(attributeName)); |
| + } else { |
| + browserPluginNode.setAttribute( |
| + attributeName, EXTENSION_OPTIONS_ATTRIBUTES[attributeName]); |
|
not at google - send to devlin
2014/07/31 20:26:00
use |value| not the whole "EXTENSION_OPTIONS_ATTRI
|
| + } |
| + }, this); |
| return browserPluginNode; |
| }; |
| @@ -62,8 +81,6 @@ ExtensionOptionsInternal.prototype.dispatchEvent = |
| ExtensionOptionsInternal.prototype.handleExtensionOptionsAttributeMutation = |
| function(name, oldValue, newValue) { |
| - if (name != 'extension') |
| - return; |
| // We treat null attribute (attribute removed) and the empty string as |
| // one case. |
| oldValue = oldValue || ''; |
| @@ -71,13 +88,22 @@ ExtensionOptionsInternal.prototype.handleExtensionOptionsAttributeMutation = |
| if (oldValue === newValue) |
| return; |
| - this.extensionId = newValue; |
| - // Create new guest view if one hasn't been created for this element. |
| - if (!this.instanceId && this.parseExtensionAttribute()) |
| - this.init(); |
| - // TODO(ericzeng): Implement navigation to another guest view if we want |
| - // that functionality. |
| + if (name == 'extension') { |
| + this.extensionId = newValue; |
| + // Create new guest view if one hasn't been created for this element. |
| + if (!this.instanceId && this.parseExtensionAttribute()) |
| + this.init(); |
| + // TODO(ericzeng): Implement navigation to another guest view if we want |
| + // that functionality. |
| + return; |
| + } |
| + |
| + if (this.browserPluginNode.hasOwnProperty(name)) { |
| + this.browserPluginNode[name] = newValue; |
| + } else { |
| + this.browserPluginNode.setAttribute(name, newValue); |
| + } |
| }; |
| ExtensionOptionsInternal.prototype.init = function() { |
| @@ -91,6 +117,11 @@ ExtensionOptionsInternal.prototype.init = function() { |
| this.createGuest(); |
| }; |
| +ExtensionOptionsInternal.prototype.onSizeChanged = function(width, height) { |
| + this.browserPluginNode.style.width = width + 'px'; |
| + this.browserPluginNode.style.height = height + 'px'; |
| +}; |
| + |
| ExtensionOptionsInternal.prototype.parseExtensionAttribute = function() { |
| if (this.extensionoptionsNode.hasAttribute('extension')) { |
| var extensionId = this.extensionoptionsNode.getAttribute('extension'); |
| @@ -127,8 +158,28 @@ ExtensionOptionsInternal.prototype.setupEventProperty = function(eventName) { |
| }; |
| ExtensionOptionsInternal.prototype.setupNodeProperties = function() { |
| + utils.forEach(EXTENSION_OPTIONS_ATTRIBUTES, function(attributeName) { |
| + Object.defineProperty(this.extensionoptionsNode, attributeName, { |
| + get: function() { |
| + if (this.browserPluginNode.hasOwnProperty(attributeName)) |
| + return this.browserPluginNode[attributeName]; |
| + return this.browserPluginNode.getAttribute(attributeName); |
| + }, |
| + set: function(value) { |
| + if (this.browserPluginNode.hasOwnProperty(attributeName)) { |
| + // Give the BrowserPlugin first stab at the attribute so that it can |
| + // throw an exception if there is a problem. This attribute will then |
| + // be propagated back to the <extensionoptions>. |
| + this.browserPluginNode[attributeName] = value; |
| + } else { |
| + this.browserPluginNode.setAttribute(attributeName, value); |
| + } |
| + }, |
| + enumerable: true |
| + }); |
| + }, this); |
| + |
| var self = this; |
| - this.extensionId = this.extensionoptionsNode.getAttribute('extension'); |
| Object.defineProperty(this.extensionoptionsNode, 'extension', { |
| get: function() { |
| return self.extensionId; |