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

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

Issue 570007: Replace __MSG_some_name__ template within extension css/html files with local... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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_message_bundle.cc
===================================================================
--- chrome/common/extensions/extension_message_bundle.cc (revision 38490)
+++ chrome/common/extensions/extension_message_bundle.cc (working copy)
@@ -11,6 +11,7 @@
#include "base/hash_tables.h"
#include "base/linked_ptr.h"
#include "base/scoped_ptr.h"
+#include "base/singleton.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "base/values.h"
@@ -209,10 +210,16 @@
bool ExtensionMessageBundle::ReplaceMessages(std::string* text,
std::string* error) const {
- return ReplaceVariables(dictionary_, kMessageBegin, kMessageEnd, text, error);
+ return ReplaceMessagesWithExternalDictionary(dictionary_, text, error);
}
// static
+bool ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary(
+ const SubstitutionMap& dictionary, std::string* text, std::string* error) {
+ return ReplaceVariables(dictionary, kMessageBegin, kMessageEnd, text, error);
+}
+
+// static
bool ExtensionMessageBundle::ReplaceVariables(
const SubstitutionMap& variables,
const std::string& var_begin_delimiter,
@@ -283,3 +290,22 @@
return "";
}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Renderer helper functions.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+ExtensionToL10nMessagesMap* GetExtensionToL10nMessagesMap() {
+ return &Singleton<ExtensionToMessagesMap>()->messages_map;
+}
+
+L10nMessagesMap* GetL10nMessagesMap(const std::string extension_id) {
+ ExtensionToL10nMessagesMap::iterator it =
+ Singleton<ExtensionToMessagesMap>()->messages_map.find(extension_id);
+ if (it != Singleton<ExtensionToMessagesMap>()->messages_map.end())
+ return &(it->second);
+
+ return NULL;
+}
« no previous file with comments | « chrome/common/extensions/extension_message_bundle.h ('k') | chrome/common/extensions/extension_message_bundle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698