1 // Copyright 2013 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.
5 #include "components/safe_json/safe_json_parser.h"
7 #if defined(OS_ANDROID)
8 #include "components/safe_json/safe_json_parser_android.h"
10 #include "components/safe_json/safe_json_parser_impl.h"
17 SafeJsonParser::Factory g_factory
= nullptr;
19 SafeJsonParser
* Create(const std::string
& unsafe_json
,
20 const SafeJsonParser::SuccessCallback
& success_callback
,
21 const SafeJsonParser::ErrorCallback
& error_callback
) {
23 return g_factory(unsafe_json
, success_callback
, error_callback
);
25 #if defined(OS_ANDROID)
26 return new SafeJsonParserAndroid(unsafe_json
, success_callback
,
29 return new SafeJsonParserImpl(unsafe_json
, success_callback
, error_callback
);
36 void SafeJsonParser::SetFactoryForTesting(Factory factory
) {
41 void SafeJsonParser::Parse(const std::string
& unsafe_json
,
42 const SuccessCallback
& success_callback
,
43 const ErrorCallback
& error_callback
) {
44 SafeJsonParser
* parser
=
45 Create(unsafe_json
, success_callback
, error_callback
);
49 } // namespace safe_json