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 <string> | 8 #include <string> |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/extensions/extension_message_bundle.h" | 12 #include "chrome/common/extensions/message_bundle.h" |
13 | 13 |
14 class ExtensionMessageBundle; | |
15 class FilePath; | 14 class FilePath; |
16 class GURL; | 15 class GURL; |
| 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 } | 19 } |
20 | 20 |
| 21 namespace extensions { |
| 22 class MessageBundle; |
| 23 } |
| 24 |
21 // Utilities for manipulating the on-disk storage of extensions. | 25 // Utilities for manipulating the on-disk storage of extensions. |
22 namespace extension_file_util { | 26 namespace extension_file_util { |
23 | 27 |
24 // The name of the directory inside the profile that we store installed | 28 // The name of the directory inside the profile that we store installed |
25 // extension in. | 29 // extension in. |
26 extern const char kInstallDirectoryName[]; | 30 extern const char kInstallDirectoryName[]; |
27 | 31 |
28 // Copies |unpacked_source_dir| into the right location under |extensions_dir|. | 32 // Copies |unpacked_source_dir| into the right location under |extensions_dir|. |
29 // 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 |
30 // on failure. | 34 // on failure. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // map from extension id to full installation path. | 83 // map from extension id to full installation path. |
80 // | 84 // |
81 // Obsolete version directories are removed, as are directories that aren't | 85 // Obsolete version directories are removed, as are directories that aren't |
82 // found in |extension_paths|. | 86 // found in |extension_paths|. |
83 void GarbageCollectExtensions( | 87 void GarbageCollectExtensions( |
84 const FilePath& extensions_dir, | 88 const FilePath& extensions_dir, |
85 const std::map<std::string, FilePath>& extension_paths); | 89 const std::map<std::string, FilePath>& extension_paths); |
86 | 90 |
87 // Loads extension message catalogs and returns message bundle. | 91 // Loads extension message catalogs and returns message bundle. |
88 // Returns NULL on error, or if extension is not localized. | 92 // Returns NULL on error, or if extension is not localized. |
89 ExtensionMessageBundle* LoadExtensionMessageBundle( | 93 extensions::MessageBundle* LoadMessageBundle( |
90 const FilePath& extension_path, | 94 const FilePath& extension_path, |
91 const std::string& default_locale, | 95 const std::string& default_locale, |
92 std::string* error); | 96 std::string* error); |
93 | 97 |
94 // Loads the extension message bundle substitution map. Contains at least | 98 // Loads the extension message bundle substitution map. Contains at least |
95 // extension_id item. | 99 // extension_id item. |
96 ExtensionMessageBundle::SubstitutionMap* | 100 extensions::MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMap( |
97 LoadExtensionMessageBundleSubstitutionMap( | |
98 const FilePath& extension_path, | 101 const FilePath& extension_path, |
99 const std::string& extension_id, | 102 const std::string& extension_id, |
100 const std::string& default_locale); | 103 const std::string& default_locale); |
101 | 104 |
102 // We need to reserve the namespace of entries that start with "_" for future | 105 // We need to reserve the namespace of entries that start with "_" for future |
103 // use by Chrome. | 106 // use by Chrome. |
104 // If any files or directories are found using "_" prefix and are not on | 107 // If any files or directories are found using "_" prefix and are not on |
105 // reserved list we return false, and set error message. | 108 // reserved list we return false, and set error message. |
106 bool CheckForIllegalFilenames(const FilePath& extension_path, | 109 bool CheckForIllegalFilenames(const FilePath& extension_path, |
107 std::string* error); | 110 std::string* error); |
(...skipping 12 matching lines...) Expand all Loading... |
120 FilePath GetUserDataTempDir(); | 123 FilePath GetUserDataTempDir(); |
121 | 124 |
122 // Helper function to delete files. This is used to avoid ugly casts which | 125 // Helper function to delete files. This is used to avoid ugly casts which |
123 // would be necessary with PostMessage since file_util::Delete is overloaded. | 126 // would be necessary with PostMessage since file_util::Delete is overloaded. |
124 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 127 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
125 void DeleteFile(const FilePath& path, bool recursive); | 128 void DeleteFile(const FilePath& path, bool recursive); |
126 | 129 |
127 } // namespace extension_file_util | 130 } // namespace extension_file_util |
128 | 131 |
129 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 132 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |