Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1115)

Unified Diff: chrome/renderer/resources/extensions/utils.js

Issue 141803016: Hide Port privates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expose name property Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/resources/extensions/messaging.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4ffb6d7bd56a7a08857a50470f781c497e508286 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,30 @@ 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() {
+ return privates(this).impl[prop];
+ },
+ set: function(value) {
+ var impl = privates(this).impl;
+ delete impl[prop];
+ impl[prop] = value;
+ }
+ });
+ });
+ }
return publicClass;
}
« no previous file with comments | « chrome/renderer/resources/extensions/messaging.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698