Enable -Wexit-time-destructors for all in-tree library targets and update process-lifetime library statics so they no longer register exit-time destructors. Long-lived caches, lookup tables, singleton registries, and generated constants now use NeverDestroyed or leaked references where the data is intended to live until process exit. Update LibWeb, LibLine, and the binding generators so regenerated sources follow the same rule instead of reintroducing destructed statics.
60 lines
2.1 KiB
C++
60 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/JsonObject.h>
|
|
#include <AK/String.h>
|
|
#include <LibCore/Version.h>
|
|
#include <LibDevTools/Actors/DeviceActor.h>
|
|
#include <LibWeb/Loader/UserAgent.h>
|
|
|
|
namespace DevTools {
|
|
|
|
NonnullRefPtr<DeviceActor> DeviceActor::create(DevToolsServer& devtools, String name)
|
|
{
|
|
return adopt_ref(*new DeviceActor(devtools, move(name)));
|
|
}
|
|
|
|
DeviceActor::DeviceActor(DevToolsServer& devtools, String name)
|
|
: Actor(devtools, move(name))
|
|
{
|
|
}
|
|
|
|
DeviceActor::~DeviceActor() = default;
|
|
|
|
void DeviceActor::handle_message(Message const& message)
|
|
{
|
|
if (message.type == "getDescription"sv) {
|
|
auto build_id = Core::Version::read_long_version_string();
|
|
|
|
static auto& browser_name = *new String(String::from_utf8_without_validation({ BROWSER_NAME, __builtin_strlen(BROWSER_NAME) }));
|
|
static auto& browser_version = *new String(String::from_utf8_without_validation({ BROWSER_VERSION, __builtin_strlen(BROWSER_VERSION) }));
|
|
static auto& platform_name = *new String(String::from_utf8_without_validation({ OS_STRING, __builtin_strlen(OS_STRING) }));
|
|
static auto& arch = *new String(String::from_utf8_without_validation({ CPU_STRING, __builtin_strlen(CPU_STRING) }));
|
|
|
|
// https://github.com/mozilla/gecko-dev/blob/master/devtools/shared/system.js
|
|
JsonObject value;
|
|
value.set("apptype"sv, browser_name.to_ascii_lowercase());
|
|
value.set("name"sv, browser_name);
|
|
value.set("brandName"sv, browser_name);
|
|
value.set("version"sv, browser_version);
|
|
value.set("appbuildid"sv, build_id);
|
|
value.set("platformbuildid"sv, build_id);
|
|
value.set("platformversion"sv, "139.0"sv);
|
|
value.set("useragent"sv, Web::default_user_agent);
|
|
value.set("os"sv, platform_name);
|
|
value.set("arch"sv, arch);
|
|
|
|
JsonObject response;
|
|
response.set("value"sv, move(value));
|
|
send_response(message, move(response));
|
|
|
|
return;
|
|
}
|
|
|
|
send_unrecognized_packet_type_error(message);
|
|
}
|
|
|
|
}
|