当运行钴时,我可以从日志中看到使用者:
[0101/000230:INFO:application.cc(690)] User Agent: Mozilla/5.0 (DirectFB; Linux x86_64) Cobalt/4.13031-qa (unlike Gecko) Starboard/1
那么它来自哪里?有没有办法改变它?
答案 0 :(得分:1)
默认的useragent在以下文件中设置,您可以进行检查:
std::string UserAgentStringFactory::CreateUserAgentString() {
// Cobalt's user agent contains the following sections:
// Mozilla/5.0 (ChromiumStylePlatform)
// Cobalt/Version.BuildNumber-BuildConfiguration (unlike Gecko)
// Starboard/APIVersion,
// Device/FirmwareVersion (Brand, Model, ConnectionType)
// Mozilla/5.0 (ChromiumStylePlatform)
std::string user_agent =
base::StringPrintf("Mozilla/5.0 (%s)", CreatePlatformString().c_str());
// Cobalt/Version.BuildNumber-BuildConfiguration (unlike Gecko)
base::StringAppendF(&user_agent, " Cobalt/%s.%s-%s (unlike Gecko)",
COBALT_VERSION, COBALT_BUILD_VERSION_NUMBER,
kBuildConfiguration);
// Starboard/APIVersion,
if (!starboard_version_.empty()) {
base::StringAppendF(&user_agent, " %s", starboard_version_.c_str());
}
// Device/FirmwareVersion (Brand, Model, ConnectionType)
if (youtube_tv_info_) {
base::StringAppendF(
&user_agent, ", %s_%s_%s/%s (%s, %s, %s)",
youtube_tv_info_->network_operator.value_or("").c_str(),
CreateDeviceTypeString().c_str(),
youtube_tv_info_->chipset_model_number.value_or("").c_str(),
youtube_tv_info_->firmware_version.value_or("").c_str(),
youtube_tv_info_->brand.c_str(), youtube_tv_info_->model.c_str(),
CreateConnectionTypeString().c_str());
}
return user_agent;
}
答案 1 :(得分:0)
如果SbSystemGetDeviceType()
的{{1}}属于SystemDeviceTypeIsTv()
,则可以通过实施user_agent_string_factory_starboard.cc
+某些SbSystemGetProperty()
的某些字段来自定义UA功能
这是一个典型的例子:
Mozilla / 5.0( 1 )Cobalt / 11.119147-gold(与Gecko不同)Starboard / 8, 2 _ 8 _ 6 / 5 ( 3 , 4 , 7 )
其中,
- kSbSystemPropertyPlatformName
- kSbSystemPropertyNetworkOperatorName
- kSbSystemPropertyManufacturerName
- kSbSystemPropertyModelName
- kSbSystemPropertyFirmwareVersion
- kSbSystemPropertyChipsetModelNumber
- SbSystemGetConnectionType()
- SbSystemGetDeviceType()
醇>