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..51fc7d1bf84721f5be04fcd5c9c397f39fc75dcd 100644 |
| --- a/chrome/renderer/resources/extensions/extension_options.js |
| +++ b/chrome/renderer/resources/extensions/extension_options.js |
| @@ -9,6 +9,18 @@ var GuestViewInternal = |
| require('binding').Binding.create('guestViewInternal').generate(); |
| var IdGenerator = requireNative('id_generator'); |
| +var EXTENSION_OPTIONS_ATTRIBUTE_MAXHEIGHT = 'maxheight'; |
|
not at google - send to devlin
2014/07/30 17:44:57
just inline each of these?
|
| +var EXTENSION_OPTIONS_ATTRIBUTE_MAXWIDTH = 'maxwidth'; |
| +var EXTENSION_OPTIONS_ATTRIBUTE_MINHEIGHT = 'minheight'; |
| +var EXTENSION_OPTIONS_ATTRIBUTE_MINWIDTH = 'minwidth'; |
| + |
| +var EXTENSION_OPTIONS_ATTRIBUTES = [ |
| + EXTENSION_OPTIONS_ATTRIBUTE_MAXHEIGHT, |
|
not at google - send to devlin
2014/07/30 17:44:57
can this be a map of name --> default value (poten
ericzeng
2014/07/30 23:29:26
Done.
|
| + EXTENSION_OPTIONS_ATTRIBUTE_MAXWIDTH, |
| + EXTENSION_OPTIONS_ATTRIBUTE_MINHEIGHT, |
| + EXTENSION_OPTIONS_ATTRIBUTE_MINWIDTH |
| +]; |
| + |
| function ExtensionOptionsInternal(extensionoptionsNode) { |
| privates(extensionoptionsNode).internal = this; |
| this.extensionoptionsNode = extensionoptionsNode; |
| @@ -34,7 +46,20 @@ ExtensionOptionsInternal.prototype.attachWindow = function(instanceId) { |
| ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() { |
| var browserPluginNode = new ExtensionOptionsInternal.BrowserPlugin(); |
| + browserPluginNode.setAttribute('autosize', 'on'); |
| + browserPluginNode.setAttribute('minwidth', 80); |
| + browserPluginNode.setAttribute('minheight', 30); |
| privates(browserPluginNode).internal = this; |
| + |
| + $Array.forEach(EXTENSION_OPTIONS_ATTRIBUTES, function(attributeName) { |
| + // Only copy attributes that have been assigned values, rather than copying |
| + // a series of undefined attributes to BrowserPlugin. |
| + if (this.extensionoptionsNode.hasAttribute(attributeName)) { |
| + browserPluginNode.setAttribute( |
| + attributeName, this.extensionoptionsNode.getAttribute(attributeName)); |
|
not at google - send to devlin
2014/07/30 17:44:57
indentation += 2
ericzeng
2014/07/30 23:29:26
Done.
|
| + } |
| + }, this); |
| + |
| return browserPluginNode; |
| }; |
| @@ -62,8 +87,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 +94,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 +123,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 +164,30 @@ ExtensionOptionsInternal.prototype.setupEventProperty = function(eventName) { |
| }; |
| ExtensionOptionsInternal.prototype.setupNodeProperties = function() { |
| + $Array.forEach(EXTENSION_OPTIONS_ATTRIBUTES, function(attributeName) { |
| + Object.defineProperty(this.extensionoptionsNode, attributeName, { |
| + get: function() { |
| + if (this.browserPluginNode.hasOwnProperty(attributeName)) { |
| + return this.browserPluginNode[attributeName]; |
| + } else { |
|
not at google - send to devlin
2014/07/30 17:44:57
no else after return.
ericzeng
2014/07/30 23:29:26
Done.
|
| + 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; |