blob: 7d2bbfdd1302e503e4c8ba5f011bd9a3c0944e89 [file] [log] [blame]
// Copyright 2013 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 "components/safe_json/safe_json_parser.h"
#include "build/build_config.h"
#if defined(OS_ANDROID)
#include "components/safe_json/safe_json_parser_android.h"
#include "components/safe_json/safe_json_parser_impl.h"
namespace safe_json {
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,
return new SafeJsonParserImpl(unsafe_json, success_callback, error_callback);
} // namespace
// static
void SafeJsonParser::SetFactoryForTesting(Factory factory) {
g_factory = factory;
// static
void SafeJsonParser::Parse(const std::string& unsafe_json,
const SuccessCallback& success_callback,
const ErrorCallback& error_callback) {
SafeJsonParser* parser =
Create(unsafe_json, success_callback, error_callback);
} // namespace safe_json