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/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "chrome/common/extensions/message_bundle.h" | |
14 #include "extensions/common/manifest.h" | 13 #include "extensions/common/manifest.h" |
15 | 14 |
16 class ExtensionIconSet; | 15 class ExtensionIconSet; |
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; | |
26 struct InstallWarning; | 24 struct InstallWarning; |
27 } | 25 } |
28 | 26 |
29 // Utilities for manipulating the on-disk storage of extensions. | 27 // Utilities for manipulating the on-disk storage of extensions. |
30 namespace extension_file_util { | 28 namespace extension_file_util { |
31 | 29 |
32 extern const base::FilePath::CharType kTempDirectoryName[]; | 30 extern const base::FilePath::CharType kTempDirectoryName[]; |
33 | 31 |
34 // Copies |unpacked_source_dir| into the right location under |extensions_dir|. | 32 // Copies |unpacked_source_dir| into the right location under |extensions_dir|. |
35 // The destination directory is returned on success, or empty path is returned | 33 // The destination directory is returned on success, or empty path is returned |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Returns a list of paths (relative to the extension dir) for images that | 85 // Returns a list of paths (relative to the extension dir) for images that |
88 // the browser might load (like themes and page action icons) for the given | 86 // the browser might load (like themes and page action icons) for the given |
89 // extension. | 87 // extension. |
90 std::set<base::FilePath> GetBrowserImagePaths( | 88 std::set<base::FilePath> GetBrowserImagePaths( |
91 const extensions::Extension* extension); | 89 const extensions::Extension* extension); |
92 | 90 |
93 // Returns a list of files that contain private keys inside |extension_dir|. | 91 // Returns a list of files that contain private keys inside |extension_dir|. |
94 std::vector<base::FilePath> FindPrivateKeyFiles( | 92 std::vector<base::FilePath> FindPrivateKeyFiles( |
95 const base::FilePath& extension_dir); | 93 const base::FilePath& extension_dir); |
96 | 94 |
97 // Loads extension message catalogs and returns message bundle. | |
98 // Returns NULL on error, or if extension is not localized. | |
99 extensions::MessageBundle* LoadMessageBundle( | |
100 const base::FilePath& extension_path, | |
101 const std::string& default_locale, | |
102 std::string* error); | |
103 | |
104 // Loads the extension message bundle substitution map. Contains at least | |
105 // extension_id item. | |
106 extensions::MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMap( | |
107 const base::FilePath& extension_path, | |
108 const std::string& extension_id, | |
109 const std::string& default_locale); | |
110 | |
111 // We need to reserve the namespace of entries that start with "_" for future | 95 // We need to reserve the namespace of entries that start with "_" for future |
112 // use by Chrome. | 96 // use by Chrome. |
113 // If any files or directories are found using "_" prefix and are not on | 97 // If any files or directories are found using "_" prefix and are not on |
114 // reserved list we return false, and set error message. | 98 // reserved list we return false, and set error message. |
115 bool CheckForIllegalFilenames(const base::FilePath& extension_path, | 99 bool CheckForIllegalFilenames(const base::FilePath& extension_path, |
116 std::string* error); | 100 std::string* error); |
117 | 101 |
118 // Returns a path to a temporary directory for unpacking an extension that will | 102 // Returns a path to a temporary directory for unpacking an extension that will |
119 // be installed into |extensions_dir|. Creates the directory if necessary. | 103 // be installed into |extensions_dir|. Creates the directory if necessary. |
120 // The directory will be on the same file system as |extensions_dir| so | 104 // The directory will be on the same file system as |extensions_dir| so |
121 // that the extension directory can be efficiently renamed into place. Returns | 105 // that the extension directory can be efficiently renamed into place. Returns |
122 // an empty file path on failure. | 106 // an empty file path on failure. |
123 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); | 107 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); |
124 | 108 |
125 // Helper function to delete files. This is used to avoid ugly casts which | 109 // Helper function to delete files. This is used to avoid ugly casts which |
126 // would be necessary with PostMessage since base::Delete is overloaded. | 110 // would be necessary with PostMessage since base::Delete is overloaded. |
127 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 111 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
128 void DeleteFile(const base::FilePath& path, bool recursive); | 112 void DeleteFile(const base::FilePath& path, bool recursive); |
129 | 113 |
130 } // namespace extension_file_util | 114 } // namespace extension_file_util |
131 | 115 |
132 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 116 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |