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

Unified Diff: chrome/renderer/resources/extensions/app_view.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/app_view.js
diff --git a/chrome/renderer/resources/extensions/app_view.js b/chrome/renderer/resources/extensions/app_view.js
index 968340b1f46a79271c6d924ffbe0680394507d3a..2cadb5933d62bbfe1bdfc2f6c4e30039d8c9681c 100644
--- a/chrome/renderer/resources/extensions/app_view.js
+++ b/chrome/renderer/resources/extensions/app_view.js
@@ -70,16 +70,45 @@ AppViewInternal.prototype.connect = function(app, data, callback) {
AppViewInternal.prototype.attachWindow = function(guestInstanceId) {
this.guestInstanceId = guestInstanceId;
+ if (!this.internalInstanceId) {
+ return;
+ }
var params = {
- 'instanceId': this.viewInstanceId,
+ 'instanceId': this.viewInstanceId
};
this.browserPluginNode.style.visibility = 'visible';
return guestViewInternalNatives.AttachGuest(
- parseInt(this.browserPluginNode.getAttribute('internalinstanceid')),
+ this.internalInstanceId,
guestInstanceId,
params);
};
+AppViewInternal.prototype.handleBrowserPluginAttributeMutation =
+ function(name, oldValue, newValue) {
+ if (name == 'internalinstanceid' && !oldValue && !!newValue) {
+ this.browserPluginNode.removeAttribute('internalinstanceid');
+ this.internalInstanceId = parseInt(newValue);
+
+ if (!!this.guestInstanceId && this.guestInstanceId != 0) {
+ var params = {
+ 'instanceId': this.viewInstanceId
+ };
+ guestViewInternalNatives.AttachGuest(
+ this.internalInstanceId,
+ this.guestInstanceId,
+ params);
+ }
+ return;
+ }
+};
+
+AppViewInternal.prototype.reset = function() {
+ if (this.guestInstanceId) {
+ GuestViewInternal.destroyGuest(this.guestInstanceId);
+ this.guestInstanceId = undefined;
+ }
+};
+
function registerBrowserPluginElement() {
var proto = Object.create(HTMLObjectElement.prototype);
@@ -94,6 +123,14 @@ function registerBrowserPluginElement() {
var unused = this.nonExistentAttribute;
};
+ proto.attributeChangedCallback = function(name, oldValue, newValue) {
+ var internal = privates(this).internal;
+ if (!internal) {
+ return;
+ }
+ internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue);
+ };
+
AppViewInternal.BrowserPlugin =
DocumentNatives.RegisterElement('appplugin', {extends: 'object',
prototype: proto});
@@ -111,10 +148,19 @@ function registerAppViewElement() {
new AppViewInternal(this);
};
+ proto.detachedCallback = function() {
+ var internal = privates(this).internal;
+ if (!internal) {
+ return;
+ }
+ internal.reset();
+ };
+
proto.connect = function() {
var internal = privates(this).internal;
$Function.apply(internal.connect, internal, arguments);
}
+
window.AppView =
DocumentNatives.RegisterElement('appview', {prototype: proto});

Powered by Google App Engine
This is Rietveld 408576698