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

Side by Side Diff: chrome/renderer/extensions/safe_builtins.cc

Issue 17247007: Remove (but leave references to) all of the builtins that we don't need saved (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/safe_builtins.h" 5 #include "chrome/renderer/extensions/safe_builtins.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 " makeCallable(builtin, safe, true);\n" 62 " makeCallable(builtin, safe, true);\n"
63 " if (includePrototype)\n" 63 " if (includePrototype)\n"
64 " makeCallable(builtin.prototype, safe, false);\n" 64 " makeCallable(builtin.prototype, safe, false);\n"
65 " return safe;\n" 65 " return safe;\n"
66 "}\n" 66 "}\n"
67 "\n" 67 "\n"
68 "// Built-in types taken from the ECMAScript spec. The spec may change,\n" 68 "// Built-in types taken from the ECMAScript spec. The spec may change,\n"
69 "// though. It would be nice to generate this somehow.\n" 69 "// though. It would be nice to generate this somehow.\n"
70 "// Note: no JSON, it needs to handle toJSON being overriden so is\n" 70 "// Note: no JSON, it needs to handle toJSON being overriden so is\n"
71 "// implemented by hand.\n" 71 "// implemented by hand.\n"
72 "var builtinTypes = [Object, Function, Array, String, Boolean, Number,\n" 72 "// Note: no Math, it's static (we also don't need it yet).\n"
73 " /*Math,*/ Date, RegExp, /*JSON,*/ Error, EvalError,\n" 73 "// Note: the other things that are commented out are ones that aren't\n"
74 " ReferenceError, SyntaxError, TypeError, URIError];\n" 74 "// needed to make the clobber tests pass, because running this\n"
75 "// file is a bit slow.\n"
76 "var builtinTypes = [\n"
77 " Object, Function, Array, String, /*Boolean, Number,*/\n"
78 " /*Math, Date,*/ RegExp, /*JSON, Error, EvalError,\n"
79 " ReferenceError, SyntaxError, TypeError, URIError*/];\n"
75 "builtinTypes.forEach(function(builtin) {\n" 80 "builtinTypes.forEach(function(builtin) {\n"
76 " Save(builtin.name, getSafeBuiltin(builtin, true));\n" 81 " Save(builtin.name, getSafeBuiltin(builtin, true));\n"
77 "});\n" 82 "});\n"
78 "Save('Math', getSafeBuiltin(Math, false));\n" 83 "//Save('Math', getSafeBuiltin(Math, false));\n"
79 "// Save JSON. This is trickier because extensions can override toJSON in\n" 84 "// Save JSON. This is trickier because extensions can override toJSON in\n"
80 "// incompatible ways, and we need to prevent that.\n" 85 "// incompatible ways, and we need to prevent that.\n"
81 "var builtinToJSONs = builtinTypes.map(function(t) {\n" 86 "var builtinToJSONs = builtinTypes.map(function(t) {\n"
82 " return t.toJSON;\n" 87 " return t.toJSON;\n"
83 "});\n" 88 "});\n"
84 "var builtinArray = Array;\n" 89 "var builtinArray = Array;\n"
85 "var builtinJSONStringify = JSON.stringify;\n" 90 "var builtinJSONStringify = JSON.stringify;\n"
86 "Save('JSON', {\n" 91 "Save('JSON', {\n"
87 " parse: JSON.parse,\n" 92 " parse: JSON.parse,\n"
88 " stringify: function(obj) {\n" 93 " stringify: function(obj) {\n"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 225
221 v8::Local<v8::Object> SafeBuiltins::GetRegExp() const { 226 v8::Local<v8::Object> SafeBuiltins::GetRegExp() const {
222 return Load("RegExp", context_->v8_context()); 227 return Load("RegExp", context_->v8_context());
223 } 228 }
224 229
225 v8::Local<v8::Object> SafeBuiltins::GetString() const { 230 v8::Local<v8::Object> SafeBuiltins::GetString() const {
226 return Load("String", context_->v8_context()); 231 return Load("String", context_->v8_context());
227 } 232 }
228 233
229 } // namespace extensions 234 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698