| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_COMMON_MESSAGE_BUNDLE_H_ | 5 #ifndef EXTENSIONS_COMMON_MESSAGE_BUNDLE_H_ |
| 6 #define EXTENSIONS_COMMON_MESSAGE_BUNDLE_H_ | 6 #define EXTENSIONS_COMMON_MESSAGE_BUNDLE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class DictionaryValue; | 15 class DictionaryValue; |
| 16 class Value; | 16 class Value; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 // Contains localized extension messages for one locale. Any messages that the | 21 // Contains localized extension messages for one locale. Any messages that the |
| 22 // locale does not provide are pulled from the default locale. | 22 // locale does not provide are pulled from the default locale. |
| 23 class MessageBundle { | 23 class MessageBundle { |
| 24 public: | 24 public: |
| 25 typedef std::map<std::string, std::string> SubstitutionMap; | 25 typedef std::map<std::string, std::string> SubstitutionMap; |
| 26 typedef std::vector<linked_ptr<base::DictionaryValue> > CatalogVector; | 26 typedef std::vector<linked_ptr<base::DictionaryValue> > CatalogVector; |
| 27 | 27 |
| 28 // JSON keys of interest for messages file. | 28 // JSON keys of interest for messages file. |
| 29 static const char* kContentKey; | 29 static const char kContentKey[]; |
| 30 static const char* kMessageKey; | 30 static const char kMessageKey[]; |
| 31 static const char* kPlaceholdersKey; | 31 static const char kPlaceholdersKey[]; |
| 32 | 32 |
| 33 // Begin/end markers for placeholders and messages | 33 // Begin/end markers for placeholders and messages |
| 34 static const char* kPlaceholderBegin; | 34 static const char kPlaceholderBegin[]; |
| 35 static const char* kPlaceholderEnd; | 35 static const char kPlaceholderEnd[]; |
| 36 static const char* kMessageBegin; | 36 static const char kMessageBegin[]; |
| 37 static const char* kMessageEnd; | 37 static const char kMessageEnd[]; |
| 38 | 38 |
| 39 // Reserved message names in the dictionary. | 39 // Reserved message names in the dictionary. |
| 40 // Update i18n documentation when adding new reserved value. | 40 // Update i18n documentation when adding new reserved value. |
| 41 static const char* kUILocaleKey; | 41 static const char kUILocaleKey[]; |
| 42 // See http://code.google.com/apis/gadgets/docs/i18n.html#BIDI for | 42 // See http://code.google.com/apis/gadgets/docs/i18n.html#BIDI for |
| 43 // description. | 43 // description. |
| 44 // TODO(cira): point to chrome docs once they are out. | 44 // TODO(cira): point to chrome docs once they are out. |
| 45 static const char* kBidiDirectionKey; | 45 static const char kBidiDirectionKey[]; |
| 46 static const char* kBidiReversedDirectionKey; | 46 static const char kBidiReversedDirectionKey[]; |
| 47 static const char* kBidiStartEdgeKey; | 47 static const char kBidiStartEdgeKey[]; |
| 48 static const char* kBidiEndEdgeKey; | 48 static const char kBidiEndEdgeKey[]; |
| 49 // Extension id gets added in the | 49 // Extension id gets added in the |
| 50 // browser/renderer_host/resource_message_filter.cc to enable message | 50 // browser/renderer_host/resource_message_filter.cc to enable message |
| 51 // replacement for non-localized extensions. | 51 // replacement for non-localized extensions. |
| 52 static const char* kExtensionIdKey; | 52 static const char kExtensionIdKey[]; |
| 53 | 53 |
| 54 // Values for some of the reserved messages. | 54 // Values for some of the reserved messages. |
| 55 static const char* kBidiLeftEdgeValue; | 55 static const char kBidiLeftEdgeValue[]; |
| 56 static const char* kBidiRightEdgeValue; | 56 static const char kBidiRightEdgeValue[]; |
| 57 | 57 |
| 58 // Creates MessageBundle or returns NULL if there was an error. Expects | 58 // Creates MessageBundle or returns NULL if there was an error. Expects |
| 59 // locale_catalogs to be sorted from more specific to less specific, with | 59 // locale_catalogs to be sorted from more specific to less specific, with |
| 60 // default catalog at the end. | 60 // default catalog at the end. |
| 61 static MessageBundle* Create(const CatalogVector& locale_catalogs, | 61 static MessageBundle* Create(const CatalogVector& locale_catalogs, |
| 62 std::string* error); | 62 std::string* error); |
| 63 | 63 |
| 64 // Get message from the catalog with given key. | 64 // Get message from the catalog with given key. |
| 65 // Returned message has all of the internal placeholders resolved to their | 65 // Returned message has all of the internal placeholders resolved to their |
| 66 // value (content). | 66 // value (content). |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 // Returns message map that matches given extension_id, or NULL. | 165 // Returns message map that matches given extension_id, or NULL. |
| 166 L10nMessagesMap* GetL10nMessagesMap(const std::string& extension_id); | 166 L10nMessagesMap* GetL10nMessagesMap(const std::string& extension_id); |
| 167 | 167 |
| 168 // Erases the L10nMessagesMap for the given |extension_id|. | 168 // Erases the L10nMessagesMap for the given |extension_id|. |
| 169 void EraseL10nMessagesMap(const std::string& extension_id); | 169 void EraseL10nMessagesMap(const std::string& extension_id); |
| 170 | 170 |
| 171 } // namespace extensions | 171 } // namespace extensions |
| 172 | 172 |
| 173 #endif // EXTENSIONS_COMMON_MESSAGE_BUNDLE_H_ | 173 #endif // EXTENSIONS_COMMON_MESSAGE_BUNDLE_H_ |
| OLD | NEW |