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 32bee63cbea7240e59078d8a9c838f14e1145b1e..681692d832c42cb4e1dd7e92e4c77610b72b3c84 100644 |
--- a/chrome/renderer/resources/extensions/extension_options.js |
+++ b/chrome/renderer/resources/extensions/extension_options.js |
@@ -24,6 +24,7 @@ function ExtensionOptionsInternal(extensionoptionsNode) { |
privates(extensionoptionsNode).internal = this; |
this.extensionoptionsNode = extensionoptionsNode; |
this.viewInstanceId = IdGenerator.GetNextId(); |
+ this.guestInstanceId = 0; |
this.autosizeDeferred = false; |
@@ -68,7 +69,11 @@ ExtensionOptionsInternal.prototype.createBrowserPluginNode = function() { |
return browserPluginNode; |
}; |
-ExtensionOptionsInternal.prototype.createGuest = function() { |
+ExtensionOptionsInternal.prototype.createGuestIfNecessary = function() { |
+ if (this.guestInstanceId != 0) { |
+ this.attachWindow(); |
+ return; |
+ } |
var params = { |
'extensionId': this.extensionId, |
}; |
@@ -145,7 +150,7 @@ ExtensionOptionsInternal.prototype.handleBrowserPluginAttributeMutation = |
this.internalInstanceId = parseInt(newValue); |
this.browserPluginNode.removeAttribute('internalinstanceid'); |
if (this.extensionId) |
- this.createGuest(); |
+ this.createGuestIfNecessary(); |
} |
}; |
@@ -293,6 +298,13 @@ ExtensionOptionsInternal.prototype.resumeDeferredAutoSize = function() { |
} |
}; |
+ExtensionOptionsInternal.prototype.reset = function() { |
+ if (this.guestInstanceId) { |
+ GuestViewInternal.destroyGuest(this.guestInstanceId); |
+ this.guestInstanceId = undefined; |
+ } |
+}; |
+ |
function registerBrowserPluginElement() { |
var proto = Object.create(HTMLObjectElement.prototype); |
@@ -331,10 +343,19 @@ function registerExtensionOptionsElement() { |
new ExtensionOptionsInternal(this); |
}; |
+ proto.detachedCallback = function() { |
+ var internal = privates(this).internal; |
+ if (!internal) { |
+ return; |
+ } |
+ internal.reset(); |
+ }; |
+ |
proto.attributeChangedCallback = function(name, oldValue, newValue) { |
var internal = privates(this).internal; |
- if (!internal) |
+ if (!internal) { |
return; |
+ } |
internal.handleExtensionOptionsAttributeMutation(name, oldValue, newValue); |
}; |