| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/api_signature.h" | 5 #include "extensions/renderer/api_signature.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 v8::Local<v8::Value> value = arguments.back(); | 320 v8::Local<v8::Value> value = arguments.back(); |
| 321 --size; | 321 --size; |
| 322 // Bindings should ensure that the value here is appropriate, but see the | 322 // Bindings should ensure that the value here is appropriate, but see the |
| 323 // comment above for limitations. | 323 // comment above for limitations. |
| 324 DCHECK(value->IsFunction() || value->IsUndefined() || value->IsNull()); | 324 DCHECK(value->IsFunction() || value->IsUndefined() || value->IsNull()); |
| 325 if (value->IsFunction()) | 325 if (value->IsFunction()) |
| 326 callback = value.As<v8::Function>(); | 326 callback = value.As<v8::Function>(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 auto json = base::MakeUnique<base::ListValue>(); | 329 auto json = base::MakeUnique<base::ListValue>(); |
| 330 std::unique_ptr<content::V8ValueConverter> converter( | 330 std::unique_ptr<content::V8ValueConverter> converter = |
| 331 content::V8ValueConverter::create()); | 331 content::V8ValueConverter::Create(); |
| 332 converter->SetFunctionAllowed(true); | 332 converter->SetFunctionAllowed(true); |
| 333 for (size_t i = 0; i < size; ++i) { | 333 for (size_t i = 0; i < size; ++i) { |
| 334 std::unique_ptr<base::Value> converted = | 334 std::unique_ptr<base::Value> converted = |
| 335 converter->FromV8Value(arguments[i], context); | 335 converter->FromV8Value(arguments[i], context); |
| 336 if (!converted) | 336 if (!converted) |
| 337 return false; | 337 return false; |
| 338 json->Append(std::move(converted)); | 338 json->Append(std::move(converted)); |
| 339 } | 339 } |
| 340 | 340 |
| 341 *json_out = std::move(json); | 341 *json_out = std::move(json); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 354 pieces.push_back( | 354 pieces.push_back( |
| 355 base::StringPrintf("%s%s %s", spec->optional() ? kOptionalPrefix : "", | 355 base::StringPrintf("%s%s %s", spec->optional() ? kOptionalPrefix : "", |
| 356 spec->GetTypeName().c_str(), spec->name().c_str())); | 356 spec->GetTypeName().c_str(), spec->name().c_str())); |
| 357 } | 357 } |
| 358 expected_signature_ = base::JoinString(pieces, ", "); | 358 expected_signature_ = base::JoinString(pieces, ", "); |
| 359 | 359 |
| 360 return expected_signature_; | 360 return expected_signature_; |
| 361 } | 361 } |
| 362 | 362 |
| 363 } // namespace extensions | 363 } // namespace extensions |
| OLD | NEW |