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> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 const FilePath& extensions_dir, | 59 const FilePath& extensions_dir, |
60 const std::map<std::string, FilePath>& extension_paths); | 60 const std::map<std::string, FilePath>& extension_paths); |
61 | 61 |
62 // Loads extension message catalogs and returns message bundle. | 62 // Loads extension message catalogs and returns message bundle. |
63 // Returns NULL on error, or if extension is not localized. | 63 // Returns NULL on error, or if extension is not localized. |
64 ExtensionMessageBundle* LoadExtensionMessageBundle( | 64 ExtensionMessageBundle* LoadExtensionMessageBundle( |
65 const FilePath& extension_path, | 65 const FilePath& extension_path, |
66 const std::string& default_locale, | 66 const std::string& default_locale, |
67 std::string* error); | 67 std::string* error); |
68 | 68 |
69 // Loads the extension message bundle substitution map. Will contain at least | |
70 // the entry for the extension ID if extension is valid. | |
Nebojša Ćirić
2011/08/10 20:38:57
Contains at least extension_id item if extension i
adriansc
2011/08/10 23:20:53
Done.
| |
71 std::map<std::string, std::string> LoadExtensionMessageBundleSubstitutionMap( | |
72 const FilePath& extension_path, | |
73 const std::string& extension_id, | |
74 const std::string& default_locale); | |
75 | |
69 // We need to reserve the namespace of entries that start with "_" for future | 76 // We need to reserve the namespace of entries that start with "_" for future |
70 // use by Chrome. | 77 // use by Chrome. |
71 // If any files or directories are found using "_" prefix and are not on | 78 // If any files or directories are found using "_" prefix and are not on |
72 // reserved list we return false, and set error message. | 79 // reserved list we return false, and set error message. |
73 bool CheckForIllegalFilenames(const FilePath& extension_path, | 80 bool CheckForIllegalFilenames(const FilePath& extension_path, |
74 std::string* error); | 81 std::string* error); |
75 | 82 |
76 // Get a relative file path from a chrome-extension:// URL. | 83 // Get a relative file path from a chrome-extension:// URL. |
77 FilePath ExtensionURLToRelativeFilePath(const GURL& url); | 84 FilePath ExtensionURLToRelativeFilePath(const GURL& url); |
78 | 85 |
79 // Get a path to a temp directory for unpacking an extension. | 86 // Get a path to a temp directory for unpacking an extension. |
80 // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), | 87 // This is essentially PathService::Get(chrome::DIR_USER_DATA_TEMP, ...), |
81 // with a histogram that allows us to understand why it is failing. | 88 // with a histogram that allows us to understand why it is failing. |
82 // Return an empty file path on failure. | 89 // Return an empty file path on failure. |
83 FilePath GetUserDataTempDir(); | 90 FilePath GetUserDataTempDir(); |
84 | 91 |
85 // Helper function to delete files. This is used to avoid ugly casts which | 92 // 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. | 93 // 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. | 94 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
88 void DeleteFile(const FilePath& path, bool recursive); | 95 void DeleteFile(const FilePath& path, bool recursive); |
89 | 96 |
90 } // namespace extension_file_util | 97 } // namespace extension_file_util |
91 | 98 |
92 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 99 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |