| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/chromeos/extensions/default_app_order.h" | 5 #include "chrome/browser/chromeos/extensions/default_app_order.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // Reads external ordinal json file and returned the parsed value. Returns NULL | 59 // Reads external ordinal json file and returned the parsed value. Returns NULL |
| 60 // if the file does not exist or could not be parsed properly. Caller takes | 60 // if the file does not exist or could not be parsed properly. Caller takes |
| 61 // ownership of the returned value. | 61 // ownership of the returned value. |
| 62 base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { | 62 base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { |
| 63 if (!base::PathExists(path)) | 63 if (!base::PathExists(path)) |
| 64 return NULL; | 64 return NULL; |
| 65 | 65 |
| 66 JSONFileValueDeserializer deserializer(path); | 66 JSONFileValueDeserializer deserializer(path); |
| 67 std::string error_msg; | 67 std::string error_msg; |
| 68 base::Value* value = deserializer.Deserialize(NULL, &error_msg); | 68 base::Value* value = deserializer.Deserialize(NULL, &error_msg).release(); |
| 69 if (!value) { | 69 if (!value) { |
| 70 LOG(WARNING) << "Unable to deserialize default app ordinals json data:" | 70 LOG(WARNING) << "Unable to deserialize default app ordinals json data:" |
| 71 << error_msg << ", file=" << path.value(); | 71 << error_msg << ", file=" << path.value(); |
| 72 return NULL; | 72 return NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 base::ListValue* ordinal_list_value = NULL; | 75 base::ListValue* ordinal_list_value = NULL; |
| 76 if (value->GetAsList(&ordinal_list_value)) | 76 if (value->GetAsList(&ordinal_list_value)) |
| 77 return ordinal_list_value; | 77 return ordinal_list_value; |
| 78 | 78 |
| 79 LOG(WARNING) << "Expect a JSON list in file " << path.value(); | 79 LOG(WARNING) << "Expect a JSON list in file " << path.value(); |
| 80 // TODO(Olli Raula) possible memory leak http://crbug.com/543015 |
| 80 return NULL; | 81 return NULL; |
| 81 } | 82 } |
| 82 | 83 |
| 83 std::string GetLocaleSpecificStringImpl( | 84 std::string GetLocaleSpecificStringImpl( |
| 84 const base::DictionaryValue* root, | 85 const base::DictionaryValue* root, |
| 85 const std::string& locale, | 86 const std::string& locale, |
| 86 const std::string& dictionary_name, | 87 const std::string& dictionary_name, |
| 87 const std::string& entry_name) { | 88 const std::string& entry_name) { |
| 88 const base::DictionaryValue* dictionary_content = NULL; | 89 const base::DictionaryValue* dictionary_content = NULL; |
| 89 if (!root || !root->GetDictionary(dictionary_name, &dictionary_content)) | 90 if (!root || !root->GetDictionary(dictionary_name, &dictionary_content)) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 std::string GetOemAppsFolderName() { | 195 std::string GetOemAppsFolderName() { |
| 195 // |loader_instance| could be NULL for test. | 196 // |loader_instance| could be NULL for test. |
| 196 if (!loader_instance) | 197 if (!loader_instance) |
| 197 return std::string(); | 198 return std::string(); |
| 198 else | 199 else |
| 199 return loader_instance->GetOemAppsFolderName(); | 200 return loader_instance->GetOemAppsFolderName(); |
| 200 } | 201 } |
| 201 | 202 |
| 202 } // namespace default_app_order | 203 } // namespace default_app_order |
| 203 } // namespace chromeos | 204 } // namespace chromeos |
| OLD | NEW |