Chromium Code Reviews| 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 cf0e309b92a0e788b047ccc48162cefd14c8049b..8e2c85c5d87f8395e538d6591720bbdbdd605db1 100644 |
| --- a/extensions/renderer/resources/guest_view/guest_view_container.js |
| +++ b/extensions/renderer/resources/guest_view/guest_view_container.js |
| @@ -23,6 +23,7 @@ function GuestViewContainer(element, viewType) { |
| this.setupAttributes(); |
| privates(this).browserPluginElement = this.createBrowserPluginElement(); |
| + this.guest.setBrowserPluginElement(privates(this).browserPluginElement); |
|
Fady Samuel
2015/05/26 16:42:15
Why is this necessary? Also, guests can change the
|
| this.setupFocusPropagation(); |
| var shadowRoot = this.element.createShadowRoot(); |
| shadowRoot.appendChild(privates(this).browserPluginElement); |
| @@ -91,6 +92,10 @@ GuestViewContainer.prototype.createBrowserPluginElement = function() { |
| return browserPluginElement; |
| }; |
| +GuestViewContainer.prototype.getBrowserPluginElement = function() { |
| + return privates(this).browserPluginElement; |
| +}; |
| + |
| GuestViewContainer.prototype.setupFocusPropagation = function() { |
| if (!this.element.hasAttribute('tabIndex')) { |
| // GuestViewContainer needs a tabIndex in order to be focusable. |
| @@ -120,22 +125,30 @@ GuestViewContainer.prototype.attachWindow = function() { |
| return true; |
| }; |
| +GuestViewContainer.prototype.onInternalInstanceID = function( |
| + internalInstanceId) { |
| + window.console.log('onInternalInstanceID: ' + internalInstanceId); |
| + this.internalInstanceId = internalInstanceId; |
| + |
| + // Track when the element resizes using the element resize callback. |
| + GuestViewInternalNatives.RegisterElementResizeCallback( |
| + this.internalInstanceId, this.onElementResize.bind(this)); |
| + |
| + window.console.log('this.guest.getId() = ' + |
| + this.guest.getId()); |
| + if (!this.guest.getId()) { |
| + return; |
| + } |
| + this.guest.attach(this.internalInstanceId, |
| + this.viewInstanceId, |
| + this.buildParams()); |
| +}; |
| + |
| GuestViewContainer.prototype.handleBrowserPluginAttributeMutation = |
| function(name, oldValue, newValue) { |
| if (name == 'internalinstanceid' && !oldValue && !!newValue) { |
| privates(this).browserPluginElement.removeAttribute('internalinstanceid'); |
| - this.internalInstanceId = parseInt(newValue); |
| - |
| - // Track when the element resizes using the element resize callback. |
| - GuestViewInternalNatives.RegisterElementResizeCallback( |
| - this.internalInstanceId, this.onElementResize.bind(this)); |
| - |
| - if (!this.guest.getId()) { |
| - return; |
| - } |
| - this.guest.attach(this.internalInstanceId, |
| - this.viewInstanceId, |
| - this.buildParams()); |
| + this.onInternalInstanceID(parseInt(newValue)); |
| } |
| }; |
| @@ -184,11 +197,17 @@ 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) { |
|
Fady Samuel
2015/05/26 16:42:15
Is this at all necessary in sitePerProcess?
lazyboy
2015/05/29 00:02:24
This function would register the custom element in
|
| - var proto = $Object.create(HTMLElement.prototype); |
| + var isSitePerProcess = GuestViewInternalNatives.IsSitePerProcess(); |
| + var proto = $Object.create(isSitePerProcess ? HTMLIFrameElement.prototype |
| + : HTMLElement.prototype); |
| + |
| + window.console.log('isSitePerProcess: ' + isSitePerProcess); |
| proto.createdCallback = function() { |
| - this.setAttribute('type', 'application/browser-plugin'); |
| - this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); |
| + if (!isSitePerProcess) { |
| + this.setAttribute('type', 'application/browser-plugin'); |
| + this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); |
| + } |
| this.style.width = '100%'; |
| this.style.height = '100%'; |
| }; |
| @@ -198,17 +217,20 @@ function registerBrowserPluginElement(viewType) { |
| var unused = this.nonExistentAttribute; |
| }; |
| - proto.attributeChangedCallback = function(name, oldValue, newValue) { |
| - var internal = privates(this).internal; |
| - if (!internal) { |
| - return; |
| - } |
| - internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); |
| - }; |
| + if (!isSitePerProcess) { |
| + proto.attributeChangedCallback = function(name, oldValue, newValue) { |
| + var internal = privates(this).internal; |
| + if (!internal) { |
| + return; |
| + } |
| + internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); |
| + }; |
| + } |
| + var options = {prototype: proto}; |
| + options.extends = isSitePerProcess ? 'iframe' : 'object'; |
| GuestViewContainer[viewType + 'BrowserPlugin'] = |
| - DocumentNatives.RegisterElement(viewType + 'browserplugin', |
| - {extends: 'object', prototype: proto}); |
| + DocumentNatives.RegisterElement(viewType + 'browserplugin', options); |
| delete proto.createdCallback; |
| delete proto.attachedCallback; |