| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This module implements the shared functionality for different guestview | 5 // This module implements the shared functionality for different guestview |
| 6 // containers, such as web_view, app_view, etc. | 6 // containers, such as web_view, app_view, etc. |
| 7 | 7 |
| 8 var DocumentNatives = requireNative('document_natives'); | 8 var DocumentNatives = requireNative('document_natives'); |
| 9 var GuestView = require('guestView').GuestView; | 9 var GuestView = require('guestView').GuestView; |
| 10 var GuestViewInternalNatives = requireNative('guest_view_internal'); | 10 var GuestViewInternalNatives = requireNative('guest_view_internal'); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 GuestViewContainer.prototype.createBrowserPluginElement = function() { | 85 GuestViewContainer.prototype.createBrowserPluginElement = function() { |
| 86 // We create BrowserPlugin as a custom element in order to observe changes | 86 // We create BrowserPlugin as a custom element in order to observe changes |
| 87 // to attributes synchronously. | 87 // to attributes synchronously. |
| 88 var browserPluginElement = | 88 var browserPluginElement = |
| 89 new GuestViewContainer[this.viewType + 'BrowserPlugin'](); | 89 new GuestViewContainer[this.viewType + 'BrowserPlugin'](); |
| 90 privates(browserPluginElement).internal = this; | 90 privates(browserPluginElement).internal = this; |
| 91 return browserPluginElement; | 91 return browserPluginElement; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 GuestViewContainer.prototype.getBrowserPluginElement = function() { |
| 95 return privates(this).browserPluginElement; |
| 96 }; |
| 97 |
| 94 GuestViewContainer.prototype.setupFocusPropagation = function() { | 98 GuestViewContainer.prototype.setupFocusPropagation = function() { |
| 95 if (!this.element.hasAttribute('tabIndex')) { | 99 if (!this.element.hasAttribute('tabIndex')) { |
| 96 // GuestViewContainer needs a tabIndex in order to be focusable. | 100 // GuestViewContainer needs a tabIndex in order to be focusable. |
| 97 // TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute | 101 // TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute |
| 98 // to allow GuestViewContainer to be focusable. | 102 // to allow GuestViewContainer to be focusable. |
| 99 // See http://crbug.com/231664. | 103 // See http://crbug.com/231664. |
| 100 this.element.setAttribute('tabIndex', -1); | 104 this.element.setAttribute('tabIndex', -1); |
| 101 } | 105 } |
| 102 this.element.addEventListener('focus', function(e) { | 106 this.element.addEventListener('focus', function(e) { |
| 103 // Focus the BrowserPlugin when the GuestViewContainer takes focus. | 107 // Focus the BrowserPlugin when the GuestViewContainer takes focus. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 181 |
| 178 // Implemented by the specific view type, if needed. | 182 // Implemented by the specific view type, if needed. |
| 179 GuestViewContainer.prototype.buildContainerParams = function() { return {}; }; | 183 GuestViewContainer.prototype.buildContainerParams = function() { return {}; }; |
| 180 GuestViewContainer.prototype.onElementAttached = function() {}; | 184 GuestViewContainer.prototype.onElementAttached = function() {}; |
| 181 GuestViewContainer.prototype.onElementDetached = function() {}; | 185 GuestViewContainer.prototype.onElementDetached = function() {}; |
| 182 GuestViewContainer.prototype.setupAttributes = function() {}; | 186 GuestViewContainer.prototype.setupAttributes = function() {}; |
| 183 | 187 |
| 184 // Registers the browser plugin <object> custom element. |viewType| is the | 188 // Registers the browser plugin <object> custom element. |viewType| is the |
| 185 // name of the specific guestview container (e.g. 'webview'). | 189 // name of the specific guestview container (e.g. 'webview'). |
| 186 function registerBrowserPluginElement(viewType) { | 190 function registerBrowserPluginElement(viewType) { |
| 187 var proto = Object.create(HTMLObjectElement.prototype); | 191 //var proto = Object.create(HTMLObjectElement.prototype); |
| 192 var proto = Object.create(HTMLIFrameElement.prototype); |
| 188 | 193 |
| 189 proto.createdCallback = function() { | 194 proto.createdCallback = function() { |
| 190 this.setAttribute('type', 'application/browser-plugin'); | 195 //this.setAttribute('type', 'application/browser-plugin'); |
| 191 this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); | 196 //this.setAttribute('id', 'browser-plugin-' + IdGenerator.GetNextId()); |
| 192 this.style.width = '100%'; | 197 this.style.width = '100%'; |
| 193 this.style.height = '100%'; | 198 this.style.height = '100%'; |
| 194 }; | 199 }; |
| 195 | 200 |
| 196 proto.attachedCallback = function() { | 201 proto.attachedCallback = function() { |
| 197 // Load the plugin immediately. | 202 // Load the plugin immediately. |
| 198 var unused = this.nonExistentAttribute; | 203 var unused = this.nonExistentAttribute; |
| 199 }; | 204 }; |
| 200 | 205 |
| 206 /* |
| 201 proto.attributeChangedCallback = function(name, oldValue, newValue) { | 207 proto.attributeChangedCallback = function(name, oldValue, newValue) { |
| 202 var internal = privates(this).internal; | 208 var internal = privates(this).internal; |
| 203 if (!internal) { | 209 if (!internal) { |
| 204 return; | 210 return; |
| 205 } | 211 } |
| 206 internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); | 212 internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); |
| 207 }; | 213 }; |
| 214 */ |
| 208 | 215 |
| 209 GuestViewContainer[viewType + 'BrowserPlugin'] = | 216 GuestViewContainer[viewType + 'BrowserPlugin'] = |
| 210 DocumentNatives.RegisterElement(viewType + 'browserplugin', | 217 DocumentNatives.RegisterElement(viewType + 'browserplugin', |
| 211 {extends: 'object', prototype: proto}); | 218 //{extends: 'object', prototype: proto}); |
| 219 {extends: 'iframe', prototype: proto}); |
| 212 | 220 |
| 213 delete proto.createdCallback; | 221 delete proto.createdCallback; |
| 214 delete proto.attachedCallback; | 222 delete proto.attachedCallback; |
| 215 delete proto.detachedCallback; | 223 delete proto.detachedCallback; |
| 216 delete proto.attributeChangedCallback; | 224 delete proto.attributeChangedCallback; |
| 217 }; | 225 }; |
| 218 | 226 |
| 219 // Registers the guestview container as a custom element. | 227 // Registers the guestview container as a custom element. |
| 220 // |guestViewContainerType| is the type of guestview container | 228 // |guestViewContainerType| is the type of guestview container |
| 221 // (e.g.WebViewImpl). | 229 // (e.g.WebViewImpl). |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Delete the callbacks so developers cannot call them and produce unexpected | 278 // Delete the callbacks so developers cannot call them and produce unexpected |
| 271 // behavior. | 279 // behavior. |
| 272 delete proto.createdCallback; | 280 delete proto.createdCallback; |
| 273 delete proto.attachedCallback; | 281 delete proto.attachedCallback; |
| 274 delete proto.detachedCallback; | 282 delete proto.detachedCallback; |
| 275 delete proto.attributeChangedCallback; | 283 delete proto.attributeChangedCallback; |
| 276 } | 284 } |
| 277 | 285 |
| 278 // Exports. | 286 // Exports. |
| 279 exports.GuestViewContainer = GuestViewContainer; | 287 exports.GuestViewContainer = GuestViewContainer; |
| OLD | NEW |