Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: components/resource_provider/file_utils.cc

Issue 1850623004: Create .mojo applications in a common subdir under out/Debug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/BUILD.gn ('k') | mojo/public/mojo_application.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/resource_provider/file_utils.h" 5 #include "components/resource_provider/file_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 base::FilePath base_path; 62 base::FilePath base_path;
63 #if defined(OS_ANDROID) 63 #if defined(OS_ANDROID)
64 PathService::Get(base::DIR_ANDROID_APP_DATA, &base_path); 64 PathService::Get(base::DIR_ANDROID_APP_DATA, &base_path);
65 // |base_path| on android has an additional path, need to go up a level to get 65 // |base_path| on android has an additional path, need to go up a level to get
66 // at other apps resources. 66 // at other apps resources.
67 base_path = base_path.DirName(); 67 base_path = base_path.DirName();
68 base_path = base_path.AppendASCII("app_cached_apps"); 68 base_path = base_path.AppendASCII("app_cached_apps");
69 #else 69 #else
70 PathService::Get(base::DIR_EXE, &base_path); 70 PathService::Get(base::DIR_EXE, &base_path);
71 #endif 71 #endif
72 return base_path.AppendASCII(path).AppendASCII("resources"); 72 // TODO(beng): this won't handle user-specific components.
73 return base_path.AppendASCII("Mojo Applications").AppendASCII(path).
74 AppendASCII("resources");
73 } 75 }
74 76
75 base::FilePath GetPathForResourceNamed(const base::FilePath& app_path, 77 base::FilePath GetPathForResourceNamed(const base::FilePath& app_path,
76 const std::string& resource_path) { 78 const std::string& resource_path) {
77 CHECK(!app_path.empty()); 79 CHECK(!app_path.empty());
78 80
79 if (resource_path.empty() || resource_path[0] == '/' || 81 if (resource_path.empty() || resource_path[0] == '/' ||
80 resource_path[resource_path.size() - 1] == '/' || 82 resource_path[resource_path.size() - 1] == '/' ||
81 resource_path.find("//") != std::string::npos) 83 resource_path.find("//") != std::string::npos)
82 return base::FilePath(); 84 return base::FilePath();
83 85
84 std::vector<std::string> path_components = base::SplitString( 86 std::vector<std::string> path_components = base::SplitString(
85 resource_path, "/", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 87 resource_path, "/", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
86 if (path_components.empty()) 88 if (path_components.empty())
87 return base::FilePath(); 89 return base::FilePath();
88 90
89 base::FilePath result(app_path); 91 base::FilePath result(app_path);
90 for (const auto& path_component : path_components) { 92 for (const auto& path_component : path_components) {
91 if (!IsPathNameValid(path_component)) 93 if (!IsPathNameValid(path_component))
92 return base::FilePath(); 94 return base::FilePath();
93 result = result.AppendASCII(path_component); 95 result = result.AppendASCII(path_component);
94 } 96 }
95 return result; 97 return result;
96 } 98 }
97 99
98 } // namespace resource_provider 100 } // namespace resource_provider
OLDNEW
« no previous file with comments | « components/mus/BUILD.gn ('k') | mojo/public/mojo_application.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698