Chromium Code Reviews| Index: chrome/browser/extensions/external_extension_util.cc |
| =================================================================== |
| --- chrome/browser/extensions/external_extension_util.cc (revision 0) |
| +++ chrome/browser/extensions/external_extension_util.cc (revision 0) |
| @@ -0,0 +1,37 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/external_extension_util.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/file_path.h" |
| +#include "base/file_util.h" |
| +#include "base/json/json_file_value_serializer.h" |
| +#include "base/json/json_string_value_serializer.h" |
| +#include "base/string_util.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "base/values.h" |
| +#include "base/version.h" |
| + |
| + |
| +// Caller takes ownership of the returned dictionary. |
|
Sam Kerner (Chrome)
2012/04/13 22:11:02
Now that this is in its own file, a comment explai
Alexandre Abreu
2012/04/13 23:24:46
Done.
|
| +DictionaryValue* ExternalExtensionUtil::ExtractPrefs( |
| + const FilePath& path, |
| + base::ValueSerializer* serializer) { |
| + std::string error_msg; |
| + Value* extensions = serializer->Deserialize(NULL, &error_msg); |
| + if (!extensions) { |
| + LOG(WARNING) << "Unable to deserialize json data: " << error_msg |
| + << " In file " << path.value() << " ."; |
| + } else { |
| + if (!extensions->IsType(Value::TYPE_DICTIONARY)) { |
| + LOG(WARNING) << "Expected a JSON dictionary in file " |
| + << path.value() << " ."; |
| + } else { |
| + return static_cast<DictionaryValue*>(extensions); |
| + } |
| + } |
| + return new DictionaryValue; |
| +} |
| + |