| 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/catalog.h" | 5 #include "mojo/services/catalog/catalog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| 11 #include "mojo/common/url_type_converters.h" | 11 #include "mojo/common/url_type_converters.h" |
| 12 #include "mojo/services/catalog/entry.h" | 12 #include "mojo/services/catalog/entry.h" |
| 13 #include "mojo/services/catalog/store.h" | 13 #include "mojo/services/catalog/store.h" |
| 14 #include "mojo/shell/public/cpp/names.h" | 14 #include "mojo/shell/public/cpp/names.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 #include "url/url_util.h" | 16 #include "url/url_util.h" |
| 17 | 17 |
| 18 namespace catalog { | 18 namespace catalog { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 base::FilePath GetManifestPath(const base::FilePath& package_dir, | 21 base::FilePath GetManifestPath(const base::FilePath& package_dir, |
| 22 const std::string& name) { | 22 const std::string& name) { |
| 23 // TODO(beng): think more about how this should be done for exe targets. | 23 // TODO(beng): think more about how this should be done for exe targets. |
| 24 std::string type = mojo::GetNameType(name); | 24 std::string type = mojo::GetNameType(name); |
| 25 std::string path = mojo::GetNamePath(name); | 25 std::string path = mojo::GetNamePath(name); |
| 26 if (type == mojo::kNameType_Mojo) | 26 if (type == mojo::kNameType_Mojo) { |
| 27 return package_dir.AppendASCII(path + "/manifest.json"); | 27 return package_dir.AppendASCII("Mojo Applications").AppendASCII( |
| 28 path + "/manifest.json"); |
| 29 } |
| 28 if (type == mojo::kNameType_Exe) | 30 if (type == mojo::kNameType_Exe) |
| 29 return package_dir.AppendASCII(path + "_manifest.json"); | 31 return package_dir.AppendASCII(path + "_manifest.json"); |
| 30 return base::FilePath(); | 32 return base::FilePath(); |
| 31 } | 33 } |
| 32 | 34 |
| 33 base::FilePath GetPackagePath(const base::FilePath& package_dir, | 35 base::FilePath GetPackagePath(const base::FilePath& package_dir, |
| 34 const std::string& name) { | 36 const std::string& name) { |
| 35 std::string type = mojo::GetNameType(name); | 37 std::string type = mojo::GetNameType(name); |
| 36 if (type == mojo::kNameType_Mojo) { | 38 if (type == mojo::kNameType_Mojo) { |
| 37 // It's still a mojo: URL, use the default mapping scheme. | 39 // It's still a mojo: URL, use the default mapping scheme. |
| 38 const std::string host = mojo::GetNamePath(name); | 40 const std::string host = mojo::GetNamePath(name); |
| 39 return package_dir.AppendASCII(host + "/" + host + ".mojo"); | 41 return package_dir.AppendASCII("Mojo Applications").AppendASCII( |
| 42 host + "/" + host + ".mojo"); |
| 40 } | 43 } |
| 41 if (type == mojo::kNameType_Exe) { | 44 if (type == mojo::kNameType_Exe) { |
| 42 #if defined OS_WIN | 45 #if defined OS_WIN |
| 43 std::string extension = ".exe"; | 46 std::string extension = ".exe"; |
| 44 #else | 47 #else |
| 45 std::string extension; | 48 std::string extension; |
| 46 #endif | 49 #endif |
| 47 return package_dir.AppendASCII(mojo::GetNamePath(name) + extension); | 50 return package_dir.AppendASCII(mojo::GetNamePath(name) + extension); |
| 48 } | 51 } |
| 49 return base::FilePath(); | 52 return base::FilePath(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 EntryCache* catalog = is_system_catalog ? system_catalog_ : &user_catalog_; | 234 EntryCache* catalog = is_system_catalog ? system_catalog_ : &user_catalog_; |
| 232 if (catalog->end() != catalog->find(entry->name())) | 235 if (catalog->end() != catalog->find(entry->name())) |
| 233 return; | 236 return; |
| 234 for (auto child : entry->applications()) | 237 for (auto child : entry->applications()) |
| 235 AddEntryToCatalog(make_scoped_ptr(child), is_system_catalog); | 238 AddEntryToCatalog(make_scoped_ptr(child), is_system_catalog); |
| 236 (*catalog)[entry->name()] = std::move(entry); | 239 (*catalog)[entry->name()] = std::move(entry); |
| 237 SerializeCatalog(); | 240 SerializeCatalog(); |
| 238 } | 241 } |
| 239 | 242 |
| 240 } // namespace catalog | 243 } // namespace catalog |
| OLD | NEW |