ladybird/Libraries/LibWeb/Internals/Settings.h
Timothy Flynn b169a98495 LibWeb+LibWebView+WebContent: Introduce a basic about:settings page
This adds a basic settings page to manage persistent Ladybird settings.
As a first pass, this exposes settings for the new tab page URL and the
default search engine.

The way the search engine option works is that once search is enabled,
the user must choose their default search engine; we do not apply any
default automatically. Search remains disabled until this is done.

There are a couple of improvements that we should make here:

* Settings changes are not broadcasted to all open about:settings pages.
  So if two instances are open, and the user changes the search engine
  in one instance, the other instance will have a stale UI.

* Adding an IPC per setting is going to get annoying. It would be nice
  if we can come up with a smaller set of IPCs to send only the relevant
  changed settings.
2025-03-22 17:27:45 +01:00

34 lines
720 B
C++

/*
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Internals/InternalsBase.h>
namespace Web::Internals {
class Settings final : public InternalsBase {
WEB_PLATFORM_OBJECT(Settings, InternalsBase);
GC_DECLARE_ALLOCATOR(Settings);
public:
virtual ~Settings() override;
void load_current_settings();
void restore_default_settings();
void set_new_tab_page_url(String const& new_tab_page_url);
void load_available_search_engines();
void set_search_engine(Optional<String> const& search_engine);
private:
explicit Settings(JS::Realm&);
virtual void initialize(JS::Realm&) override;
};
}