OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <map> | 10 #include <map> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // We need to reserve the namespace of entries that start with "_" for future | 93 // We need to reserve the namespace of entries that start with "_" for future |
94 // use by Chrome. | 94 // use by Chrome. |
95 // If any files or directories are found using "_" prefix and are not on | 95 // If any files or directories are found using "_" prefix and are not on |
96 // reserved list we return false, and set error message. | 96 // reserved list we return false, and set error message. |
97 bool CheckForIllegalFilenames(const FilePath& extension_path, | 97 bool CheckForIllegalFilenames(const FilePath& extension_path, |
98 std::string* error); | 98 std::string* error); |
99 | 99 |
100 // Get a relative file path from a chrome-extension:// URL. | 100 // Get a relative file path from a chrome-extension:// URL. |
101 FilePath ExtensionURLToRelativeFilePath(const GURL& url); | 101 FilePath ExtensionURLToRelativeFilePath(const GURL& url); |
102 | 102 |
| 103 // Get a full file path from a chrome-extension-resource:// URL, If the URL |
| 104 // points a file outside of root, this function will return empty FilePath. |
| 105 FilePath ExtensionResourceURLToFilePath(const GURL& url, const FilePath& root); |
| 106 |
103 // Get a path to a temp directory for unpacking an extension. | 107 // Get a path to a temp directory for unpacking an extension. |
104 // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), | 108 // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), |
105 // with a histogram that allows us to understand why it is failing. | 109 // with a histogram that allows us to understand why it is failing. |
106 // Return an empty file path on failure. | 110 // Return an empty file path on failure. |
107 FilePath GetUserDataTempDir(); | 111 FilePath GetUserDataTempDir(); |
108 | 112 |
109 // Helper function to delete files. This is used to avoid ugly casts which | 113 // Helper function to delete files. This is used to avoid ugly casts which |
110 // would be necessary with PostMessage since file_util::Delete is overloaded. | 114 // would be necessary with PostMessage since file_util::Delete is overloaded. |
111 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 115 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
112 void DeleteFile(const FilePath& path, bool recursive); | 116 void DeleteFile(const FilePath& path, bool recursive); |
113 | 117 |
114 } // namespace extension_file_util | 118 } // namespace extension_file_util |
115 | 119 |
116 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 120 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |