| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // the arguments in the signature. This is very broken. | 317 // the arguments in the signature. This is very broken. |
| 318 if (HasCallback(signature_)) { | 318 if (HasCallback(signature_)) { |
| 319 CHECK(!arguments.empty()); | 319 CHECK(!arguments.empty()); |
| 320 if (arguments[size - 1]->IsFunction()) { | 320 if (arguments[size - 1]->IsFunction()) { |
| 321 callback = arguments[size - 1].As<v8::Function>(); | 321 callback = arguments[size - 1].As<v8::Function>(); |
| 322 --size; | 322 --size; |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 auto json = base::MakeUnique<base::ListValue>(); | 326 auto json = base::MakeUnique<base::ListValue>(); |
| 327 std::unique_ptr<content::V8ValueConverter> converter( | 327 std::unique_ptr<content::V8ValueConverter> converter = |
| 328 content::V8ValueConverter::create()); | 328 content::V8ValueConverter::Create(); |
| 329 converter->SetFunctionAllowed(true); | 329 converter->SetFunctionAllowed(true); |
| 330 for (size_t i = 0; i < size; ++i) { | 330 for (size_t i = 0; i < size; ++i) { |
| 331 std::unique_ptr<base::Value> converted = | 331 std::unique_ptr<base::Value> converted = |
| 332 converter->FromV8Value(arguments[i], context); | 332 converter->FromV8Value(arguments[i], context); |
| 333 if (!converted) | 333 if (!converted) |
| 334 return false; | 334 return false; |
| 335 json->Append(std::move(converted)); | 335 json->Append(std::move(converted)); |
| 336 } | 336 } |
| 337 | 337 |
| 338 *json_out = std::move(json); | 338 *json_out = std::move(json); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 351 pieces.push_back( | 351 pieces.push_back( |
| 352 base::StringPrintf("%s%s %s", spec->optional() ? kOptionalPrefix : "", | 352 base::StringPrintf("%s%s %s", spec->optional() ? kOptionalPrefix : "", |
| 353 spec->GetTypeName().c_str(), spec->name().c_str())); | 353 spec->GetTypeName().c_str(), spec->name().c_str())); |
| 354 } | 354 } |
| 355 expected_signature_ = base::JoinString(pieces, ", "); | 355 expected_signature_ = base::JoinString(pieces, ", "); |
| 356 | 356 |
| 357 return expected_signature_; | 357 return expected_signature_; |
| 358 } | 358 } |
| 359 | 359 |
| 360 } // namespace extensions | 360 } // namespace extensions |
| OLD | NEW |