OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/extension_message_bundle.h" |
13 | 14 |
14 class Extension; | 15 class Extension; |
15 class ExtensionMessageBundle; | 16 class ExtensionMessageBundle; |
16 class FilePath; | 17 class FilePath; |
17 class GURL; | 18 class GURL; |
18 | 19 |
19 // Utilties for manipulating the on-disk storage of extensions. | 20 // Utilties for manipulating the on-disk storage of extensions. |
20 namespace extension_file_util { | 21 namespace extension_file_util { |
21 | 22 |
22 // The name of the directory inside the profile that we store installed | 23 // The name of the directory inside the profile that we store installed |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const FilePath& extensions_dir, | 60 const FilePath& extensions_dir, |
60 const std::map<std::string, FilePath>& extension_paths); | 61 const std::map<std::string, FilePath>& extension_paths); |
61 | 62 |
62 // Loads extension message catalogs and returns message bundle. | 63 // Loads extension message catalogs and returns message bundle. |
63 // Returns NULL on error, or if extension is not localized. | 64 // Returns NULL on error, or if extension is not localized. |
64 ExtensionMessageBundle* LoadExtensionMessageBundle( | 65 ExtensionMessageBundle* LoadExtensionMessageBundle( |
65 const FilePath& extension_path, | 66 const FilePath& extension_path, |
66 const std::string& default_locale, | 67 const std::string& default_locale, |
67 std::string* error); | 68 std::string* error); |
68 | 69 |
| 70 // Loads the extension message bundle substitution map. Contains at least |
| 71 // extension_id item. |
| 72 ExtensionMessageBundle::SubstitutionMap* |
| 73 LoadExtensionMessageBundleSubstitutionMap( |
| 74 const FilePath& extension_path, |
| 75 const std::string& extension_id, |
| 76 const std::string& default_locale); |
| 77 |
69 // We need to reserve the namespace of entries that start with "_" for future | 78 // We need to reserve the namespace of entries that start with "_" for future |
70 // use by Chrome. | 79 // use by Chrome. |
71 // If any files or directories are found using "_" prefix and are not on | 80 // If any files or directories are found using "_" prefix and are not on |
72 // reserved list we return false, and set error message. | 81 // reserved list we return false, and set error message. |
73 bool CheckForIllegalFilenames(const FilePath& extension_path, | 82 bool CheckForIllegalFilenames(const FilePath& extension_path, |
74 std::string* error); | 83 std::string* error); |
75 | 84 |
76 // Get a relative file path from a chrome-extension:// URL. | 85 // Get a relative file path from a chrome-extension:// URL. |
77 FilePath ExtensionURLToRelativeFilePath(const GURL& url); | 86 FilePath ExtensionURLToRelativeFilePath(const GURL& url); |
78 | 87 |
79 // Get a path to a temp directory for unpacking an extension. | 88 // Get a path to a temp directory for unpacking an extension. |
80 // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), | 89 // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), |
81 // with a histogram that allows us to understand why it is failing. | 90 // with a histogram that allows us to understand why it is failing. |
82 // Return an empty file path on failure. | 91 // Return an empty file path on failure. |
83 FilePath GetUserDataTempDir(); | 92 FilePath GetUserDataTempDir(); |
84 | 93 |
85 // Helper function to delete files. This is used to avoid ugly casts which | 94 // Helper function to delete files. This is used to avoid ugly casts which |
86 // would be necessary with PostMessage since file_util::Delete is overloaded. | 95 // would be necessary with PostMessage since file_util::Delete is overloaded. |
87 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 96 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
88 void DeleteFile(const FilePath& path, bool recursive); | 97 void DeleteFile(const FilePath& path, bool recursive); |
89 | 98 |
90 } // namespace extension_file_util | 99 } // namespace extension_file_util |
91 | 100 |
92 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 101 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |