Chromium Code Reviews| Index: chrome/renderer/resources/extensions/web_view.js |
| diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js |
| index 3bed13beaab9d30d95ea6ed93d57b8a732cbccef..f2a798ab273c1a67335314b3841a22c813bd61b8 100644 |
| --- a/chrome/renderer/resources/extensions/web_view.js |
| +++ b/chrome/renderer/resources/extensions/web_view.js |
| @@ -19,6 +19,14 @@ var WEB_VIEW_ATTRIBUTE_MAXHEIGHT = 'maxheight'; |
| var WEB_VIEW_ATTRIBUTE_MAXWIDTH = 'maxwidth'; |
| var WEB_VIEW_ATTRIBUTE_MINHEIGHT = 'minheight'; |
| var WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth'; |
| +var AUTO_SIZE_ATTRIBUTES = [ |
| + 'autosize', |
| + WEB_VIEW_ATTRIBUTE_MAXHEIGHT, |
| + WEB_VIEW_ATTRIBUTE_MAXWIDTH, |
| + WEB_VIEW_ATTRIBUTE_MINHEIGHT, |
| + WEB_VIEW_ATTRIBUTE_MINWIDTH |
| +]; |
| + |
| var WEB_VIEW_ATTRIBUTE_PARTITION = 'partition'; |
| var PLUGIN_METHOD_ATTACH = '-internal-attach'; |
| @@ -30,11 +38,6 @@ var ERROR_MSG_INVALID_PARTITION_ATTRIBUTE = 'Invalid partition attribute.'; |
| /** @type {Array.<string>} */ |
| var WEB_VIEW_ATTRIBUTES = [ |
| 'allowtransparency', |
| - 'autosize', |
| - WEB_VIEW_ATTRIBUTE_MINHEIGHT, |
| - WEB_VIEW_ATTRIBUTE_MINWIDTH, |
| - WEB_VIEW_ATTRIBUTE_MAXHEIGHT, |
| - WEB_VIEW_ATTRIBUTE_MAXWIDTH |
| ]; |
| /** @class representing state of storage partition. */ |
| @@ -314,6 +317,22 @@ WebViewInternal.prototype.insertCSS = function(var_args) { |
| $Function.apply(WebView.insertCSS, null, args); |
| }; |
| +WebViewInternal.prototype.setupAutoSizeProperties = function() { |
| + var self = this; |
| + $Array.forEach(AUTO_SIZE_ATTRIBUTES, function(attributeName) { |
| + this[attributeName] = this.webviewNode.getAttribute(attributeName); |
| + Object.defineProperty(this.webviewNode, attributeName, { |
| + get: function() { |
| + return self[attributeName]; |
| + }, |
| + set: function(value) { |
| + self.webviewNode.setAttribute(attributeName, value); |
| + }, |
| + enumerable: true |
| + }); |
| + }, this); |
| +}; |
| + |
| /** |
| * @private |
| */ |
| @@ -322,6 +341,7 @@ WebViewInternal.prototype.setupWebviewNodeProperties = function() { |
| 'contentWindow is not available at this time. It will become available ' + |
| 'when the page has finished loading.'; |
| + this.setupAutoSizeProperties(); |
| var self = this; |
| var browserPluginNode = this.browserPluginNode; |
| // Expose getters and setters for the attributes. |
| @@ -445,7 +465,25 @@ WebViewInternal.prototype.handleWebviewAttributeMutation = |
| // a BrowserPlugin property will update the corresponding BrowserPlugin |
| // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more |
| // details. |
| - if (name == 'name') { |
| + if (AUTO_SIZE_ATTRIBUTES.indexOf(name) > -1) { |
| + this[name] = newValue; |
| + if (!this.instanceId) { |
| + return; |
| + } |
| + // Convert autosize attribute to boolean. |
| + var autosize = (this.autosize + '').toLowerCase() == 'true' ? true : false; |
|
lazyboy
2014/07/31 04:24:22
This is bad way of specifying attributes IIRC, don
Fady Samuel
2014/08/01 18:12:52
Fixed.
|
| + WebView.setAutoSize(this.instanceId, { |
| + 'enableAutoSize': autosize, |
| + 'min': { |
| + 'width': parseInt(this.minwidth || 0), |
| + 'height': parseInt(this.minheight || 0) |
| + }, |
| + 'max': { |
| + 'width': parseInt(this.maxwidth || 0), |
| + 'height': parseInt(this.maxheight || 0) |
| + } |
| + }); |
| + } else if (name == 'name') { |
| // We treat null attribute (attribute removed) and the empty string as |
| // one case. |
| oldValue = oldValue || ''; |
| @@ -783,8 +821,12 @@ WebViewInternal.prototype.getZoom = function(callback) { |
| WebViewInternal.prototype.buildAttachParams = function(isNewWindow) { |
| var params = { |
| - 'api': 'webview', |
| + 'autosize': (this.autosize + '').toLowerCase() == 'true' ? true : false, |
| 'instanceId': this.viewInstanceId, |
| + 'maxheight': parseInt(this.maxheight || 0), |
| + 'maxwidth': parseInt(this.maxwidth || 0), |
| + 'minheight': parseInt(this.minheight || 0), |
| + 'minwidth': parseInt(this.minwidth || 0), |
| 'name': this.name, |
| // We don't need to navigate new window from here. |
| 'src': isNewWindow ? undefined : this.src, |