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/argument_spec.h" | 5 #include "extensions/renderer/argument_spec.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "content/public/child/v8_value_converter.h" | 9 #include "content/public/child/v8_value_converter.h" |
10 #include "extensions/renderer/api_type_reference_map.h" | 10 #include "extensions/renderer/api_type_reference_map.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 if (!out_value && enum_values_.empty()) | 221 if (!out_value && enum_values_.empty()) |
222 return true; | 222 return true; |
223 // ...Otherwise, we need to convert to a std::string. | 223 // ...Otherwise, we need to convert to a std::string. |
224 std::string s; | 224 std::string s; |
225 // We already checked that this is a string, so this should never fail. | 225 // We already checked that this is a string, so this should never fail. |
226 CHECK(gin::Converter<std::string>::FromV8(context->GetIsolate(), value, | 226 CHECK(gin::Converter<std::string>::FromV8(context->GetIsolate(), value, |
227 &s)); | 227 &s)); |
228 if (!enum_values_.empty() && enum_values_.count(s) == 0) | 228 if (!enum_values_.empty() && enum_values_.count(s) == 0) |
229 return false; | 229 return false; |
230 if (out_value) { | 230 if (out_value) { |
231 // TODO(devlin): If base::StringValue ever takes a std::string&&, we | 231 // TODO(devlin): If base::Value ever takes a std::string&&, we |
232 // could use std::move to construct. | 232 // could use std::move to construct. |
233 *out_value = base::MakeUnique<base::StringValue>(s); | 233 *out_value = base::MakeUnique<base::Value>(s); |
234 } | 234 } |
235 return true; | 235 return true; |
236 } | 236 } |
237 case ArgumentType::BOOLEAN: { | 237 case ArgumentType::BOOLEAN: { |
238 if (!value->IsBoolean()) | 238 if (!value->IsBoolean()) |
239 return false; | 239 return false; |
240 if (out_value) { | 240 if (out_value) { |
241 *out_value = | 241 *out_value = |
242 base::MakeUnique<base::Value>(value.As<v8::Boolean>()->Value()); | 242 base::MakeUnique<base::Value>(value.As<v8::Boolean>()->Value()); |
243 } | 243 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 return false; | 391 return false; |
392 } | 392 } |
393 if (type_ == ArgumentType::BINARY) | 393 if (type_ == ArgumentType::BINARY) |
394 DCHECK_EQ(base::Value::Type::BINARY, converted->GetType()); | 394 DCHECK_EQ(base::Value::Type::BINARY, converted->GetType()); |
395 *out_value = std::move(converted); | 395 *out_value = std::move(converted); |
396 } | 396 } |
397 return true; | 397 return true; |
398 } | 398 } |
399 | 399 |
400 } // namespace extensions | 400 } // namespace extensions |
OLD | NEW |