| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 services->GetDictionary(i, &service); | 238 services->GetDictionary(i, &service); |
| 239 std::unique_ptr<Entry> child = Entry::Deserialize(*service); | 239 std::unique_ptr<Entry> child = Entry::Deserialize(*service); |
| 240 if (child) { | 240 if (child) { |
| 241 child->set_package(entry.get()); | 241 child->set_package(entry.get()); |
| 242 // Caller must assume ownership of these items. | 242 // Caller must assume ownership of these items. |
| 243 entry->children_.emplace_back(std::move(child)); | 243 entry->children_.emplace_back(std::move(child)); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 // Privileged? |
| 249 bool privileged = false; |
| 250 if (value.HasKey(Store::kPrivilegedKey) && |
| 251 value.GetBoolean(Store::kPrivilegedKey, &privileged)) { |
| 252 entry->set_privileged(privileged); |
| 253 } |
| 254 |
| 248 return entry; | 255 return entry; |
| 249 } | 256 } |
| 250 | 257 |
| 251 bool Entry::ProvidesClass(const std::string& clazz) const { | 258 bool Entry::ProvidesClass(const std::string& clazz) const { |
| 252 return capabilities_.provided.find(clazz) != capabilities_.provided.end(); | 259 return capabilities_.provided.find(clazz) != capabilities_.provided.end(); |
| 253 } | 260 } |
| 254 | 261 |
| 255 bool Entry::operator==(const Entry& other) const { | 262 bool Entry::operator==(const Entry& other) const { |
| 256 return other.name_ == name_ && other.qualifier_ == qualifier_ && | 263 return other.name_ == name_ && other.qualifier_ == qualifier_ && |
| 257 other.display_name_ == display_name_ && | 264 other.display_name_ == display_name_ && |
| (...skipping 14 matching lines...) Expand all Loading... |
| 272 shell::mojom::ResolveResultPtr | 279 shell::mojom::ResolveResultPtr |
| 273 TypeConverter<shell::mojom::ResolveResultPtr, catalog::Entry>::Convert( | 280 TypeConverter<shell::mojom::ResolveResultPtr, catalog::Entry>::Convert( |
| 274 const catalog::Entry& input) { | 281 const catalog::Entry& input) { |
| 275 shell::mojom::ResolveResultPtr result(shell::mojom::ResolveResult::New()); | 282 shell::mojom::ResolveResultPtr result(shell::mojom::ResolveResult::New()); |
| 276 result->name = input.name(); | 283 result->name = input.name(); |
| 277 const catalog::Entry& package = input.package() ? *input.package() : input; | 284 const catalog::Entry& package = input.package() ? *input.package() : input; |
| 278 result->resolved_name = package.name(); | 285 result->resolved_name = package.name(); |
| 279 result->qualifier = input.qualifier(); | 286 result->qualifier = input.qualifier(); |
| 280 result->capabilities = input.capabilities(); | 287 result->capabilities = input.capabilities(); |
| 281 result->package_path = package.path(); | 288 result->package_path = package.path(); |
| 289 result->privileged = input.privileged(); |
| 282 return result; | 290 return result; |
| 283 } | 291 } |
| 284 | 292 |
| 285 // static | 293 // static |
| 286 catalog::mojom::EntryPtr | 294 catalog::mojom::EntryPtr |
| 287 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( | 295 TypeConverter<catalog::mojom::EntryPtr, catalog::Entry>::Convert( |
| 288 const catalog::Entry& input) { | 296 const catalog::Entry& input) { |
| 289 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); | 297 catalog::mojom::EntryPtr result(catalog::mojom::Entry::New()); |
| 290 result->name = input.name(); | 298 result->name = input.name(); |
| 291 result->display_name = input.display_name(); | 299 result->display_name = input.display_name(); |
| 292 return result; | 300 return result; |
| 293 } | 301 } |
| 294 | 302 |
| 295 } // namespace mojo | 303 } // namespace mojo |
| OLD | NEW |