Skip to content

Commit b9534a1

Browse files
author
Santosh Mahto
committed
Prepend starboard OS name in user-agent string
The current OS name in user-agent string is fetched using chromium code which just return "Linux". This misses the real OS name for starboard platform and result in YTS test failure. So OS name in user-agent string should include the starboard platform OS name. Bug: 475670748 Change-Id: Iead491cc09a5823429cbd378b5c23bf922246493
1 parent 22ae31c commit b9534a1

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

base/system/sys_info_starboard.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ std::string SbSysInfo::Brand() {
7878
__system_property_get("ro.product.brand", brand_str);
7979
return std::string(brand_str);
8080
}
81+
82+
std::string SbSysInfo::OSFriendlyName() {
83+
return "AOSP";
84+
}
85+
8186
#elif BUILDFLAG(IS_STARBOARD)
8287
std::string SbSysInfo::OriginalDesignManufacturer() {
8388
return GetSystemPropertyString(kSbSystemPropertySystemIntegratorName);
@@ -95,6 +100,10 @@ std::string SbSysInfo::Brand() {
95100
return GetSystemPropertyString(kSbSystemPropertyBrandName);
96101
}
97102

103+
std::string SbSysInfo::OSFriendlyName() {
104+
return GetSystemPropertyString(kSbSystemPropertyFriendlyName);
105+
}
106+
98107
#elif BUILDFLAG(IS_IOS_TVOS)
99108
std::string SbSysInfo::OriginalDesignManufacturer() {
100109
// Cobalt 25: https://github.com/youtube/cobalt/blob/62c2380b7eb0da5889a387c4b9be283656a8575d/starboard/shared/uikit/system_get_property.mm#L126
@@ -152,6 +161,11 @@ std::string SbSysInfo::Brand() {
152161
return "Apple";
153162
}
154163

164+
std::string SbSysInfo::OSFriendlyName() {
165+
NOTIMPLEMENTED();
166+
return ""
167+
}
168+
155169
#endif // BUILDFLAG(IS_ANDROID)
156170

157171
} // namespace starboard

base/system/sys_info_starboard.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ class BASE_EXPORT SbSysInfo {
3131
static std::string ModelYear();
3232

3333
static std::string Brand();
34+
35+
static std::string OSFriendlyName();
3436
};
3537

3638
} // namespace starboard
3739
} // namespace base
3840

39-
#endif // BASE_SYSTEM_SYS_INFO_STARBOARD_H_
41+
#endif // BASE_SYSTEM_SYS_INFO_STARBOARD_H_

base/system/sys_info_starboard_unittest.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
namespace base {
2323
namespace starboard {
2424

25-
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS_TVOS)
25+
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS_TVOS) ||
26+
BUILDFLAG(IS_STARBOARD)
2627

2728
using SbSysInfoTest = PlatformTest;
2829

@@ -46,6 +47,10 @@ TEST_F(SbSysInfoTest, Brand) {
4647
EXPECT_NE(brand_str, "");
4748
}
4849

50+
TEST_F(SbSysInfoTest, OSFriendlyName) {
51+
std::string os_name_str = SbSysInfo::OSFriendlyName();
52+
EXPECT_NE(os_name_str, "");
53+
}
4954
#endif
5055

5156
} // namespace starboard

cobalt/browser/user_agent/user_agent_platform_info.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ void UserAgentPlatformInfo::InitializePlatformDependentFieldsAndroid() {
190190
}
191191
#elif BUILDFLAG(IS_STARBOARD)
192192
void UserAgentPlatformInfo::InitializePlatformDependentFieldsStarboard() {
193-
const std::string os_name = base::SysInfo::OperatingSystemName();
193+
std::string os_name = base::SysInfo::OperatingSystemName();
194+
const std::string os_friendly_name =
195+
base::starboard::SbSysInfo::OSFriendlyName();
196+
if (!os_friendly_name.empty()) {
197+
os_name = os_friendly_name + "; " + os_name;
198+
}
194199
const std::string os_version = base::SysInfo::OperatingSystemVersion();
195200
set_os_name_and_version(
196201
base::StringPrintf("%s %s", os_name.c_str(), os_version.c_str()));

0 commit comments

Comments
 (0)