Ladybird+LibWeb: Move User-Agent definitions to their own file

This is to avoid including any LibProtocol header in Objective-C source
files, which will cause a conflict between the Protocol namespace and a
@Protocol interface.

See Ladybird/AppKit/Application/ApplicationBridge.cpp for why this
conflict unfortunately cannot be worked around.
This commit is contained in:
Timothy Flynn 2024-05-26 11:12:49 -04:00 committed by Andreas Kling
parent a38144fb2a
commit 086ddd481d
Notes: sideshowbarker 2024-07-16 22:22:13 +09:00
8 changed files with 69 additions and 54 deletions

View file

@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Loader/UserAgent.h>
#include <LibWebView/SearchEngine.h>
#include <LibWebView/URL.h>
#include <LibWebView/UserAgent.h>
#import <Application/ApplicationDelegate.h>
#import <LibWeb/Loader/ResourceLoader.h>
#import <LibWebView/UserAgent.h>
#import <UI/LadybirdWebView.h>
#import <UI/Tab.h>
#import <UI/TabController.h>

View file

@ -19,7 +19,7 @@
#include <Ladybird/Qt/TabBar.h>
#include <Ladybird/Utilities.h>
#include <LibWeb/CSS/PreferredColorScheme.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Loader/UserAgent.h>
#include <LibWebView/CookieJar.h>
#include <LibWebView/UserAgent.h>
#include <QAction>

View file

@ -35,7 +35,7 @@
#include <LibWeb/Dump.h>
#include <LibWeb/HTML/AudioPlayState.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Loader/UserAgent.h>
#include <LibWebView/CookieJar.h>
#include <LibWebView/OutOfProcessWebView.h>
#include <LibWebView/SearchEngine.h>

View file

@ -12,7 +12,7 @@
#include <LibCore/Resource.h>
#include <LibCore/System.h>
#include <LibWeb/Loader/GeneratedPagesLoader.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Loader/UserAgent.h>
namespace Web {

View file

@ -21,6 +21,7 @@
#include <LibWeb/Loader/ProxyMappings.h>
#include <LibWeb/Loader/Resource.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Loader/UserAgent.h>
#include <LibWeb/Platform/EventLoopPlugin.h>
#include <LibWeb/Platform/Timer.h>

View file

@ -19,54 +19,6 @@
namespace Web {
#if ARCH(X86_64)
# define CPU_STRING "x86_64"
#elif ARCH(AARCH64)
# define CPU_STRING "AArch64"
#elif ARCH(I386)
# define CPU_STRING "x86"
#elif ARCH(RISCV64)
# define CPU_STRING "RISC-V 64"
#else
# error Unknown architecture
#endif
#if defined(AK_OS_SERENITY)
# define OS_STRING "SerenityOS"
#elif defined(AK_OS_ANDROID)
# define OS_STRING "Android 10"
#elif defined(AK_OS_LINUX)
# define OS_STRING "Linux"
#elif defined(AK_OS_MACOS)
# define OS_STRING "macOS"
#elif defined(AK_OS_IOS)
# define OS_STRING "iOS"
#elif defined(AK_OS_WINDOWS)
# define OS_STRING "Windows"
#elif defined(AK_OS_FREEBSD)
# define OS_STRING "FreeBSD"
#elif defined(AK_OS_OPENBSD)
# define OS_STRING "OpenBSD"
#elif defined(AK_OS_NETBSD)
# define OS_STRING "NetBSD"
#elif defined(AK_OS_DRAGONFLY)
# define OS_STRING "DragonFly"
#elif defined(AK_OS_SOLARIS)
# define OS_STRING "SunOS"
#elif defined(AK_OS_HAIKU)
# define OS_STRING "Haiku"
#elif defined(AK_OS_GNU_HURD)
# define OS_STRING "GNU/Hurd"
#else
# error Unknown OS
#endif
#define BROWSER_NAME "Ladybird"
#define BROWSER_VERSION "1.0"
constexpr auto default_user_agent = "Mozilla/5.0 (" OS_STRING "; " CPU_STRING ") " BROWSER_NAME "/" BROWSER_VERSION ""sv;
constexpr auto default_platform = OS_STRING " " CPU_STRING ""sv;
namespace WebSockets {
class WebSocketClientSocket;
}

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Platform.h>
#include <AK/StringView.h>
namespace Web {
#if ARCH(X86_64)
# define CPU_STRING "x86_64"
#elif ARCH(AARCH64)
# define CPU_STRING "AArch64"
#elif ARCH(I386)
# define CPU_STRING "x86"
#elif ARCH(RISCV64)
# define CPU_STRING "RISC-V 64"
#else
# error Unknown architecture
#endif
#if defined(AK_OS_SERENITY)
# define OS_STRING "SerenityOS"
#elif defined(AK_OS_ANDROID)
# define OS_STRING "Android 10"
#elif defined(AK_OS_LINUX)
# define OS_STRING "Linux"
#elif defined(AK_OS_MACOS)
# define OS_STRING "macOS"
#elif defined(AK_OS_IOS)
# define OS_STRING "iOS"
#elif defined(AK_OS_WINDOWS)
# define OS_STRING "Windows"
#elif defined(AK_OS_FREEBSD)
# define OS_STRING "FreeBSD"
#elif defined(AK_OS_OPENBSD)
# define OS_STRING "OpenBSD"
#elif defined(AK_OS_NETBSD)
# define OS_STRING "NetBSD"
#elif defined(AK_OS_DRAGONFLY)
# define OS_STRING "DragonFly"
#elif defined(AK_OS_SOLARIS)
# define OS_STRING "SunOS"
#elif defined(AK_OS_HAIKU)
# define OS_STRING "Haiku"
#elif defined(AK_OS_GNU_HURD)
# define OS_STRING "GNU/Hurd"
#else
# error Unknown OS
#endif
#define BROWSER_NAME "Ladybird"
#define BROWSER_VERSION "1.0"
constexpr auto default_user_agent = "Mozilla/5.0 (" OS_STRING "; " CPU_STRING ") " BROWSER_NAME "/" BROWSER_VERSION ""sv;
constexpr auto default_platform = OS_STRING " " CPU_STRING ""sv;
}

View file

@ -9,7 +9,7 @@
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <AK/Optional.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Loader/UserAgent.h>
#include <LibWeb/WebDriver/Capabilities.h>
#include <LibWeb/WebDriver/TimeoutsConfiguration.h>