Salvador Guerrero Ramos | b9e1019 | 2024-02-08 19:56:25 | [diff] [blame] | 1 | // Copyright 2024 The Chromium Authors |
| 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 "base/android/callback_android.h" |
| 6 | #include "base/functional/callback_forward.h" |
| 7 | #include "base/types/optional_ref.h" |
Salvador Guerrero Ramos | b9e1019 | 2024-02-08 19:56:25 | [diff] [blame] | 8 | #include "chrome/browser/content_extraction/inner_text.h" |
| 9 | #include "content/public/browser/render_frame_host.h" |
| 10 | |
Andrew Grieve | ecb885bb | 2024-05-29 18:14:19 | [diff] [blame] | 11 | // Must come after all headers that specialize FromJniType() / ToJniType(). |
| 12 | #include "chrome/browser/content_extraction/android/jni_headers/InnerTextBridge_jni.h" |
| 13 | |
Salvador Guerrero Ramos | b9e1019 | 2024-02-08 19:56:25 | [diff] [blame] | 14 | using ::base::android::JavaParamRef; |
| 15 | |
| 16 | namespace { |
| 17 | void OnGotInnerText( |
| 18 | base::OnceCallback<void(const base::optional_ref<const std::string>)> |
| 19 | optional_string_callback, |
| 20 | std::unique_ptr<content_extraction::InnerTextResult> inner_text) { |
| 21 | if (!optional_string_callback) { |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | if (!inner_text) { |
| 26 | std::move(optional_string_callback).Run(base::optional_ref<std::string>()); |
| 27 | } else { |
| 28 | std::move(optional_string_callback).Run(inner_text->inner_text); |
|
|