OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/safe_builtins.h" | 5 #include "extensions/renderer/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 "extensions/renderer/script_context.h" | 10 #include "extensions/renderer/script_context.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 info.GetIsolate(), | 187 info.GetIsolate(), |
188 "The first argument is the receiver and must be an object"))); | 188 "The first argument is the receiver and must be an object"))); |
189 return; | 189 return; |
190 } | 190 } |
191 v8::Local<v8::Object> args = v8::Local<v8::Object>::Cast(info[2]); | 191 v8::Local<v8::Object> args = v8::Local<v8::Object>::Cast(info[2]); |
192 int first_arg_index = info[3].As<v8::Int32>()->Value(); | 192 int first_arg_index = info[3].As<v8::Int32>()->Value(); |
193 int args_length = info[4].As<v8::Int32>()->Value(); | 193 int args_length = info[4].As<v8::Int32>()->Value(); |
194 | 194 |
195 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); | 195 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); |
196 int argc = args_length - first_arg_index; | 196 int argc = args_length - first_arg_index; |
197 scoped_ptr<v8::Local<v8::Value> []> argv(new v8::Local<v8::Value>[argc]); | 197 std::unique_ptr<v8::Local<v8::Value>[]> argv( |
| 198 new v8::Local<v8::Value>[argc]); |
198 for (int i = 0; i < argc; ++i) { | 199 for (int i = 0; i < argc; ++i) { |
199 CHECK(IsTrue(args->Has(context, i + first_arg_index))); | 200 CHECK(IsTrue(args->Has(context, i + first_arg_index))); |
200 // Getting a property value could throw an exception. | 201 // Getting a property value could throw an exception. |
201 if (!GetProperty(context, args, i + first_arg_index, &argv[i])) | 202 if (!GetProperty(context, args, i + first_arg_index, &argv[i])) |
202 return; | 203 return; |
203 } | 204 } |
204 | 205 |
205 v8::MicrotasksScope microtasks( | 206 v8::MicrotasksScope microtasks( |
206 info.GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); | 207 info.GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); |
207 v8::Local<v8::Value> return_value; | 208 v8::Local<v8::Value> return_value; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 249 |
249 v8::Local<v8::Object> SafeBuiltins::GetString() const { | 250 v8::Local<v8::Object> SafeBuiltins::GetString() const { |
250 return Load("String", context_->v8_context()); | 251 return Load("String", context_->v8_context()); |
251 } | 252 } |
252 | 253 |
253 v8::Local<v8::Object> SafeBuiltins::GetError() const { | 254 v8::Local<v8::Object> SafeBuiltins::GetError() const { |
254 return Load("Error", context_->v8_context()); | 255 return Load("Error", context_->v8_context()); |
255 } | 256 } |
256 | 257 |
257 } // namespace extensions | 258 } // namespace extensions |
OLD | NEW |