#ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_ECHO_HOST_H_
#define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_ECHO_HOST_H_
#include <memory>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "extensions/browser/api/messaging/native_message_host.h"
namespace {
class BrowserContext;
}
namespace extensions {
class NativeMessageEchoHost : public NativeMessageHost {
public:
static constexpr char kHostName[] = "com.google.chrome.test.echo";
static constexpr const char* kOrigins[] = {
"chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"};
static std::unique_ptr<NativeMessageHost> Create(
content::BrowserContext* browser_context);
NativeMessageEchoHost();
NativeMessageEchoHost(const NativeMessageEchoHost&) = delete;
NativeMessageEchoHost& operator=(const NativeMessageEchoHost&) = delete;
~NativeMessageEchoHost() override;
void Start(Client* client) override;
void OnMessage(const std::string& request_string) override;
scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override;
private:
void ProcessEcho(const base::Value::Dict& request);
void SendInvalidResponse();
int message_number_ = 0;
raw_ptr<Client> client_ = nullptr;
};
}
#endif