From ea69d45c30492a229a81a8d72493b5e77d24ea36 Mon Sep 17 00:00:00 2001 From: Garo Bournoutian <128516918+gbournou@users.noreply.github.com> Date: Mon, 5 Jun 2023 13:03:12 -0700 Subject: [PATCH] Update naming of Android Client Hint Headers (#541) b/188060079 --- cobalt/browser/client_hint_headers.cc | 7 +++-- cobalt/browser/client_hint_headers_test.cc | 8 ++--- cobalt/browser/user_agent_platform_info.cc | 30 +++++++++---------- cobalt/browser/user_agent_platform_info.h | 18 ++++++----- cobalt/web/cobalt_ua_data_values.idl | 4 +-- cobalt/web/cobalt_ua_data_values_interface.cc | 8 ++--- cobalt/web/cobalt_ua_data_values_interface.h | 12 ++++---- .../web/cobalt_ua_data_values_interface.idl | 4 +-- cobalt/web/navigator_ua_data.cc | 7 +++-- .../testing/mock_user_agent_platform_info.h | 6 ++-- cobalt/web/user_agent_platform_info.h | 4 +-- starboard/extension/platform_info.h | 4 +-- 12 files changed, 60 insertions(+), 52 deletions(-) diff --git a/cobalt/browser/client_hint_headers.cc b/cobalt/browser/client_hint_headers.cc index 8dc7dcc15650..99794d5d7050 100644 --- a/cobalt/browser/client_hint_headers.cc +++ b/cobalt/browser/client_hint_headers.cc @@ -43,10 +43,11 @@ std::vector GetClientHintHeaders( const UserAgentPlatformInfo& platform_info) { std::vector headers; - AddHeader(headers, "Firmware-Version-Details", - platform_info.firmware_version_details()); + AddHeader(headers, "Android-Build-Fingerprint", + platform_info.android_build_fingerprint()); - AddHeader(headers, "OS-Experience", platform_info.os_experience()); + AddHeader(headers, "Android-OS-Experience", + platform_info.android_os_experience()); return headers; } diff --git a/cobalt/browser/client_hint_headers_test.cc b/cobalt/browser/client_hint_headers_test.cc index f96626a01c55..7cb26e9a8e41 100644 --- a/cobalt/browser/client_hint_headers_test.cc +++ b/cobalt/browser/client_hint_headers_test.cc @@ -27,14 +27,14 @@ using ::testing::UnorderedElementsAre; TEST(ClientHintHeadersTest, GetClientHintHeaders) { UserAgentPlatformInfo platform_info; - platform_info.set_firmware_version_details("abc/def:123.456/xy-z"); - platform_info.set_os_experience("Amati"); + platform_info.set_android_build_fingerprint("abc/def:123.456/xy-z"); + platform_info.set_android_os_experience("Amati"); std::vector headers = GetClientHintHeaders(platform_info); EXPECT_THAT(headers, UnorderedElementsAre( - "Sec-CH-UA-Co-Firmware-Version-Details:abc/def:123.456/xy-z", - "Sec-CH-UA-Co-OS-Experience:Amati")); + "Sec-CH-UA-Co-Android-Build-Fingerprint:abc/def:123.456/xy-z", + "Sec-CH-UA-Co-Android-OS-Experience:Amati")); } } // namespace diff --git a/cobalt/browser/user_agent_platform_info.cc b/cobalt/browser/user_agent_platform_info.cc index 30b4b397a3fa..0284aa625a48 100644 --- a/cobalt/browser/user_agent_platform_info.cc +++ b/cobalt/browser/user_agent_platform_info.cc @@ -282,9 +282,9 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { result = platform_info_extension->GetFirmwareVersionDetails( value, kSystemPropertyMaxLength); if (result) { - info.set_firmware_version_details(value); + info.set_android_build_fingerprint(value); } - info.set_os_experience(platform_info_extension->GetOsExperience()); + info.set_android_os_experience(platform_info_extension->GetOsExperience()); } info.set_cobalt_version(COBALT_VERSION); @@ -422,12 +422,12 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { } else if (!input.first.compare("evergreen_version")) { info.set_evergreen_version(input.second); LOG(INFO) << "Set evergreen version to " << input.second; - } else if (!input.first.compare("firmware_version_details")) { - info.set_firmware_version_details(input.second); - LOG(INFO) << "Set firmware version details to " << input.second; - } else if (!input.first.compare("os_experience")) { - info.set_os_experience(input.second); - LOG(INFO) << "Set os experience to " << input.second; + } else if (!input.first.compare("android_build_fingerprint")) { + info.set_android_build_fingerprint(input.second); + LOG(INFO) << "Set android build fingerprint to " << input.second; + } else if (!input.first.compare("android_os_experience")) { + info.set_android_os_experience(input.second); + LOG(INFO) << "Set android os experience to " << input.second; } else if (!input.first.compare("cobalt_version")) { info.set_cobalt_version(input.second); LOG(INFO) << "Set cobalt type to " << input.second; @@ -542,15 +542,15 @@ void UserAgentPlatformInfo::set_evergreen_version( evergreen_version_ = Sanitize(evergreen_version, isTCHAR); } -void UserAgentPlatformInfo::set_firmware_version_details( - const std::string& firmware_version_details) { - firmware_version_details_ = - Sanitize(firmware_version_details, isVCHARorSpace); +void UserAgentPlatformInfo::set_android_build_fingerprint( + const std::string& android_build_fingerprint) { + android_build_fingerprint_ = + Sanitize(android_build_fingerprint, isVCHARorSpace); } -void UserAgentPlatformInfo::set_os_experience( - const std::string& os_experience) { - os_experience_ = Sanitize(os_experience, isTCHAR); +void UserAgentPlatformInfo::set_android_os_experience( + const std::string& android_os_experience) { + android_os_experience_ = Sanitize(android_os_experience, isTCHAR); } void UserAgentPlatformInfo::set_cobalt_version( diff --git a/cobalt/browser/user_agent_platform_info.h b/cobalt/browser/user_agent_platform_info.h index 26b0b6412136..e5768a495ea2 100644 --- a/cobalt/browser/user_agent_platform_info.h +++ b/cobalt/browser/user_agent_platform_info.h @@ -76,10 +76,12 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { const std::string& evergreen_version() const override { return evergreen_version_; } - const std::string& firmware_version_details() const override { - return firmware_version_details_; + const std::string& android_build_fingerprint() const override { + return android_build_fingerprint_; + } + const std::string& android_os_experience() const override { + return android_os_experience_; } - const std::string& os_experience() const override { return os_experience_; } const std::string& cobalt_version() const override { return cobalt_version_; } const std::string& cobalt_build_version_number() const override { return cobalt_build_version_number_; @@ -111,9 +113,9 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { void set_evergreen_type(const std::string& evergreen_type); void set_evergreen_file_type(const std::string& evergreen_file_type); void set_evergreen_version(const std::string& evergreen_version); - void set_firmware_version_details( - const std::string& firmware_version_details); - void set_os_experience(const std::string& os_experience); + void set_android_build_fingerprint( + const std::string& android_build_fingerprint); + void set_android_os_experience(const std::string& android_os_experience); void set_cobalt_version(const std::string& cobalt_version); void set_cobalt_build_version_number( const std::string& cobalt_build_version_number); @@ -138,8 +140,8 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { std::string evergreen_type_; std::string evergreen_file_type_; std::string evergreen_version_; - std::string firmware_version_details_; // Only via Client Hints - std::string os_experience_; // Only via Client Hints + std::string android_build_fingerprint_; // Only via Client Hints + std::string android_os_experience_; // Only via Client Hints std::string cobalt_version_; std::string cobalt_build_version_number_; diff --git a/cobalt/web/cobalt_ua_data_values.idl b/cobalt/web/cobalt_ua_data_values.idl index 399651aaa1da..eef1fa00f3b1 100644 --- a/cobalt/web/cobalt_ua_data_values.idl +++ b/cobalt/web/cobalt_ua_data_values.idl @@ -22,8 +22,8 @@ dictionary CobaltUADataValues : UADataValues { DOMString evergreenType; DOMString evergreenFileType; DOMString evergreenVersion; - DOMString firmwareVersionDetails; - DOMString osExperience; + DOMString androidBuildFingerprint; + DOMString androidOsExperience; DOMString starboardVersion; DOMString originalDesignManufacturer; DOMString deviceType; diff --git a/cobalt/web/cobalt_ua_data_values_interface.cc b/cobalt/web/cobalt_ua_data_values_interface.cc index 47e23dd86534..ac4a9c0d71f4 100644 --- a/cobalt/web/cobalt_ua_data_values_interface.cc +++ b/cobalt/web/cobalt_ua_data_values_interface.cc @@ -67,11 +67,11 @@ CobaltUADataValuesInterface::CobaltUADataValuesInterface( if (init_dict.has_evergreen_version()) { evergreen_version_ = init_dict.evergreen_version(); } - if (init_dict.has_firmware_version_details()) { - firmware_version_details_ = init_dict.firmware_version_details(); + if (init_dict.has_android_build_fingerprint()) { + android_build_fingerprint_ = init_dict.android_build_fingerprint(); } - if (init_dict.has_os_experience()) { - os_experience_ = init_dict.os_experience(); + if (init_dict.has_android_os_experience()) { + android_os_experience_ = init_dict.android_os_experience(); } if (init_dict.has_starboard_version()) { starboard_version_ = init_dict.starboard_version(); diff --git a/cobalt/web/cobalt_ua_data_values_interface.h b/cobalt/web/cobalt_ua_data_values_interface.h index 81dcc70381b8..22599ff77eb2 100644 --- a/cobalt/web/cobalt_ua_data_values_interface.h +++ b/cobalt/web/cobalt_ua_data_values_interface.h @@ -48,10 +48,12 @@ class CobaltUADataValuesInterface : public script::Wrappable { return evergreen_file_type_; } const std::string& evergreen_version() const { return evergreen_version_; } - const std::string& firmware_version_details() const { - return firmware_version_details_; + const std::string& android_build_fingerprint() const { + return android_build_fingerprint_; + } + const std::string& android_os_experience() const { + return android_os_experience_; } - const std::string& os_experience() const { return os_experience_; } const std::string& starboard_version() const { return starboard_version_; } const std::string& original_design_manufacturer() const { return original_design_manufacturer_; @@ -83,8 +85,8 @@ class CobaltUADataValuesInterface : public script::Wrappable { std::string evergreen_type_; std::string evergreen_file_type_; std::string evergreen_version_; - std::string firmware_version_details_; - std::string os_experience_; + std::string android_build_fingerprint_; + std::string android_os_experience_; std::string starboard_version_; std::string original_design_manufacturer_; std::string device_type_; diff --git a/cobalt/web/cobalt_ua_data_values_interface.idl b/cobalt/web/cobalt_ua_data_values_interface.idl index fc670c26149e..b7ce6341ccd2 100644 --- a/cobalt/web/cobalt_ua_data_values_interface.idl +++ b/cobalt/web/cobalt_ua_data_values_interface.idl @@ -32,8 +32,8 @@ interface CobaltUADataValuesInterface { readonly attribute DOMString evergreenType; readonly attribute DOMString evergreenFileType; readonly attribute DOMString evergreenVersion; - readonly attribute DOMString firmwareVersionDetails; - readonly attribute DOMString osExperience; + readonly attribute DOMString androidBuildFingerprint; + readonly attribute DOMString androidOsExperience; readonly attribute DOMString starboardVersion; readonly attribute DOMString originalDesignManufacturer; readonly attribute DOMString deviceType; diff --git a/cobalt/web/navigator_ua_data.cc b/cobalt/web/navigator_ua_data.cc index 4ca973c7830a..7c4d258ca7ad 100644 --- a/cobalt/web/navigator_ua_data.cc +++ b/cobalt/web/navigator_ua_data.cc @@ -60,9 +60,10 @@ NavigatorUAData::NavigatorUAData( platform_info->evergreen_file_type()); all_high_entropy_values_.set_evergreen_version( platform_info->evergreen_version()); - all_high_entropy_values_.set_firmware_version_details( - platform_info->firmware_version_details()); - all_high_entropy_values_.set_os_experience(platform_info->os_experience()); + all_high_entropy_values_.set_android_build_fingerprint( + platform_info->android_build_fingerprint()); + all_high_entropy_values_.set_android_os_experience( + platform_info->android_os_experience()); all_high_entropy_values_.set_starboard_version( platform_info->starboard_version()); all_high_entropy_values_.set_original_design_manufacturer( diff --git a/cobalt/web/testing/mock_user_agent_platform_info.h b/cobalt/web/testing/mock_user_agent_platform_info.h index 1ef43018e774..fca692f375b0 100644 --- a/cobalt/web/testing/mock_user_agent_platform_info.h +++ b/cobalt/web/testing/mock_user_agent_platform_info.h @@ -75,10 +75,12 @@ class MockUserAgentPlatformInfo : public web::UserAgentPlatformInfo { const std::string& evergreen_version() const override { return empty_string_; } - const std::string& firmware_version_details() const override { + const std::string& android_build_fingerprint() const override { + return empty_string_; + } + const std::string& android_os_experience() const override { return empty_string_; } - const std::string& os_experience() const override { return empty_string_; } const std::string& cobalt_version() const override { return empty_string_; } const std::string& cobalt_build_version_number() const override { return empty_string_; diff --git a/cobalt/web/user_agent_platform_info.h b/cobalt/web/user_agent_platform_info.h index 6ee6e9c47b8f..d7b4ad141e31 100644 --- a/cobalt/web/user_agent_platform_info.h +++ b/cobalt/web/user_agent_platform_info.h @@ -47,8 +47,8 @@ class UserAgentPlatformInfo { virtual const std::string& evergreen_type() const = 0; virtual const std::string& evergreen_file_type() const = 0; virtual const std::string& evergreen_version() const = 0; - virtual const std::string& firmware_version_details() const = 0; - virtual const std::string& os_experience() const = 0; + virtual const std::string& android_build_fingerprint() const = 0; + virtual const std::string& android_os_experience() const = 0; virtual const std::string& cobalt_version() const = 0; virtual const std::string& cobalt_build_version_number() const = 0; diff --git a/starboard/extension/platform_info.h b/starboard/extension/platform_info.h index a9d9b1192309..e670044f7bbb 100644 --- a/starboard/extension/platform_info.h +++ b/starboard/extension/platform_info.h @@ -35,8 +35,8 @@ typedef struct CobaltExtensionPlatformInfoApi { // The fields below this point were added in version 1 or later. - // Returns details about the device firmware version. This can be something - // like Android build fingerprint (go/android-build-fingerprint). + // Returns details about the device firmware version. On Android, this will + // be the Android build fingerprint (go/android-build-fingerprint). bool (*GetFirmwareVersionDetails)(char* out_value, int value_length); // Returns the OS experience. (e.g. Amati or Watson on an Android device).