[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / component_updater / component_updater_utils.cc
1 // Copyright 2021 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/component_updater/component_updater_utils.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/containers/flat_map.h"
11 #include "base/files/file_enumerator.h"
12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h"
14 #include "base/logging.h"
15 #include "base/version.h"
16 #include "components/component_updater/component_updater_service.h"
17 #include "third_party/abseil-cpp/absl/types/optional.h"
18
19 namespace component_updater {
20
21 absl::optional<ComponentRegistration> GetComponent(
22     const base::flat_map<std::string, ComponentRegistration>& components,
23     const std::string& id) {
24   const auto it = components.find(id);
25   if (it != components.end())
26     return it->second;
27   return absl::nullopt;
28 }
29
30 std::vector<absl::optional<ComponentRegistration>> GetCrxComponents(
31     const base::flat_map<std::string, ComponentRegistration>&
32         registered_components,
33     const std::vector<std::string>& ids) {
34   std::vector<absl::optional<ComponentRegistration>> components;
35   for (const auto& id : ids)
36     components.push_back(GetComponent(registered_components, id));
37   return components;
38 }
39
40 }  // namespace component_updater