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 "services/catalog/entry.h" | 5 #include "services/catalog/entry.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "services/catalog/store.h" | 8 #include "services/catalog/store.h" |
9 #include "services/shell/public/cpp/names.h" | 9 #include "services/shell/public/cpp/names.h" |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 } | 117 } |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 Entry::Entry() {} | 123 Entry::Entry() {} |
124 Entry::Entry(const std::string& name) | 124 Entry::Entry(const std::string& name) |
125 : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {} | 125 : name_(name), qualifier_(shell::GetNamePath(name)), display_name_(name) {} |
126 Entry::Entry(const Entry& other) = default; | |
127 Entry::~Entry() {} | 126 Entry::~Entry() {} |
128 | 127 |
129 std::unique_ptr<base::DictionaryValue> Entry::Serialize() const { | 128 std::unique_ptr<base::DictionaryValue> Entry::Serialize() const { |
130 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 129 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
131 value->SetInteger(Store::kManifestVersionKey, 1); | 130 value->SetInteger(Store::kManifestVersionKey, 1); |
132 value->SetString(Store::kNameKey, name_); | 131 value->SetString(Store::kNameKey, name_); |
133 value->SetString(Store::kDisplayNameKey, display_name_); | 132 value->SetString(Store::kDisplayNameKey, display_name_); |
134 value->SetString(Store::kQualifierKey, qualifier_); | 133 value->SetString(Store::kQualifierKey, qualifier_); |
135 std::unique_ptr<base::DictionaryValue> spec(new base::DictionaryValue); | 134 std::unique_ptr<base::DictionaryValue> spec(new base::DictionaryValue); |
136 | 135 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 if (value.HasKey(Store::kServicesKey)) { | 233 if (value.HasKey(Store::kServicesKey)) { |
235 const base::ListValue* services = nullptr; | 234 const base::ListValue* services = nullptr; |
236 value.GetList(Store::kServicesKey, &services); | 235 value.GetList(Store::kServicesKey, &services); |
237 for (size_t i = 0; i < services->GetSize(); ++i) { | 236 for (size_t i = 0; i < services->GetSize(); ++i) { |
238 const base::DictionaryValue* service = nullptr; | 237 const base::DictionaryValue* service = nullptr; |
239 services->GetDictionary(i, &service); | 238 services->GetDictionary(i, &service); |
240 std::unique_ptr<Entry> child = Entry::Deserialize(*service); | 239 std::unique_ptr<Entry> child = Entry::Deserialize(*service); |
241 if (child) { | 240 if (child) { |
242 child->set_package(entry.get()); | 241 child->set_package(entry.get()); |
243 // Caller must assume ownership of these items. | 242 // Caller must assume ownership of these items. |
244 entry->services_.insert(child.release()); | 243 entry->children_.emplace_back(std::move(child)); |
245 } | 244 } |
246 } | 245 } |
247 } | 246 } |
248 | 247 |
249 return entry; | 248 return entry; |
250 } | 249 } |
251 | 250 |
252 bool Entry::ProvidesClass(const std::string& clazz) const { | 251 bool Entry::ProvidesClass(const std::string& clazz) const { |
253 return capabilities_.provided.find(clazz) != capabilities_.provided.end(); | 252 return capabilities_.provided.find(clazz) != capabilities_.provided.end(); |
254 } | 253 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 catalog::mojom::EntryPtr | 286 catalog::mojom::EntryPtr |
288 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( | 287 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( |
289 const catalog::Entry& input) { | 288 const catalog::Entry& input) { |
290 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); | 289 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); |
291 result->name = input.name(); | 290 result->name = input.name(); |
292 result->display_name = input.display_name(); | 291 result->display_name = input.display_name(); |
293 return result; | 292 return result; |
294 } | 293 } |
295 | 294 |
296 } // namespace mojo | 295 } // namespace mojo |
OLD | NEW |