| 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 "mojo/services/catalog/entry.h" | 5 #include "mojo/services/catalog/entry.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "mojo/services/catalog/store.h" | 8 #include "mojo/services/catalog/store.h" |
| 9 #include "mojo/shell/public/cpp/names.h" | 9 #include "mojo/shell/public/cpp/names.h" |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 entry->set_display_name(display_name); | 172 entry->set_display_name(display_name); |
| 173 const base::DictionaryValue* capabilities = nullptr; | 173 const base::DictionaryValue* capabilities = nullptr; |
| 174 if (!value.GetDictionary(Store::kCapabilitiesKey, &capabilities)) { | 174 if (!value.GetDictionary(Store::kCapabilitiesKey, &capabilities)) { |
| 175 LOG(WARNING) << "Entry::Description: dictionary has no capabilities key"; | 175 LOG(WARNING) << "Entry::Description: dictionary has no capabilities key"; |
| 176 return nullptr; | 176 return nullptr; |
| 177 } | 177 } |
| 178 if (manifest_version == 0) | 178 if (manifest_version == 0) |
| 179 entry->set_capabilities(BuildCapabilitiesV0(*capabilities)); | 179 entry->set_capabilities(BuildCapabilitiesV0(*capabilities)); |
| 180 else | 180 else |
| 181 entry->set_capabilities(BuildCapabilitiesV1(*capabilities)); | 181 entry->set_capabilities(BuildCapabilitiesV1(*capabilities)); |
| 182 |
| 183 if (value.HasKey(Store::kApplicationsKey)) { |
| 184 const base::ListValue* applications = nullptr; |
| 185 value.GetList(Store::kApplicationsKey, &applications); |
| 186 for (size_t i = 0; i < applications->GetSize(); ++i) { |
| 187 const base::DictionaryValue* application = nullptr; |
| 188 applications->GetDictionary(i, &application); |
| 189 scoped_ptr<Entry> child = Entry::Deserialize(*application); |
| 190 if (child) |
| 191 entry->applications_.insert(*child); |
| 192 } |
| 193 } |
| 194 |
| 182 return entry; | 195 return entry; |
| 183 } | 196 } |
| 184 | 197 |
| 185 bool Entry::operator==(const Entry& other) const { | 198 bool Entry::operator==(const Entry& other) const { |
| 186 return other.name_ == name_ && other.qualifier_ == qualifier_ && | 199 return other.name_ == name_ && other.qualifier_ == qualifier_ && |
| 187 other.display_name_ == display_name_ && | 200 other.display_name_ == display_name_ && |
| 188 other.capabilities_ == capabilities_; | 201 other.capabilities_ == capabilities_; |
| 189 } | 202 } |
| 190 | 203 |
| 204 bool Entry::operator<(const Entry& other) const { |
| 205 return std::tie(name_, qualifier_, display_name_, capabilities_) < |
| 206 std::tie(other.name_, other.qualifier_, other.display_name_, |
| 207 other.capabilities_); |
| 208 } |
| 209 |
| 191 } // catalog | 210 } // catalog |
| OLD | NEW |