| 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 #include "extensions/common/message_bundle.h" | 5 #include "extensions/common/message_bundle.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 "[A-Z], [0-9] and \"_\" are allowed.", | 55 "[A-Z], [0-9] and \"_\" are allowed.", |
| 56 name.c_str()); | 56 name.c_str()); |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // static | 60 // static |
| 61 MessageBundle* MessageBundle::Create(const CatalogVector& locale_catalogs, | 61 MessageBundle* MessageBundle::Create(const CatalogVector& locale_catalogs, |
| 62 std::string* error) { | 62 std::string* error) { |
| 63 scoped_ptr<MessageBundle> message_bundle(new MessageBundle); | 63 scoped_ptr<MessageBundle> message_bundle(new MessageBundle); |
| 64 if (!message_bundle->Init(locale_catalogs, error)) | 64 if (!message_bundle->Init(locale_catalogs, error)) |
| 65 return NULL; | 65 return nullptr; |
| 66 | 66 |
| 67 return message_bundle.release(); | 67 return message_bundle.release(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool MessageBundle::Init(const CatalogVector& locale_catalogs, | 70 bool MessageBundle::Init(const CatalogVector& locale_catalogs, |
| 71 std::string* error) { | 71 std::string* error) { |
| 72 dictionary_.clear(); | 72 dictionary_.clear(); |
| 73 | 73 |
| 74 for (CatalogVector::const_reverse_iterator it = locale_catalogs.rbegin(); | 74 for (CatalogVector::const_reverse_iterator it = locale_catalogs.rbegin(); |
| 75 it != locale_catalogs.rend(); ++it) { | 75 it != locale_catalogs.rend(); ++it) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 ExtensionToL10nMessagesMap* GetExtensionToL10nMessagesMap() { | 331 ExtensionToL10nMessagesMap* GetExtensionToL10nMessagesMap() { |
| 332 return &g_extension_to_messages_map.Get().messages_map; | 332 return &g_extension_to_messages_map.Get().messages_map; |
| 333 } | 333 } |
| 334 | 334 |
| 335 L10nMessagesMap* GetL10nMessagesMap(const std::string& extension_id) { | 335 L10nMessagesMap* GetL10nMessagesMap(const std::string& extension_id) { |
| 336 ExtensionToL10nMessagesMap::iterator it = | 336 ExtensionToL10nMessagesMap::iterator it = |
| 337 g_extension_to_messages_map.Get().messages_map.find(extension_id); | 337 g_extension_to_messages_map.Get().messages_map.find(extension_id); |
| 338 if (it != g_extension_to_messages_map.Get().messages_map.end()) | 338 if (it != g_extension_to_messages_map.Get().messages_map.end()) |
| 339 return &(it->second); | 339 return &(it->second); |
| 340 | 340 |
| 341 return NULL; | 341 return nullptr; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void EraseL10nMessagesMap(const std::string& extension_id) { | 344 void EraseL10nMessagesMap(const std::string& extension_id) { |
| 345 g_extension_to_messages_map.Get().messages_map.erase(extension_id); | 345 g_extension_to_messages_map.Get().messages_map.erase(extension_id); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace extensions | 348 } // namespace extensions |
| OLD | NEW |