Files
ladybird/Libraries/LibWebView/Autocomplete.h
Andreas Kling fe2cab9270 LibWebView: Add history-backed location autocomplete
Teach LibWebView autocomplete to query HistoryStore before falling back
to remote engines and move the wiring out of the AppKit frontend.
Refine matching so scheme and www. boilerplate do not dominate results,
short title and substring queries stay quiet, and history tracing can
explain what the ranking code is doing.
2026-04-16 21:01:28 +02:00

47 lines
1.2 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>
#include <LibWebView/Forward.h>
namespace WebView {
struct AutocompleteEngine {
StringView name;
StringView query_url;
};
WEBVIEW_API ReadonlySpan<AutocompleteEngine> autocomplete_engines();
WEBVIEW_API Optional<AutocompleteEngine const&> find_autocomplete_engine_by_name(StringView name);
class WEBVIEW_API 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&, Optional<ByteString const&> content_type, StringView response);
void invoke_autocomplete_query_complete(Vector<String> suggestions) const;
String m_query;
Vector<String> m_history_suggestions;
RefPtr<Requests::Request> m_request;
};
}