OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 for (auto c : name) { | 22 for (auto c : name) { |
23 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && | 23 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && |
24 c != '_' && c != '.') | 24 c != '_' && c != '.') |
25 return false; | 25 return false; |
26 } | 26 } |
27 return true; | 27 return true; |
28 } | 28 } |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 base::FilePath GetPathForApplicationUrl(const std::string& application_url) { | 32 base::FilePath GetPathForApplicationName(const std::string& application_name) { |
33 // We don't want to use GURL because it can behave differently depending on | 33 std::string path = application_name; |
34 // whether mojo:// has been registered as a standard scheme or not. Also, we | |
35 // can get mojo:foo or mojo://foo urls here. | |
36 std::string path = application_url; | |
37 const bool is_mojo = | 34 const bool is_mojo = |
38 base::StartsWith(path, "mojo:", base::CompareCase::INSENSITIVE_ASCII); | 35 base::StartsWith(path, "mojo:", base::CompareCase::INSENSITIVE_ASCII); |
39 const bool is_exe = | 36 const bool is_exe = |
40 !is_mojo && | 37 !is_mojo && |
41 base::StartsWith(path, "exe:", base::CompareCase::INSENSITIVE_ASCII); | 38 base::StartsWith(path, "exe:", base::CompareCase::INSENSITIVE_ASCII); |
42 if (!is_mojo && !is_exe) | 39 if (!is_mojo && !is_exe) |
43 return base::FilePath(); | 40 return base::FilePath(); |
44 if (path.find('.') != std::string::npos) | 41 if (path.find('.') != std::string::npos) |
45 return base::FilePath(); | 42 return base::FilePath(); |
46 if (is_mojo) | 43 if (is_mojo) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::FilePath result(app_path); | 89 base::FilePath result(app_path); |
93 for (const auto& path_component : path_components) { | 90 for (const auto& path_component : path_components) { |
94 if (!IsPathNameValid(path_component)) | 91 if (!IsPathNameValid(path_component)) |
95 return base::FilePath(); | 92 return base::FilePath(); |
96 result = result.AppendASCII(path_component); | 93 result = result.AppendASCII(path_component); |
97 } | 94 } |
98 return result; | 95 return result; |
99 } | 96 } |
100 | 97 |
101 } // namespace resource_provider | 98 } // namespace resource_provider |
OLD | NEW |