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

Side by Side Diff: chrome/common/extensions/extension_message_bundle.h

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_MESSAGE_BUNDLE_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGE_BUNDLE_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGE_BUNDLE_H_ 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGE_BUNDLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 14
15 namespace base {
15 class DictionaryValue; 16 class DictionaryValue;
17 }
16 18
17 // Contains localized extension messages for one locale. Any messages that the 19 // Contains localized extension messages for one locale. Any messages that the
18 // locale does not provide are pulled from the default locale. 20 // locale does not provide are pulled from the default locale.
19 class ExtensionMessageBundle { 21 class ExtensionMessageBundle {
20 public: 22 public:
21 typedef std::map<std::string, std::string> SubstitutionMap; 23 typedef std::map<std::string, std::string> SubstitutionMap;
22 typedef std::vector<linked_ptr<DictionaryValue> > CatalogVector; 24 typedef std::vector<linked_ptr<base::DictionaryValue> > CatalogVector;
23 25
24 // JSON keys of interest for messages file. 26 // JSON keys of interest for messages file.
25 static const char* kContentKey; 27 static const char* kContentKey;
26 static const char* kMessageKey; 28 static const char* kMessageKey;
27 static const char* kPlaceholdersKey; 29 static const char* kPlaceholdersKey;
28 30
29 // Begin/end markers for placeholders and messages 31 // Begin/end markers for placeholders and messages
30 static const char* kPlaceholderBegin; 32 static const char* kPlaceholderBegin;
31 static const char* kPlaceholderEnd; 33 static const char* kPlaceholderEnd;
32 static const char* kMessageBegin; 34 static const char* kMessageBegin;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 118
117 // Appends locale specific reserved messages to the dictionary. 119 // Appends locale specific reserved messages to the dictionary.
118 // Returns false if there was a conflict with user defined messages. 120 // Returns false if there was a conflict with user defined messages.
119 bool AppendReservedMessagesForLocale(const std::string& application_locale, 121 bool AppendReservedMessagesForLocale(const std::string& application_locale,
120 std::string* error); 122 std::string* error);
121 123
122 // Helper methods that navigate JSON tree and return simplified message. 124 // Helper methods that navigate JSON tree and return simplified message.
123 // They replace all $PLACEHOLDERS$ with their value, and return just key/value 125 // They replace all $PLACEHOLDERS$ with their value, and return just key/value
124 // of the message. 126 // of the message.
125 bool GetMessageValue(const std::string& key, 127 bool GetMessageValue(const std::string& key,
126 const DictionaryValue& catalog, 128 const base::DictionaryValue& catalog,
127 std::string* value, 129 std::string* value,
128 std::string* error) const; 130 std::string* error) const;
129 131
130 // Get all placeholders for a given message from JSON subtree. 132 // Get all placeholders for a given message from JSON subtree.
131 bool GetPlaceholders(const DictionaryValue& name_tree, 133 bool GetPlaceholders(const base::DictionaryValue& name_tree,
132 const std::string& name_key, 134 const std::string& name_key,
133 SubstitutionMap* placeholders, 135 SubstitutionMap* placeholders,
134 std::string* error) const; 136 std::string* error) const;
135 137
136 // For a given message, replaces all placeholders with their actual value. 138 // For a given message, replaces all placeholders with their actual value.
137 // Returns false if replacement failed (see ReplaceVariables). 139 // Returns false if replacement failed (see ReplaceVariables).
138 bool ReplacePlaceholders(const SubstitutionMap& placeholders, 140 bool ReplacePlaceholders(const SubstitutionMap& placeholders,
139 std::string* message, 141 std::string* message,
140 std::string* error) const; 142 std::string* error) const;
141 143
(...skipping 13 matching lines...) Expand all
155 // A map of extension ID to l10n message map. 157 // A map of extension ID to l10n message map.
156 typedef std::map<std::string, L10nMessagesMap > ExtensionToL10nMessagesMap; 158 typedef std::map<std::string, L10nMessagesMap > ExtensionToL10nMessagesMap;
157 159
158 // Returns the extension_id to messages map. 160 // Returns the extension_id to messages map.
159 ExtensionToL10nMessagesMap* GetExtensionToL10nMessagesMap(); 161 ExtensionToL10nMessagesMap* GetExtensionToL10nMessagesMap();
160 162
161 // Returns message map that matches given extension_id, or NULL. 163 // Returns message map that matches given extension_id, or NULL.
162 L10nMessagesMap* GetL10nMessagesMap(const std::string& extension_id); 164 L10nMessagesMap* GetL10nMessagesMap(const std::string& extension_id);
163 165
164 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGE_BUNDLE_H_ 166 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_MESSAGE_BUNDLE_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_l10n_util.h ('k') | chrome/common/extensions/extension_permission_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698