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 | |
|
Finnur
2012/04/24 13:03:24
nit: remove extra line.
| |
| 18 // Extracts/expect a file content in json format. | |
| 19 // Used by the external extension facilities/providers | |
| 20 // to parse their extension manifests. | |
|
Finnur
2012/04/24 13:03:24
nit: Extra space at front.
Alexandre Abreu
2012/04/24 19:30:30
Done.
| |
| 21 // Caller takes ownership of the returned dictionary. | |
|
Finnur
2012/04/24 13:03:24
This should be moved to the .h file. It is also a
Alexandre Abreu
2012/04/24 19:30:30
Done.
| |
| 22 DictionaryValue* ExternalExtensionUtil::ExtractPrefs( | |
|
Finnur
2012/04/24 13:03:24
Hmm... this function is actually, in large part, d
Alexandre Abreu
2012/04/24 19:30:30
Done.
| |
| 23 const FilePath& path, | |
| 24 base::ValueSerializer* serializer) { | |
| 25 std::string error_msg; | |
| 26 Value* extensions = serializer->Deserialize(NULL, &error_msg); | |
| 27 if (!extensions) { | |
| 28 LOG(WARNING) << "Unable to deserialize json data: " << error_msg | |
| 29 << " In file " << path.value() << " ."; | |
|
Finnur
2012/04/24 13:03:24
nit: Extra space before period (also on line 33).
Alexandre Abreu
2012/04/24 19:30:30
Done.
| |
| 30 } else { | |
| 31 if (!extensions->IsType(Value::TYPE_DICTIONARY)) { | |
| 32 LOG(WARNING) << "Expected a JSON dictionary in file " | |
| 33 << path.value() << " ."; | |
| 34 } else { | |
| 35 return static_cast<DictionaryValue*>(extensions); | |
| 36 } | |
| 37 } | |
| 38 return new DictionaryValue; | |
| 39 } | |
| 40 | |
| OLD | NEW |