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,36 @@ |
+// 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. |
+DictionaryValue* ExternalExtensionUtil::ExtractPrefs(const FilePath& path, |
+ 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.
|
+ 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; |
+} |
+ |