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 854b550e19a1040efe2408a71a5bef43eec361a7..dfa5acea01afb530d1c9d3fd68ddef043f68e965 100644 |
--- a/chrome/renderer/resources/extensions/extension_options.js |
+++ b/chrome/renderer/resources/extensions/extension_options.js |
@@ -24,6 +24,11 @@ function ExtensionOptionsInternal(extensionoptionsNode) { |
this.extensionoptionsNode = extensionoptionsNode; |
this.viewInstanceId = IdGenerator.GetNextId(); |
+ // Flag that is set when attempting the attach the guest view, but <object> |
+ // bindings are not available. When the bindings become available, the |
+ // attaching will resume. |
+ this.deferredAttachState = false; |
+ |
// on* Event handlers. |
this.eventHandlers = {}; |
@@ -32,27 +37,34 @@ function ExtensionOptionsInternal(extensionoptionsNode) { |
// the event is fired from here instead of through |
// extension_options_events.js. |
this.setupEventProperty('createfailed'); |
- |
new ExtensionOptionsEvents(this, this.viewInstanceId); |
this.setupNodeProperties(); |
- |
if (this.parseExtensionAttribute()) |
this.init(); |
}; |
ExtensionOptionsInternal.prototype.attachWindow = function(instanceId) { |
this.instanceId = instanceId; |
- var params = { |
+ if (!this.hasBindings()) { |
+ this.deferredAttachState = true; |
+ return false; |
+ } |
+ |
+ var params = this.buildAttachParams(); |
+ return this.browserPluginNode['-internal-attach'](instanceId, params); |
+}; |
+ |
+ExtensionOptionsInternal.prototype.buildAttachParams = function() { |
+ return { |
'autosize': this.autosize, |
'instanceId': this.viewInstanceId, |
'maxheight': parseInt(this.maxheight || 0), |
'maxwidth': parseInt(this.maxwidth || 0), |
'minheight': parseInt(this.minheight || 0), |
'minwidth': parseInt(this.minwidth || 0) |
- } |
- return this.browserPluginNode['-internal-attach'](instanceId, params); |
-}; |
+ }; |
+} |
ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() { |
var browserPluginNode = new ExtensionOptionsInternal.BrowserPlugin(); |
@@ -123,6 +135,32 @@ ExtensionOptionsInternal.prototype.handleExtensionOptionsAttributeMutation = |
} |
}; |
+ExtensionOptionsInternal.prototype.handleBrowserPluginAttributeMutation = |
+ function(name, oldValue, newValue) { |
+ if (name == 'internalbindings' && !oldValue && newValue) { |
not at google - send to devlin
2014/08/12 19:58:29
I guess that 'internalbindings' is some magical th
Fady Samuel
2014/08/12 21:36:39
internalbindings is a browserplugin attribute that
|
+ this.browserPluginNode.removeAttribute('internalbindings'); |
+ |
+ if (this.deferredAttachState) { |
+ // A setTimeout is necessary for the binding to be initialized properly. |
+ window.setTimeout(function() { |
+ if (this.hasBindings()) { |
+ var params = this.buildAttachParams(); |
+ this.browserPluginNode['-internal-attach'](this.instanceId, params); |
+ this.deferredAttachState = false; |
+ } else { |
+ } |
not at google - send to devlin
2014/08/12 19:58:29
Empty else block?
|
+ }.bind(this), 0); |
+ } |
+ return; |
+ } |
+}; |
+ |
+// Returns true if Browser Plugin bindings is available. |
+// Bindings are unavailable if <object> is not in the render tree. |
+ExtensionOptionsInternal.prototype.hasBindings = function() { |
+ return 'function' == typeof this.browserPluginNode['-internal-attach']; |
not at google - send to devlin
2014/08/12 19:58:29
No yoda condition preferably.
Though I find this
ericzeng
2014/08/12 21:53:33
I'm not very happy with the whole flow of the scri
|
+}; |
+ |
ExtensionOptionsInternal.prototype.init = function() { |
if (this.initCalled) |
return; |
@@ -223,6 +261,14 @@ function registerBrowserPluginElement() { |
this.style.height = '100%'; |
}; |
+ proto.attributeChangedCallback = function(name, oldValue, newValue) { |
+ var internal = privates(this).internal; |
+ if (!internal) { |
+ return; |
+ } |
+ internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); |
+ }; |
+ |
proto.attachedCallback = function() { |
// Load the plugin immediately. |
var unused = this.nonExistentAttribute; |
@@ -230,7 +276,7 @@ function registerBrowserPluginElement() { |
ExtensionOptionsInternal.BrowserPlugin = |
DocumentNatives.RegisterElement('extensionoptionsplugin', |
- {extends: 'object', prototype: proto}); |
+ {extends: 'object', prototype: proto}); |
delete proto.createdCallback; |
delete proto.attachedCallback; |
delete proto.detachedCallback; |