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 "gin/converter.h" | 10 #include "gin/converter.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 } | 40 } |
41 | 41 |
42 void ArgumentSpec::InitializeType(const base::DictionaryValue* dict) { | 42 void ArgumentSpec::InitializeType(const base::DictionaryValue* dict) { |
43 std::string ref_string; | 43 std::string ref_string; |
44 if (dict->GetString("$ref", &ref_string)) { | 44 if (dict->GetString("$ref", &ref_string)) { |
45 ref_ = std::move(ref_string); | 45 ref_ = std::move(ref_string); |
46 type_ = ArgumentType::REF; | 46 type_ = ArgumentType::REF; |
47 return; | 47 return; |
48 } | 48 } |
49 | 49 |
50 { | |
51 const base::ListValue* choices = nullptr; | |
Devlin
2016/12/16 01:55:49
This is needed for the chrome.test API to work, bu
| |
52 if (dict->GetList("choices", &choices)) { | |
53 // TODO(devlin): Properly handle choices. | |
54 type_ = ArgumentType::ANY; | |
55 return; | |
56 } | |
57 } | |
58 | |
50 std::string type_string; | 59 std::string type_string; |
51 CHECK(dict->GetString("type", &type_string)); | 60 CHECK(dict->GetString("type", &type_string)); |
52 if (type_string == "integer") | 61 if (type_string == "integer") |
53 type_ = ArgumentType::INTEGER; | 62 type_ = ArgumentType::INTEGER; |
54 else if (type_string == "number") | 63 else if (type_string == "number") |
55 type_ = ArgumentType::DOUBLE; | 64 type_ = ArgumentType::DOUBLE; |
56 else if (type_string == "object") | 65 else if (type_string == "object") |
57 type_ = ArgumentType::OBJECT; | 66 type_ = ArgumentType::OBJECT; |
58 else if (type_string == "array") | 67 else if (type_string == "array") |
59 type_ = ArgumentType::LIST; | 68 type_ = ArgumentType::LIST; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 std::unique_ptr<content::V8ValueConverter> converter( | 273 std::unique_ptr<content::V8ValueConverter> converter( |
265 content::V8ValueConverter::create()); | 274 content::V8ValueConverter::create()); |
266 std::unique_ptr<base::Value> converted( | 275 std::unique_ptr<base::Value> converted( |
267 converter->FromV8Value(value, context)); | 276 converter->FromV8Value(value, context)); |
268 if (!converted) | 277 if (!converted) |
269 *error = "Could not convert to 'any'."; | 278 *error = "Could not convert to 'any'."; |
270 return converted; | 279 return converted; |
271 } | 280 } |
272 | 281 |
273 } // namespace extensions | 282 } // namespace extensions |
OLD | NEW |