| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/extensions/extension_l10n_util.h" | 5 #include "chrome/common/extensions/extension_l10n_util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Loads contents of the messages file for given locale. If file is not found, | 243 // Loads contents of the messages file for given locale. If file is not found, |
| 244 // or there was parsing error we return NULL and set |error|. | 244 // or there was parsing error we return NULL and set |error|. |
| 245 // Caller owns the returned object. | 245 // Caller owns the returned object. |
| 246 static DictionaryValue* LoadMessageFile(const FilePath& locale_path, | 246 static DictionaryValue* LoadMessageFile(const FilePath& locale_path, |
| 247 const std::string& locale, | 247 const std::string& locale, |
| 248 std::string* error) { | 248 std::string* error) { |
| 249 std::string extension_locale = locale; | 249 std::string extension_locale = locale; |
| 250 FilePath file = locale_path.AppendASCII(extension_locale) | 250 FilePath file = locale_path.AppendASCII(extension_locale) |
| 251 .Append(Extension::kMessagesFilename); | 251 .Append(Extension::kMessagesFilename); |
| 252 JSONFileValueSerializer messages_serializer(file); | 252 JSONFileValueSerializer messages_serializer(file); |
| 253 Value *dictionary = messages_serializer.Deserialize(error); | 253 Value *dictionary = messages_serializer.Deserialize(NULL, error); |
| 254 if (!dictionary && error->empty()) { | 254 if (!dictionary && error->empty()) { |
| 255 // JSONFileValueSerializer just returns NULL if file cannot be found. It | 255 // JSONFileValueSerializer just returns NULL if file cannot be found. It |
| 256 // doesn't set the error, so we have to do it. | 256 // doesn't set the error, so we have to do it. |
| 257 *error = StringPrintf("Catalog file is missing for locale %s.", | 257 *error = StringPrintf("Catalog file is missing for locale %s.", |
| 258 extension_locale.c_str()); | 258 extension_locale.c_str()); |
| 259 } | 259 } |
| 260 | 260 |
| 261 return static_cast<DictionaryValue*>(dictionary); | 261 return static_cast<DictionaryValue*>(dictionary); |
| 262 } | 262 } |
| 263 | 263 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 if (std::find(subdir.begin(), subdir.end(), L'.') != subdir.end()) | 305 if (std::find(subdir.begin(), subdir.end(), L'.') != subdir.end()) |
| 306 return true; | 306 return true; |
| 307 | 307 |
| 308 if (all_locales.find(WideToASCII(subdir)) == all_locales.end()) | 308 if (all_locales.find(WideToASCII(subdir)) == all_locales.end()) |
| 309 return true; | 309 return true; |
| 310 | 310 |
| 311 return false; | 311 return false; |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace extension_l10n_util | 314 } // namespace extension_l10n_util |
| OLD | NEW |