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

Unified Diff: extensions/renderer/resources/guest_view/guest_view_container.js

Issue 1165773004: Extract the element implementation logic to function mods in <webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@qui
Patch Set: sync @tott Created 5 years, 6 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: extensions/renderer/resources/guest_view/guest_view_container.js
diff --git a/extensions/renderer/resources/guest_view/guest_view_container.js b/extensions/renderer/resources/guest_view/guest_view_container.js
index 60b133267e291c851cb68ba2295b829c5bdb9b9f..91fe71c93d7ae4630b81c89dc3684094265843cb 100644
--- a/extensions/renderer/resources/guest_view/guest_view_container.js
+++ b/extensions/renderer/resources/guest_view/guest_view_container.js
@@ -23,10 +23,10 @@ function GuestViewContainer(element, viewType) {
this.guest = new GuestView(viewType);
this.setupAttributes();
- privates(this).browserPluginElement = this.createBrowserPluginElement();
+ privates(this).internalElement = this.createInternalElement$();
this.setupFocusPropagation();
var shadowRoot = this.element.createShadowRoot();
- shadowRoot.appendChild(privates(this).browserPluginElement);
+ shadowRoot.appendChild(privates(this).internalElement);
GuestViewInternalNatives.RegisterView(this.viewInstanceId, this);
}
@@ -52,8 +52,7 @@ GuestViewContainer.registerElement = function(guestViewContainerType) {
if (document.readyState == 'loading')
return;
- registerBrowserPluginElement(
- guestViewContainerType.VIEW_TYPE.toLowerCase());
+ registerInternalElement(guestViewContainerType.VIEW_TYPE.toLowerCase());
registerGuestViewElement(guestViewContainerType);
window.removeEventListener(event.type, listener, useCapture);
}, useCapture);
@@ -85,7 +84,7 @@ GuestViewContainer.prototype.setupGuestProperty = function() {
});
};
-GuestViewContainer.prototype.createBrowserPluginElement = function() {
+GuestViewContainer.prototype.createInternalElement$ = function() {
// We create BrowserPlugin as a custom element in order to observe changes
// to attributes synchronously.
var browserPluginElement =
@@ -104,15 +103,15 @@ GuestViewContainer.prototype.setupFocusPropagation = function() {
}
this.element.addEventListener('focus', this.weakWrapper(function(e) {
// Focus the BrowserPlugin when the GuestViewContainer takes focus.
- privates(this).browserPluginElement.focus();
+ privates(this).internalElement.focus();
}));
this.element.addEventListener('blur', this.weakWrapper(function(e) {
// Blur the BrowserPlugin when the GuestViewContainer loses focus.
- privates(this).browserPluginElement.blur();
+ privates(this).internalElement.blur();
}));
};
-GuestViewContainer.prototype.attachWindow = function() {
+GuestViewContainer.prototype.attachWindow$ = function() {
if (!this.internalInstanceId) {
return true;
}
@@ -129,24 +128,28 @@ GuestViewContainer.prototype.makeGCOwnContainer = function(internalInstanceId) {
}, -1);
};
-GuestViewContainer.prototype.handleBrowserPluginAttributeMutation =
- function(name, oldValue, newValue) {
- if (name == 'internalinstanceid' && !oldValue && !!newValue) {
- privates(this).browserPluginElement.removeAttribute('internalinstanceid');
- this.internalInstanceId = parseInt(newValue);
+GuestViewContainer.prototype.onInternalInstanceId = function(
+ internalInstanceId) {
+ this.internalInstanceId = internalInstanceId;
+ this.makeGCOwnContainer(this.internalInstanceId);
- this.makeGCOwnContainer(this.internalInstanceId);
+ // Track when the element resizes using the element resize callback.
+ GuestViewInternalNatives.RegisterElementResizeCallback(
+ this.internalInstanceId, this.weakWrapper(this.onElementResize));
- // Track when the element resizes using the element resize callback.
- GuestViewInternalNatives.RegisterElementResizeCallback(
- this.internalInstanceId, this.weakWrapper(this.onElementResize));
+ if (!this.guest.getId()) {
+ return;
+ }
+ this.guest.attach(this.internalInstanceId,
+ this.viewInstanceId,
+ this.buildParams());
+};
- if (!this.guest.getId()) {
- return;
- }
- this.guest.attach(this.internalInstanceId,
- this.viewInstanceId,
- this.buildParams());
+GuestViewContainer.prototype.handleInternalElementAttributeMutation =
+ function(name, oldValue, newValue) {
+ if (name == 'internalinstanceid' && !oldValue && !!newValue) {
+ privates(this).internalElement.removeAttribute('internalinstanceid');
+ this.onInternalInstanceId(parseInt(newValue));
}
};
@@ -196,7 +199,7 @@ GuestViewContainer.prototype.setupAttributes = function() {};
// Registers the browser plugin <object> custom element. |viewType| is the
// name of the specific guestview container (e.g. 'webview').
-function registerBrowserPluginElement(viewType) {
+function registerInternalElement(viewType) {
var proto = $Object.create(HTMLElement.prototype);
proto.createdCallback = function() {
@@ -216,7 +219,7 @@ function registerBrowserPluginElement(viewType) {
if (!internal) {
return;
}
- internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue);
+ internal.handleInternalElementAttributeMutation(name, oldValue, newValue);
};
GuestViewContainer[viewType + 'BrowserPlugin'] =
« no previous file with comments | « extensions/renderer/resources/guest_view/guest_view.js ('k') | extensions/renderer/resources/guest_view/guest_view_iframe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698