1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

LibWeb: Port NavigatorID from DeprecatedString to String

This commit is contained in:
Shannon Booth 2023-11-20 13:44:27 +13:00 committed by Andreas Kling
parent 0a4586d510
commit 6aff55d655
5 changed files with 24 additions and 24 deletions

View file

@ -11,14 +11,14 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appversion
DeprecatedString NavigatorIDMixin::app_version() const
String NavigatorIDMixin::app_version() const
{
// Must return the appropriate string that starts with "5.0 (", as follows:
// Let trail be the substring of default `User-Agent` value that follows the "Mozilla/" prefix.
auto user_agent_string = ResourceLoader::the().user_agent();
auto trail = user_agent_string.substring_view(strlen("Mozilla/"), user_agent_string.length() - strlen("Mozilla/"));
auto trail = MUST(user_agent_string.substring_from_byte_offset(strlen("Mozilla/"), user_agent_string.bytes().size() - strlen("Mozilla/")));
// If the navigator compatibility mode is Chrome or WebKit
// NOTE: We are using Chrome for now. Make sure to update all APIs if you add a toggle for this.
@ -33,7 +33,7 @@ DeprecatedString NavigatorIDMixin::app_version() const
}
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-platform
DeprecatedString NavigatorIDMixin::platform() const
String NavigatorIDMixin::platform() const
{
// Must return a string representing the platform on which the browser is executing (e.g. "MacIntel", "Win32",
// "Linux x86_64", "Linux armv81") or, for privacy and compatibility, a string that is commonly returned on another
@ -44,7 +44,7 @@ DeprecatedString NavigatorIDMixin::platform() const
}
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-useragent
DeprecatedString NavigatorIDMixin::user_agent() const
String NavigatorIDMixin::user_agent() const
{
// Must return the default `User-Agent` value.
return ResourceLoader::the().user_agent();

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/String.h>
namespace Web::HTML {
@ -17,31 +17,31 @@ public:
// implementers are strongly urged to include as little information in this API as possible.
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appcodename
DeprecatedString app_code_name() const { return "Mozilla"sv; }
String app_code_name() const { return "Mozilla"_string; }
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appcodename
DeprecatedString app_name() const { return "Netscape"sv; }
String app_name() const { return "Netscape"_string; }
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appversion
DeprecatedString app_version() const;
String app_version() const;
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-platform
DeprecatedString platform() const;
String platform() const;
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-product
DeprecatedString product() const { return "Gecko"sv; }
String product() const { return "Gecko"_string; }
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-productsub
DeprecatedString product_sub() const { return "20030107"sv; } // Compatibility mode "Chrome"
String product_sub() const { return "20030107"_string; } // Compatibility mode "Chrome"
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-useragent
DeprecatedString user_agent() const;
String user_agent() const;
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-vendor
DeprecatedString vendor() const { return "Google Inc."sv; } // Compatibility mode "Chrome"
String vendor() const { return "Google Inc."_string; } // Compatibility mode "Chrome"
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-vendorsub
DeprecatedString vendor_sub() const { return ""sv; }
String vendor_sub() const { return String {}; }
// NOTE: If the navigator compatibility mode is Gecko, then the user agent must also support the following partial interface:
// bool taint_enabled()