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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 274 } |
275 | 275 |
276 // static | 276 // static |
277 bool MessageBundle::IsValidName(const std::string& name) { | 277 bool MessageBundle::IsValidName(const std::string& name) { |
278 if (name.empty()) | 278 if (name.empty()) |
279 return false; | 279 return false; |
280 | 280 |
281 std::string::const_iterator it = name.begin(); | 281 std::string::const_iterator it = name.begin(); |
282 for (; it != name.end(); ++it) { | 282 for (; it != name.end(); ++it) { |
283 // Allow only ascii 0-9, a-z, A-Z, and _ in the name. | 283 // Allow only ascii 0-9, a-z, A-Z, and _ in the name. |
284 if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '_' && *it != '@') | 284 if (!base::IsAsciiAlpha(*it) && !base::IsAsciiDigit(*it) && *it != '_' && |
| 285 *it != '@') |
285 return false; | 286 return false; |
286 } | 287 } |
287 | 288 |
288 return true; | 289 return true; |
289 } | 290 } |
290 | 291 |
291 // Dictionary interface. | 292 // Dictionary interface. |
292 | 293 |
293 std::string MessageBundle::GetL10nMessage(const std::string& name) const { | 294 std::string MessageBundle::GetL10nMessage(const std::string& name) const { |
294 return GetL10nMessage(name, dictionary_); | 295 return GetL10nMessage(name, dictionary_); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 return &(it->second); | 340 return &(it->second); |
340 | 341 |
341 return NULL; | 342 return NULL; |
342 } | 343 } |
343 | 344 |
344 void EraseL10nMessagesMap(const std::string& extension_id) { | 345 void EraseL10nMessagesMap(const std::string& extension_id) { |
345 g_extension_to_messages_map.Get().messages_map.erase(extension_id); | 346 g_extension_to_messages_map.Get().messages_map.erase(extension_id); |
346 } | 347 } |
347 | 348 |
348 } // namespace extensions | 349 } // namespace extensions |
OLD | NEW |