summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorpaulmeyer <paulmeyer@chromium.org>2014-12-04 07:57:49 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-04 15:58:16 +0000
commit95e50070efbffd8a0dc0c7dc44a61d6d239216d9 (patch)
treedd1675b4c1c9457e2f227c5506ea5a468be7e0cb /chrome/renderer
parent85516e91b22b9f393335c9569330d777d567ccda (diff)
downloadchromium_src-95e50070efbffd8a0dc0c7dc44a61d6d239216d9.zip
chromium_src-95e50070efbffd8a0dc0c7dc44a61d6d239216d9.tar.gz
chromium_src-95e50070efbffd8a0dc0c7dc44a61d6d239216d9.tar.bz2
Split up creating and attaching in extensionoptions.
Both were previously done together in one function, which was different from how webview and appview work, leading to weird behavior in some cases. Also in this patch I renamed |listenForReadyStateChange()| to |registerElement()|, since the fact that the element is registered in a listener is just an implementation detail. BUG=431002, 434226 TBR=kalman@chromium.org Review URL: https://codereview.chromium.org/759873004 Cr-Commit-Position: refs/heads/master@{#306820}
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/resources/extensions/extension_options.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/chrome/renderer/resources/extensions/extension_options.js b/chrome/renderer/resources/extensions/extension_options.js
index e518e29..e0ae072 100644
--- a/chrome/renderer/resources/extensions/extension_options.js
+++ b/chrome/renderer/resources/extensions/extension_options.js
@@ -62,6 +62,11 @@ ExtensionOptionsImpl.setupElement = function(proto) {
GuestViewContainer.forwardApiMethods(proto, apiMethods);
}
+ExtensionOptionsImpl.prototype.onElementAttached = function() {
+ this.parseExtensionAttribute();
+ this.createGuest();
+}
+
ExtensionOptionsImpl.prototype.onElementDetached = function() {
this.guest.destroy();
};
@@ -87,14 +92,10 @@ ExtensionOptionsImpl.prototype.attachWindow = function() {
return true;
};
-ExtensionOptionsImpl.prototype.createGuestIfNecessary = function() {
+ExtensionOptionsImpl.prototype.createGuest = function() {
if (!this.elementAttached) {
return;
}
- if (this.guest.getId() != 0) {
- this.attachWindow();
- return;
- }
var params = {
'extensionId': this.extensionId,
};
@@ -127,7 +128,7 @@ ExtensionOptionsImpl.prototype.handleAttributeMutation =
if (oldValue === newValue)
return;
- if (name == 'extension' && !oldValue && newValue) {
+ if (name == 'extension' && !oldValue && !!newValue) {
this.extensionId = newValue;
// If the browser plugin is not ready then don't create the guest until
// it is ready (in handleBrowserPluginAttributeMutation).
@@ -136,7 +137,7 @@ ExtensionOptionsImpl.prototype.handleAttributeMutation =
// If a guest view does not exist then create one.
if (!this.guest.getId()) {
- this.createGuestIfNecessary();
+ this.createGuest();
return;
}
// TODO(ericzeng): Implement navigation to another guest view if we want
@@ -165,11 +166,12 @@ ExtensionOptionsImpl.prototype.handleAttributeMutation =
ExtensionOptionsImpl.prototype.handleBrowserPluginAttributeMutation =
function(name, oldValue, newValue) {
if (name == 'internalinstanceid' && !oldValue && !!newValue) {
- this.elementAttached = true;
this.internalInstanceId = parseInt(newValue);
this.browserPluginElement.removeAttribute('internalinstanceid');
- if (this.extensionId)
- this.createGuestIfNecessary();
+ if (!this.guest.getId() || !this.extensionId) {
+ return;
+ }
+ this.attachWindow();
}
};
@@ -316,4 +318,4 @@ ExtensionOptionsImpl.prototype.resumeDeferredAutoSize = function() {
}
};
-GuestViewContainer.listenForReadyStateChange(ExtensionOptionsImpl);
+GuestViewContainer.registerElement(ExtensionOptionsImpl);