Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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. | |
| 4 | |
| 5 #include "components/safe_json/safe_json_parser_mojo_impl.h" | |
|
Bernhard Bauer
2016/04/13 15:49:08
Technically, we should split this up into a browse
Anand Mistry (off Chromium)
2016/04/14 00:59:49
Well, the utility-side message filter was still in
Bernhard Bauer
2016/04/14 14:11:38
Sure, they get built as different targets, but the
Anand Mistry (off Chromium)
2016/04/18 05:06:45
I've made the change for this latest patchset. How
Bernhard Bauer
2016/04/20 16:43:15
OK, fair enough. It is a rather big change, and in
| |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/json/json_reader.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/values.h" | |
| 12 | |
| 13 namespace safe_json { | |
| 14 | |
| 15 // static | |
| 16 void SafeJsonParserMojoImpl::Create( | |
| 17 mojo::InterfaceRequest<mojom::SafeJsonParser> request) { | |
| 18 new SafeJsonParserMojoImpl(std::move(request)); | |
| 19 } | |
| 20 | |
| 21 SafeJsonParserMojoImpl::SafeJsonParserMojoImpl( | |
| 22 mojo::InterfaceRequest<mojom::SafeJsonParser> request) | |
| 23 : binding_(this, std::move(request)) {} | |
| 24 | |
| 25 SafeJsonParserMojoImpl::~SafeJsonParserMojoImpl() { | |
| 26 } | |
| 27 | |
| 28 void SafeJsonParserMojoImpl::Parse(const mojo::String& json, | |
| 29 const ParseCallback& callback) { | |
| 30 int error_code; | |
| 31 std::string error; | |
| 32 scoped_ptr<base::Value> value = base::JSONReader::ReadAndReturnError( | |
| 33 json.get(), base::JSON_PARSE_RFC, &error_code, &error); | |
| 34 base::ListValue wrapper; | |
| 35 if (value) { | |
| 36 wrapper.Append(std::move(value)); | |
| 37 callback.Run(wrapper, nullptr); | |
| 38 } else { | |
| 39 callback.Run(wrapper, error); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 } // namespace safe_json | |
| OLD | NEW |