Chromium Code Reviews| Index: chrome/renderer/resources/extensions/browser_tag.js |
| diff --git a/chrome/renderer/resources/extensions/browser_tag.js b/chrome/renderer/resources/extensions/browser_tag.js |
| index 362ebea154313565dfbf0977853de2ced78ef992..0271532306a6ce3606e729a012fe0ab3f4891032 100644 |
| --- a/chrome/renderer/resources/extensions/browser_tag.js |
| +++ b/chrome/renderer/resources/extensions/browser_tag.js |
| @@ -9,6 +9,20 @@ |
| var BROWSER_TAG_ATTRIBUTES = ['src', 'width', 'height']; |
| +// All exposed api methods for <browser>, these are forwarded to the browser |
| +// plugin. |
| +var BROWSER_TAG_API_METHODS = [ |
| + 'addEventListener', |
| + 'back', |
| + 'forward', |
| + 'getProcessId', |
| + 'go', |
| + 'reload', |
| + 'removeEventListener', |
| + 'stop', |
| + 'terminate' |
| + ]; |
| + |
| window.addEventListener('DOMContentLoaded', function() { |
| // Handle <browser> tags already in the document. |
| var browserNodes = document.body.querySelectorAll('browser'); |
| @@ -38,7 +52,13 @@ function BrowserTag(node) { |
| this.objectNode_ = document.createElement('object'); |
| this.objectNode_.type = 'application/browser-plugin'; |
| + var objectNode = this.objectNode_; |
| BROWSER_TAG_ATTRIBUTES.forEach(this.copyAttribute_, this); |
| + BROWSER_TAG_API_METHODS.forEach(function(apiMethod) { |
| + node[apiMethod] = function(var_args) { |
| + return objectNode[apiMethod].apply(objectNode, arguments); |
|
sadrul
2012/10/12 22:03:49
node[apiMethod] = objectNode[apiMethod].bind(objec
Mihai Parparita -not on Chrome
2012/10/12 22:19:41
+1
lazyboy
2012/10/12 23:21:16
Cool, thanks.
|
| + }; |
| + }); |
|
Mihai Parparita -not on Chrome
2012/10/12 22:19:41
You just pass in this as an argument to forEach, a
lazyboy
2012/10/12 23:21:16
Yes, now doing this;
I didn't do it b/c I was acce
|
| shadowRoot.appendChild(this.objectNode_); |
| // Map attribute modifications on the <browser> tag to changes on the |