Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var DocumentNatives = requireNative('document_natives'); | 5 var DocumentNatives = requireNative('document_natives'); |
| 6 var ExtensionOptionsEvents = | 6 var ExtensionOptionsEvents = |
| 7 require('extensionOptionsEvents').ExtensionOptionsEvents; | 7 require('extensionOptionsEvents').ExtensionOptionsEvents; |
| 8 var GuestViewInternal = | 8 var GuestViewInternal = |
| 9 require('binding').Binding.create('guestViewInternal').generate(); | 9 require('binding').Binding.create('guestViewInternal').generate(); |
| 10 var IdGenerator = requireNative('id_generator'); | 10 var IdGenerator = requireNative('id_generator'); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 if (this.initCalled) | 127 if (this.initCalled) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 this.initCalled = true; | 130 this.initCalled = true; |
| 131 this.browserPluginNode = this.createBrowserPluginNode(); | 131 this.browserPluginNode = this.createBrowserPluginNode(); |
| 132 var shadowRoot = this.extensionoptionsNode.createShadowRoot(); | 132 var shadowRoot = this.extensionoptionsNode.createShadowRoot(); |
| 133 shadowRoot.appendChild(this.browserPluginNode); | 133 shadowRoot.appendChild(this.browserPluginNode); |
| 134 this.createGuest(); | 134 this.createGuest(); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 ExtensionOptionsInternal.prototype.onSizeChanged = function(width, height) { | 137 ExtensionOptionsInternal.prototype.onSizeChanged = |
| 138 this.browserPluginNode.style.width = width + 'px'; | 138 function(newWidth, newHeight, oldWidth, oldHeight) { |
| 139 this.browserPluginNode.style.height = height + 'px'; | 139 // When this method is called, the sizechanged event on the external |
| 140 // ExtensionOptions object is fired at the same time. This timeout allows | |
| 141 // the embedder WebUI overlay to perform resizing animations before the | |
| 142 // guest view resizes. | |
| 143 var animationTime = 0.25 * Math.sqrt( | |
|
not at google - send to devlin
2014/08/19 17:02:48
Why is there animation code inside the extension_o
ericzeng
2014/08/19 18:20:13
I need a way to delay <extensionoptions> from auto
not at google - send to devlin
2014/08/19 19:27:18
Ah I see. It's still unfortunately specific to be
| |
| 144 Math.pow(newWidth - oldWidth, 2) + | |
| 145 Math.pow(newHeight - oldHeight, 2)); | |
| 146 setTimeout(function() { | |
| 147 this.browserPluginNode.style.width = newWidth + 'px'; | |
| 148 this.browserPluginNode.style.height = newHeight + 'px'; | |
| 149 | |
| 150 // Do not allow the options page's dimensions to shrink so that the options | |
| 151 // page has a consistent UI. If the new size is larger than the minimum, | |
| 152 // make that the new minimum size. | |
| 153 if (newWidth > this.minwidth) | |
| 154 this.minwidth = newWidth; | |
| 155 if (newHeight > this.minheight) | |
| 156 this.minheight = newHeight; | |
| 157 | |
| 158 GuestViewInternal.setAutoSize(this.instanceId, { | |
| 159 'enableAutoSize': this.extensionoptionsNode.hasAttribute('autosize'), | |
| 160 'min': { | |
| 161 'width': parseInt(this.minwidth || 0), | |
| 162 'height': parseInt(this.minheight || 0) | |
| 163 }, | |
| 164 'max': { | |
| 165 'width': parseInt(this.maxwidth || 0), | |
| 166 'height': parseInt(this.maxheight || 0) | |
| 167 } | |
| 168 }); | |
| 169 }.bind(this), animationTime); | |
| 140 }; | 170 }; |
| 141 | 171 |
| 142 ExtensionOptionsInternal.prototype.parseExtensionAttribute = function() { | 172 ExtensionOptionsInternal.prototype.parseExtensionAttribute = function() { |
| 143 if (this.extensionoptionsNode.hasAttribute('extension')) { | 173 if (this.extensionoptionsNode.hasAttribute('extension')) { |
| 144 this.extensionId = this.extensionoptionsNode.getAttribute('extension'); | 174 this.extensionId = this.extensionoptionsNode.getAttribute('extension'); |
| 145 return true; | 175 return true; |
| 146 } | 176 } |
| 147 return false; | 177 return false; |
| 148 }; | 178 }; |
| 149 | 179 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 | 294 |
| 265 var useCapture = true; | 295 var useCapture = true; |
| 266 window.addEventListener('readystatechange', function listener(event) { | 296 window.addEventListener('readystatechange', function listener(event) { |
| 267 if (document.readyState == 'loading') | 297 if (document.readyState == 'loading') |
| 268 return; | 298 return; |
| 269 | 299 |
| 270 registerBrowserPluginElement(); | 300 registerBrowserPluginElement(); |
| 271 registerExtensionOptionsElement(); | 301 registerExtensionOptionsElement(); |
| 272 window.removeEventListener(event.type, listener, useCapture); | 302 window.removeEventListener(event.type, listener, useCapture); |
| 273 }, useCapture); | 303 }, useCapture); |
| OLD | NEW |