LibWebView: Support custom search engines

This allows the user to store custom search engines via about:settings.
Custom engines will be displayed below the builtin engines in the drop-
down to select the default engine.

A couple of edge cases here:

1. We currently reject a custom engine if one with the same name already
   exists. In the future, we should allow editing custom engines.

2. If a custom engine which was the default engine is removed, we will
   disable search rather than falling back to any other engine.
This commit is contained in:
Timothy Flynn 2025-04-04 18:12:32 -04:00 committed by Andreas Kling
commit 2810071a9c
Notes: github-actions[bot] 2025-04-06 11:46:03 +00:00
7 changed files with 317 additions and 28 deletions

View file

@ -60,6 +60,10 @@ public:
Optional<SearchEngine> const& search_engine() const { return m_search_engine; }
void set_search_engine(Optional<StringView> search_engine_name);
static Optional<SearchEngine> parse_custom_search_engine(JsonValue const&);
void add_custom_search_engine(SearchEngine);
void remove_custom_search_engine(SearchEngine const&);
Optional<AutocompleteEngine> const& autocomplete_engine() const { return m_autocomplete_engine; }
void set_autocomplete_engine(Optional<StringView> autocomplete_engine_name);
@ -80,11 +84,14 @@ private:
void persist_settings();
Optional<SearchEngine> find_search_engine_by_name(StringView name);
ByteString m_settings_path;
URL::URL m_new_tab_page_url;
Vector<String> m_languages;
Optional<SearchEngine> m_search_engine;
Vector<SearchEngine> m_custom_search_engines;
Optional<AutocompleteEngine> m_autocomplete_engine;
SiteSetting m_autoplay;
DoNotTrack m_do_not_track { DoNotTrack::No };