mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWebView+WebContent: Monitor for system time zone changes
This creates a TimeZoneWatcher in the UI process to inform all open WebContent processes when the time zone changes. The WebContent process will clear its time zone cache to retrieve a fresh zone the next time it is asked for one.
This commit is contained in:
parent
577efcdc32
commit
d8c69a0e9e
Notes:
github-actions[bot]
2024-08-25 07:48:36 +00:00
Author: https://github.com/trflynn89
Commit: d8c69a0e9e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1182
5 changed files with 31 additions and 0 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibCore/TimeZoneWatcher.h>
|
||||
#include <LibImageDecoderClient/Client.h>
|
||||
#include <LibWebView/Application.h>
|
||||
#include <LibWebView/URL.h>
|
||||
|
@ -20,6 +22,22 @@ Application::Application()
|
|||
VERIFY(!s_the);
|
||||
s_the = this;
|
||||
|
||||
// No need to monitor the system time zone if the TZ environment variable is set, as it overrides system preferences.
|
||||
if (!Core::Environment::has("TZ"sv)) {
|
||||
if (auto time_zone_watcher = Core::TimeZoneWatcher::create(); time_zone_watcher.is_error()) {
|
||||
warnln("Unable to monitor system time zone: {}", time_zone_watcher.error());
|
||||
} else {
|
||||
m_time_zone_watcher = time_zone_watcher.release_value();
|
||||
|
||||
m_time_zone_watcher->on_time_zone_changed = []() {
|
||||
WebContentClient::for_each_client([&](WebView::WebContentClient& client) {
|
||||
client.async_system_time_zone_changed();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
m_process_manager.on_process_exited = [this](Process&& process) {
|
||||
process_did_exit(move(process));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue