Chromium Code Reviews| Index: chrome/renderer/resources/extensions/utils.js |
| diff --git a/chrome/renderer/resources/extensions/utils.js b/chrome/renderer/resources/extensions/utils.js |
| index edf249cadc7d1186be9d5146554a733bf804a785..4825fee5fc7ab533bc9107d8a07fb580b55eacee 100644 |
| --- a/chrome/renderer/resources/extensions/utils.js |
| +++ b/chrome/renderer/resources/extensions/utils.js |
| @@ -52,8 +52,9 @@ function loadTypeSchema(typeName, defaultSchema) { |
| } |
| // expose takes a private class implementation |cls| and exposes a subset of its |
| -// methods |funcs| in a public wrapper class that it returns. |
| -function expose(cls, funcs) { |
| +// methods |funcs| and properties |props| in a public wrapper class that it |
| +// returns. |
| +function expose(cls, funcs, props) { |
| function publicClass() { |
| var privateObj = $Object.create(cls.prototype); |
| $Function.apply(cls, privateObj, arguments); |
| @@ -61,12 +62,31 @@ function expose(cls, funcs) { |
| privates(this).impl = privateObj; |
| } |
| - $Array.forEach(funcs, function(func) { |
| - publicClass.prototype[func] = function() { |
| - var impl = privates(this).impl; |
| - return $Function.apply(impl[func], impl, arguments); |
| - }; |
| - }); |
| + if (funcs) { |
| + $Array.forEach(funcs, function(func) { |
| + publicClass.prototype[func] = function() { |
| + var impl = privates(this).impl; |
| + return $Function.apply(impl[func], impl, arguments); |
| + }; |
| + }); |
| + } |
| + |
| + if (props) { |
| + $Array.forEach(props, function(prop) { |
| + $Object.defineProperty(publicClass.prototype, prop, { |
| + enumerable: true, |
| + get: function() { |
| + var impl = privates(this).impl; |
| + return impl[prop]; |
|
not at google - send to devlin
2014/01/28 22:25:06
inline |impl|?
|
| + }, |
| + set: function(value) { |
| + var impl = privates(this).impl; |
| + delete impl[prop]; |
| + impl[prop] = value; |
| + } |
| + }); |
| + }); |
| + } |
| return publicClass; |
| } |