Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4348)

Unified Diff: chrome/common/extensions/extension_file_util.cc

Issue 7552028: Injected CSS localization fix (see bug no.) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Inserted whitespace. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3370fadb8a23a3a04b3bcc336e13e9804df8c463 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;
+ if (!default_locale.empty()) {
+ // Touch disk only if extension is localized.
+ std::string error;
+ scoped_ptr<ExtensionMessageBundle> bundle(
+ extension_file_util::LoadExtensionMessageBundle(
+ 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;
Nebojša Ćirić 2011/08/10 20:38:57 I am torn between ext_i18n_utils, message_bundle o
adriansc 2011/08/10 23:20:53 Perhaps we should get rid of the static functions
+}
+
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);

Powered by Google App Engine
This is Rietveld 408576698