#ifndef CONTENT_BROWSER_ANDROID_SELECTION_SMART_SELECTION_CLIENT_H_
#define CONTENT_BROWSER_ANDROID_SELECTION_SMART_SELECTION_CLIENT_H_
#include <jni.h>
#include <string>
#include "base/android/jni_weak_ref.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
namespace content {
class WebContents;
class SmartSelectionClient {
public:
SmartSelectionClient(JNIEnv* env,
const base::android::JavaRef<jobject>& obj,
WebContents* web_contents);
SmartSelectionClient(const SmartSelectionClient&) = delete;
SmartSelectionClient& operator=(const SmartSelectionClient&) = delete;
~SmartSelectionClient();
void RequestSurroundingText(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
int num_extra_characters,
int callback_data);
void CancelAllRequests(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
private:
void OnSurroundingTextReceived(int callback_data,
const std::u16string& text,
uint32_t start,
uint32_t end);
JavaObjectWeakGlobalRef java_ref_;
raw_ptr<WebContents> web_contents_;
base::WeakPtrFactory<SmartSelectionClient> weak_ptr_factory_{this};
};
}
#endif