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

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

Issue 332233002: enterprise.platformKeys: Copy-on-read the 'algorithm' member of Key objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ensure that crx is up-to-date. Created 6 years, 6 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/test/data/extensions/api_test/enterprise_platform_keys/basic.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/utils.js
diff --git a/extensions/renderer/resources/utils.js b/extensions/renderer/resources/utils.js
index 853c652361d42c660af1a91039da124a3fa65a8f..a5437411c2279422f84f1d0cb62de4918b70dbc6 100644
--- a/extensions/renderer/resources/utils.js
+++ b/extensions/renderer/resources/utils.js
@@ -124,7 +124,40 @@ function expose(name, cls, exposed) {
return publicClass;
}
+/**
+ * Copies |value| recursively. |value| must not contain cyclic references.
+ * Copies only nested structures of non-object types (like number or string),
+ * Array, Uint8Array and the directly owned properties of objects (it ignores
+ * prototypes).
not at google - send to devlin 2014/06/19 00:12:42 there's actually a really sneaky way you can imple
pneubeck (no reviews) 2014/06/19 16:09:41 Done.
+ */
+function deepCopy(value) {
+ if (value === null)
+ return null;
+ if (typeof(value) !== 'object')
+ return value;
+
+ var copy = null;
+ if (Array.isArray(value) ) {
+ copy = new Array();
+ for (var i = 0; i < value.length; i++)
+ copy[i] = deepCopy(value[i]);
+ } else if (value.__proto__.constructor.name === 'Uint8Array') {
not at google - send to devlin 2014/06/19 00:12:42 I don't think you need the __proto__ ? just value.
+ copy = new Uint8Array(value.length);
+ for (var i = 0; i < value.length; i++)
+ copy[i] = value[i];
+ } else {
+ copy = new Object();
+ for (var key in value) {
+ if (!value.hasOwnProperty(key))
+ continue;
+ copy[key] = deepCopy(value[key]);
not at google - send to devlin 2014/06/19 00:12:42 nit: I would invert the hasOwnProperty check to sa
+ }
+ }
+ return copy;
+}
+
exports.forEach = forEach;
exports.loadTypeSchema = loadTypeSchema;
exports.lookup = lookup;
exports.expose = expose;
+exports.deepCopy = deepCopy;
« no previous file with comments | « chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698