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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "chrome/common/extensions/message_bundle.h" | 12 #include "chrome/common/extensions/message_bundle.h" |
13 #include "extensions/common/manifest.h" | 13 #include "extensions/common/manifest.h" |
14 | 14 |
15 class ExtensionIconSet; | 15 class ExtensionIconSet; |
16 class GURL; | |
17 | 16 |
18 namespace base { | 17 namespace base { |
19 class DictionaryValue; | 18 class DictionaryValue; |
20 class FilePath; | 19 class FilePath; |
21 } | 20 } |
22 | 21 |
23 namespace extensions { | 22 namespace extensions { |
24 class Extension; | 23 class Extension; |
25 class MessageBundle; | 24 class MessageBundle; |
26 struct InstallWarning; | 25 struct InstallWarning; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const std::string& extension_id, | 118 const std::string& extension_id, |
120 const std::string& default_locale); | 119 const std::string& default_locale); |
121 | 120 |
122 // We need to reserve the namespace of entries that start with "_" for future | 121 // We need to reserve the namespace of entries that start with "_" for future |
123 // use by Chrome. | 122 // use by Chrome. |
124 // If any files or directories are found using "_" prefix and are not on | 123 // If any files or directories are found using "_" prefix and are not on |
125 // reserved list we return false, and set error message. | 124 // reserved list we return false, and set error message. |
126 bool CheckForIllegalFilenames(const base::FilePath& extension_path, | 125 bool CheckForIllegalFilenames(const base::FilePath& extension_path, |
127 std::string* error); | 126 std::string* error); |
128 | 127 |
129 // Get a relative file path from a chrome-extension:// URL. | |
130 base::FilePath ExtensionURLToRelativeFilePath(const GURL& url); | |
131 | |
132 // Get a full file path from a chrome-extension-resource:// URL, If the URL | |
133 // points a file outside of root, this function will return empty FilePath. | |
134 base::FilePath ExtensionResourceURLToFilePath(const GURL& url, | |
135 const base::FilePath& root); | |
136 | |
137 // Returns a path to a temporary directory for unpacking an extension that will | 128 // Returns a path to a temporary directory for unpacking an extension that will |
138 // be installed into |extensions_dir|. Creates the directory if necessary. | 129 // be installed into |extensions_dir|. Creates the directory if necessary. |
139 // The directory will be on the same file system as |extensions_dir| so | 130 // The directory will be on the same file system as |extensions_dir| so |
140 // that the extension directory can be efficiently renamed into place. Returns | 131 // that the extension directory can be efficiently renamed into place. Returns |
141 // an empty file path on failure. | 132 // an empty file path on failure. |
142 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); | 133 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); |
143 | 134 |
144 // Helper function to delete files. This is used to avoid ugly casts which | 135 // Helper function to delete files. This is used to avoid ugly casts which |
145 // would be necessary with PostMessage since base::Delete is overloaded. | 136 // would be necessary with PostMessage since base::Delete is overloaded. |
146 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 137 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
147 void DeleteFile(const base::FilePath& path, bool recursive); | 138 void DeleteFile(const base::FilePath& path, bool recursive); |
148 | 139 |
149 } // namespace extension_file_util | 140 } // namespace extension_file_util |
150 | 141 |
151 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 142 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |