blob: 74c1d23d140218a21afcca9d2423feb2afbc8eb3 [file] [log] [blame]
Salvador Guerrero Ramosb9e10192024-02-08 19:56:251// 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 Ramosb9e10192024-02-08 19:56:258#include "chrome/browser/content_extraction/inner_text.h"
9#include "content/public/browser/render_frame_host.h"
10
Andrew Grieveecb885bb2024-05-29 18:14:1911// Must come after all headers that specialize FromJniType() / ToJniType().
12#include "chrome/browser/content_extraction/android/jni_headers/InnerTextBridge_jni.h"
13
Salvador Guerrero Ramosb9e10192024-02-08 19:56:2514using ::base::android::JavaParamRef;
15
16namespace {
17void 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);