Index: chrome/browser/extensions/external_extension_util.cc |
diff --git a/chrome/browser/extensions/external_extension_util.cc b/chrome/browser/extensions/external_extension_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c6ebe73e71d8795de4c80e765d533e45e748f167 |
--- /dev/null |
+++ b/chrome/browser/extensions/external_extension_util.cc |
@@ -0,0 +1,40 @@ |
+// 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" |
+ |
+ |
Finnur
2012/04/24 13:03:24
nit: remove extra line.
|
+// Extracts/expect a file content in json format. |
+// Used by the external extension facilities/providers |
+// 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.
|
+// 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.
|
+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.
|
+ 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() << " ."; |
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.
|
+ } 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; |
+} |
+ |