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..425ed2b436a6cd977cc2aca4f65485c28237b8ce 100644 |
| --- a/chrome/renderer/resources/extensions/utils.js |
| +++ b/chrome/renderer/resources/extensions/utils.js |
| @@ -53,7 +53,7 @@ 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. |
|
not at google - send to devlin
2014/01/27 23:21:56
explain |props| in this comment as well, though wh
Fady Samuel
2014/01/28 20:45:45
Done. As per our offline discussion, it's fairly m
|
| -function expose(cls, funcs) { |
| +function expose(cls, funcs, props) { |
| function publicClass() { |
| var privateObj = $Object.create(cls.prototype); |
| $Function.apply(cls, privateObj, arguments); |
| @@ -61,12 +61,27 @@ 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/27 23:21:56
Hm this is pretty tricky.
You should make this se
Fady Samuel
2014/01/28 20:45:45
Done.
|
| + }); |
| + }); |
| + } |
| return publicClass; |
| } |