0

When run the cobalt, I can see the useragent from the log:

[0101/000230:INFO:application.cc(690)] User Agent: Mozilla/5.0 (DirectFB; Linux x86_64) Cobalt/4.13031-qa (unlike Gecko) Starboard/1

So where does it come from? Is there a way to change it?

2 Answers2

1

The default useragent is set in the following file, you can have a check:

https://cobalt.googlesource.com/cobalt/+/e9b4b99dab6e774b8b6e63add74c352cc5dd395a/src/cobalt/network/user_agent_string_factory.cc

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;
}
bitchainer
  • 535
  • 2
  • 19
  • May be that you need to search the keyword though the whole source code of cobalt, and you will find it. – bitchainer Feb 10 '17 at 01:14
  • 1
    Ideally, you would just update the User-Agent string by changing the the values reported by Starboard, rather than messing with the common UserAgentStringFactory. – David Ghandehari Feb 10 '17 at 02:50
  • David is right. Never make changes to user_agent_string_factory.cc. Instead, implement system_get_property.cc, system_get_device_type.cc in Starboard correctly. Then well formatted user agent strings will be filled in automatically. – Daniel Juyung Seo Dec 12 '17 at 18:07
0

If your SbSystemGetDeviceType() is true for SystemDeviceTypeIsTv() (in file user_agent_string_factory_starboard.cc), you can customize the UA by implementing some fields of SbSystemGetProperty() + some SbSystemGet() functions.

This is a typical example:

Mozilla/5.0 (1) Cobalt/11.119147-gold (unlike Gecko) Starboard/8, 2_8_6/5 (3, 4, 7)

where,

  1. kSbSystemPropertyPlatformName
  2. kSbSystemPropertyNetworkOperatorName
  3. kSbSystemPropertyManufacturerName
  4. kSbSystemPropertyModelName
  5. kSbSystemPropertyFirmwareVersion
  6. kSbSystemPropertyChipsetModelNumber
  7. SbSystemGetConnectionType()
  8. SbSystemGetDeviceType()
Ali Azam
  • 2,047
  • 1
  • 16
  • 25
dacBR
  • 1
  • 1