Chromium Code Reviews| Index: chrome/common/extensions/extension_file_util.cc |
| diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc |
| index a6a85c3b2499d57d6bdbbfbdb9058c71ca740c0f..e744b7b2d6e5edaee57943189a46ef294406d37c 100644 |
| --- a/chrome/common/extensions/extension_file_util.cc |
| +++ b/chrome/common/extensions/extension_file_util.cc |
| @@ -20,6 +20,8 @@ |
| #include "chrome/common/extensions/extension_action.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/extensions/extension_l10n_util.h" |
| +#include "chrome/common/extensions/extension_messages.h" |
| +#include "chrome/common/extensions/extension_message_bundle.h" |
| #include "chrome/common/extensions/extension_resource.h" |
| #include "chrome/common/extensions/extension_sidebar_defaults.h" |
| #include "content/common/json_value_serializer.h" |
| @@ -400,6 +402,30 @@ ExtensionMessageBundle* LoadExtensionMessageBundle( |
| return message_bundle; |
| } |
| +SubstitutionMap* LoadExtensionMessageBundleSubstitutionMap( |
| + const FilePath& extension_path, |
| + const std::string& extension_id, |
| + const std::string& default_locale) { |
| + SubstitutionMap* returnValue = new SubstitutionMap(); |
| + if (!default_locale.empty()) { |
| + // Touch disk only if extension is localized. |
| + std::string error; |
| + scoped_ptr<ExtensionMessageBundle> bundle( |
| + extension_file_util::LoadExtensionMessageBundle( |
|
Mihai Parparita -not on Chrome
2011/08/11 01:58:34
extension_file_util:: namespace prefix is unnecess
adriansc
2011/08/11 21:25:08
Done.
|
| + extension_path, default_locale, &error)); |
| + |
| + if (bundle.get()) |
| + *returnValue = *bundle->dictionary(); |
| + } |
| + |
| + // Add @@extension_id reserved message here, so it's available to |
| + // non-localized extensions too. |
| + returnValue->insert( |
| + std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id)); |
| + |
| + return returnValue; |
| +} |
| + |
| static bool ValidateLocaleInfo(const Extension& extension, std::string* error) { |
| // default_locale and _locales have to be both present or both missing. |
| const FilePath path = extension.path().Append(Extension::kLocaleFolder); |