Avi Drissman | 60039d4 | 2022-09-13 21:49:05 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Devlin Cronin | b25ac33 | 2022-01-27 21:56:29 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef EXTENSIONS_BROWSER_L10N_FILE_UTIL_H_ |
| 6 | #define EXTENSIONS_BROWSER_L10N_FILE_UTIL_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "extensions/common/extension_id.h" |
| 12 | #include "extensions/common/message_bundle.h" |
| 13 | |
| 14 | namespace base { |
| 15 | class FilePath; |
| 16 | } |
| 17 | |
| 18 | namespace extension_l10n_util { |
| 19 | enum class GzippedMessagesPermission; |
| 20 | } |
| 21 | |
| 22 | namespace extensions::l10n_file_util { |
| 23 | |
| 24 | // TODO(devlin): All these methods return ownership of the object. Make them |
| 25 | // return unique_ptrs. |
| 26 | |
| 27 | // Loads the extension message bundle substitution map. Contains at least |
| 28 | // the extension_id item. Does not supported compressed locale files. Passes |
| 29 | // |gzip_permission| to extension_l10n_util::LoadMessageCatalogs (see |
| 30 | // extension_l10n_util.h). |
| 31 | MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMap( |
| 32 | const base::FilePath& extension_path, |
| 33 | const ExtensionId& extension_id, |
| 34 | const std::string& default_locale, |
| 35 | extension_l10n_util::GzippedMessagesPermission gzip_permission); |
| 36 | |
| 37 | // Loads the extension message bundle substitution map for a non-localized |
| 38 | // extension. Contains only the extension_id item. |
| 39 | // This doesn't require hitting disk, so it's safe to call on any thread. |
| 40 | MessageBundle::SubstitutionMap* LoadNonLocalizedMessageBundleSubstitutionMap( |
| 41 | const ExtensionId& extension_id); |
| 42 | |
| 43 | // Loads the extension message bundle substitution map from the specified paths. |
| 44 | // Contains at least the extension_id item. Passes |gzip_permission| to |
| 45 | // extension_l10n_util::LoadMessageCatalogs (see extension_l10n_util.h). |
| 46 | MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMapFromPaths( |
| 47 | const std::vector<base::FilePath>& paths, |
| 48 | const ExtensionId& extension_id, |
| 49 | const std::string& default_locale, |
| 50 | extension_l10n_util::GzippedMessagesPermission gzip_permission); |
| 51 | |
| 52 | } // namespace extensions::l10n_file_util |
| 53 | |
| 54 | #endif // EXTENSIONS_BROWSER_L10N_FILE_UTIL_H_ |