Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: extensions/renderer/argument_spec_builder.cc

Issue 2847843002: [Extensions Bindings] Move signature parsing tests to their own file (Closed)
Patch Set: jbroman's Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/argument_spec_builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "extensions/renderer/argument_spec_builder.h"
6
7 #include "base/memory/ptr_util.h"
8
9 namespace extensions {
10
11 ArgumentSpecBuilder::ArgumentSpecBuilder(ArgumentType type)
12 : ArgumentSpecBuilder(type, base::StringPiece()) {}
13
14 ArgumentSpecBuilder::ArgumentSpecBuilder(ArgumentType type,
15 base::StringPiece name)
16 : spec_(base::MakeUnique<ArgumentSpec>(type)) {
17 if (!name.empty())
18 spec_->set_name(name);
19 }
20
21 ArgumentSpecBuilder::~ArgumentSpecBuilder() {}
22
23 ArgumentSpecBuilder& ArgumentSpecBuilder::MakeOptional() {
24 spec_->set_optional(true);
25 return *this;
26 }
27
28 ArgumentSpecBuilder& ArgumentSpecBuilder::AddProperty(
29 base::StringPiece property_name,
30 std::unique_ptr<ArgumentSpec> property_spec) {
31 properties_[property_name.as_string()] = std::move(property_spec);
32 return *this;
33 }
34
35 ArgumentSpecBuilder& ArgumentSpecBuilder::SetMinimum(int minimum) {
36 spec_->set_minimum(minimum);
37 return *this;
38 }
39
40 ArgumentSpecBuilder& ArgumentSpecBuilder::SetListType(
41 std::unique_ptr<ArgumentSpec> list_type) {
42 spec_->set_list_element_type(std::move(list_type));
43 return *this;
44 }
45
46 ArgumentSpecBuilder& ArgumentSpecBuilder::SetRef(base::StringPiece ref) {
47 spec_->set_ref(ref);
48 return *this;
49 }
50
51 ArgumentSpecBuilder& ArgumentSpecBuilder::SetChoices(
52 std::vector<std::unique_ptr<ArgumentSpec>> choices) {
53 spec_->set_choices(std::move(choices));
54 return *this;
55 }
56
57 ArgumentSpecBuilder& ArgumentSpecBuilder::SetEnums(
58 std::set<std::string> enum_values) {
59 spec_->set_enum_values(std::move(enum_values));
60 return *this;
61 }
62
63 ArgumentSpecBuilder& ArgumentSpecBuilder::SetAdditionalProperties(
64 std::unique_ptr<ArgumentSpec> additional_properties) {
65 spec_->set_additional_properties(std::move(additional_properties));
66 return *this;
67 }
68
69 std::unique_ptr<ArgumentSpec> ArgumentSpecBuilder::Build() {
70 spec_->set_properties(std::move(properties_));
71 return std::move(spec_);
72 }
73
74 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/argument_spec_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698