OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/safe_json/json_sanitizer.h" | 5 #include "components/safe_json/json_sanitizer.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/threading/sequenced_task_runner_handle.h" | 14 #include "base/threading/sequenced_task_runner_handle.h" |
15 #include "jni/JsonSanitizer_jni.h" | 15 #include "jni/JsonSanitizer_jni.h" |
16 | 16 |
| 17 using base::android::JavaParamRef; |
| 18 |
17 namespace safe_json { | 19 namespace safe_json { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // An implementation of JsonSanitizer that calls into Java. It deals with | 23 // An implementation of JsonSanitizer that calls into Java. It deals with |
22 // malformed input (in particular malformed Unicode encodings) in the following | 24 // malformed input (in particular malformed Unicode encodings) in the following |
23 // steps: | 25 // steps: |
24 // 1. The input string is checked for whether it is well-formed UTF-8. Malformed | 26 // 1. The input string is checked for whether it is well-formed UTF-8. Malformed |
25 // UTF-8 is rejected. | 27 // UTF-8 is rejected. |
26 // 2. The UTF-8 string is converted in native code to a Java String, which is | 28 // 2. The UTF-8 string is converted in native code to a Java String, which is |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 JsonSanitizerAndroid sanitizer(success_callback, error_callback); | 116 JsonSanitizerAndroid sanitizer(success_callback, error_callback); |
115 sanitizer.Sanitize(unsafe_json); | 117 sanitizer.Sanitize(unsafe_json); |
116 } | 118 } |
117 | 119 |
118 // static | 120 // static |
119 bool JsonSanitizer::Register(JNIEnv* env) { | 121 bool JsonSanitizer::Register(JNIEnv* env) { |
120 return RegisterNativesImpl(env); | 122 return RegisterNativesImpl(env); |
121 } | 123 } |
122 | 124 |
123 } // namespace safe_json | 125 } // namespace safe_json |
OLD | NEW |