[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / fuchsia_component_support / serialize_arguments.cc
1 // Copyright 2022 The Chromium Authors
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 "components/fuchsia_component_support/serialize_arguments.h"
6
7 #include <string>
8
9 #include "base/check.h"
10 #include "base/command_line.h"
11 #include "base/json/json_string_value_serializer.h"
12 #include "base/values.h"
13
14 namespace fuchsia_component_support {
15
16 std::vector<uint8_t> SerializeArguments(const base::CommandLine& command_line) {
17   base::Value::List argv_list;
18   const auto& argv = command_line.argv();
19   DCHECK_GE(argv.size(), 1UL);
20   argv_list.reserve(argv.size() - 1);
21   for (size_t i = 1, size = argv.size(); i < size; ++i) {
22     argv_list.Append(argv[i]);
23   }
24
25   base::Value::Dict feature_dict;
26   feature_dict.Set("argv", std::move(argv_list));
27   std::string json_string;
28   CHECK(JSONStringValueSerializer(&json_string)
29             .Serialize(base::Value(std::move(feature_dict))));
30   return std::vector<uint8_t>(json_string.begin(), json_string.end());
31 }
32
33 }  // namespace fuchsia_component_support