Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1606)

Unified Diff: components/safe_json/safe_json_parser.cc

Issue 1203083002: Add a JSON sanitizer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build files Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/safe_json/json_sanitizer_unittest.cc ('k') | components/safe_json/safe_json_parser_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_json/safe_json_parser.cc
diff --git a/components/safe_json/safe_json_parser.cc b/components/safe_json/safe_json_parser.cc
index 8193d0358e42fee709e2e7904937ef8ec5f2d24b..653800e0d0586a8384b1b5c4d98b3b791e07c8ee 100644
--- a/components/safe_json/safe_json_parser.cc
+++ b/components/safe_json/safe_json_parser.cc
@@ -4,7 +4,11 @@
#include "components/safe_json/safe_json_parser.h"
+#if defined(OS_ANDROID)
+#include "components/safe_json/safe_json_parser_android.h"
+#else
#include "components/safe_json/safe_json_parser_impl.h"
+#endif
namespace safe_json {
@@ -12,6 +16,20 @@ namespace {
SafeJsonParser::Factory g_factory = nullptr;
+SafeJsonParser* Create(const std::string& unsafe_json,
+ const SafeJsonParser::SuccessCallback& success_callback,
+ const SafeJsonParser::ErrorCallback& error_callback) {
+ if (g_factory)
+ return g_factory(unsafe_json, success_callback, error_callback);
+
+#if defined(OS_ANDROID)
+ return new SafeJsonParserAndroid(unsafe_json, success_callback,
+ error_callback);
+#else
+ return new SafeJsonParserImpl(unsafe_json, success_callback, error_callback);
+#endif
+}
+
} // namespace
// static
@@ -24,9 +42,7 @@ void SafeJsonParser::Parse(const std::string& unsafe_json,
const SuccessCallback& success_callback,
const ErrorCallback& error_callback) {
SafeJsonParser* parser =
- g_factory ? g_factory(unsafe_json, success_callback, error_callback)
- : new SafeJsonParserImpl(unsafe_json, success_callback,
- error_callback);
+ Create(unsafe_json, success_callback, error_callback);
parser->Start();
}
« no previous file with comments | « components/safe_json/json_sanitizer_unittest.cc ('k') | components/safe_json/safe_json_parser_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698