mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-23 17:33:12 +00:00
This implements an autocomplete engine inside LibWebView, to replace the engine currently used by Qt. Whereas Qt uses the Qt Network framework to perform autocomplete requests, LibWebView uses RequestServer. This moves downloading this untrusted data out of the browser process. This patch only implements the persisted settings and their UI. It does not integrate this engine into the browser UI.
44 lines
1 KiB
C++
44 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/Function.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/String.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibRequests/Forward.h>
|
|
|
|
namespace WebView {
|
|
|
|
struct AutocompleteEngine {
|
|
StringView name;
|
|
StringView query_url;
|
|
};
|
|
|
|
ReadonlySpan<AutocompleteEngine> autocomplete_engines();
|
|
Optional<AutocompleteEngine const&> find_autocomplete_engine_by_name(StringView name);
|
|
|
|
class Autocomplete {
|
|
public:
|
|
Autocomplete();
|
|
~Autocomplete();
|
|
|
|
Function<void(Vector<String>)> on_autocomplete_query_complete;
|
|
|
|
void query_autocomplete_engine(String);
|
|
|
|
private:
|
|
static ErrorOr<Vector<String>> received_autocomplete_respsonse(AutocompleteEngine const&, StringView response);
|
|
void invoke_autocomplete_query_complete(Vector<String> suggestions) const;
|
|
|
|
String m_query;
|
|
RefPtr<Requests::Request> m_request;
|
|
};
|
|
|
|
}
|