LibWebView: Add autocomplete settings to about:settings

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.
This commit is contained in:
Timothy Flynn 2025-03-30 16:21:24 -04:00 committed by Tim Flynn
commit 5d2e6ffe30
Notes: github-actions[bot] 2025-04-02 12:53:55 +00:00
9 changed files with 432 additions and 66 deletions

View file

@ -0,0 +1,44 @@
/*
* 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;
};
}