Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/external_extension_util.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/file_path.h" | |
| 9 #include "base/file_util.h" | |
| 10 #include "base/json/json_file_value_serializer.h" | |
| 11 #include "base/json/json_string_value_serializer.h" | |
| 12 #include "base/string_util.h" | |
| 13 #include "base/utf_string_conversions.h" | |
| 14 #include "base/values.h" | |
| 15 #include "base/version.h" | |
| 16 | |
| 17 | |
| 18 // Caller takes ownership of the returned dictionary. | |
| 19 DictionaryValue* ExternalExtensionUtil::ExtractPrefs(const FilePath& path, | |
| 20 base::ValueSerializer* serializer) { | |
|
Sam Kerner (Chrome)
2012/04/13 19:35:13
Style nit: "const" and "base::" should line up in
Alexandre Abreu
2012/04/13 21:52:38
Done.
| |
| 21 std::string error_msg; | |
| 22 Value* extensions = serializer->Deserialize(NULL, &error_msg); | |
| 23 if (!extensions) { | |
| 24 LOG(WARNING) << "Unable to deserialize json data: " << error_msg | |
| 25 << " In file " << path.value() << " ."; | |
| 26 } else { | |
| 27 if (!extensions->IsType(Value::TYPE_DICTIONARY)) { | |
| 28 LOG(WARNING) << "Expected a JSON dictionary in file " | |
| 29 << path.value() << " ."; | |
| 30 } else { | |
| 31 return static_cast<DictionaryValue*>(extensions); | |
| 32 } | |
| 33 } | |
| 34 return new DictionaryValue; | |
| 35 } | |
| 36 | |
| OLD | NEW |