Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7557)

Unified Diff: chrome/renderer/resources/extensions/extension_options.js

Issue 618823002: GuestView: Move lifetime management out of content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix extensionoptions cleanup Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};

Powered by Google App Engine
This is Rietveld 408576698