0

[UA-CH] Move Sec-CH-UA-Platform-Version format to "major.minor.bugfix"

Previously, other version formats were for User-Agent compatibility,
which isn't an issue for a new header, and having one format means only
having one "parser". This will cause divergence from the user-agent
string in the following ways:

1. Windows versions will include a ".0" bugfix number where previously
   there was none.
2. MacOS versions will use periods instead of underscores
3. MacOS version will no longer be capped at "10_15_7"

Again, that divergence is not problematic as the information being
changed here is only for the new Sec-CH-UA-Platform-Version header and
navigator.userAgentMetadata, both of which have no backwards
compatibility requirements given current low usage and experimental
status.

I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/dafizBGwWMw

Bug: 1175225
Change-Id: I5e1a5dd65b9fc0bd8fa14e74082ad9d20aabc5d1
Fixed: 1208165
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2891972
Commit-Queue: Aaron Tagliaboschi <aarontag@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#893438}
This commit is contained in:
Aaron Tagliaboschi
2021-06-17 15:08:23 +00:00
committed by Chromium LUCI CQ
parent cbbf53c856
commit c42d0b6137
2 changed files with 11 additions and 5 deletions

@@ -7,6 +7,8 @@
#include "base/command_line.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "build/branding_buildflags.h"
#include "components/embedder_support/switches.h"
#include "components/version_info/version_info.h"
@@ -138,9 +140,6 @@ blink::UserAgentMetadata GetUserAgentMetadata() {
metadata.brand_version_list = GetBrandVersionList();
metadata.full_version = version_info::GetVersionNumber();
metadata.platform = GetPlatformForUAMetadata();
metadata.platform_version =
content::GetOSVersion(content::IncludeAndroidBuildNumber::Exclude,
content::IncludeAndroidModel::Exclude);
metadata.architecture = content::GetLowEntropyCpuArchitecture();
metadata.model = content::BuildModelInfo();
@@ -150,6 +149,11 @@ blink::UserAgentMetadata GetUserAgentMetadata() {
switches::kUseMobileUserAgent);
#endif
int32_t major, minor, bugfix = 0;
base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
metadata.platform_version =
base::StringPrintf("%d.%d.%d", major, minor, bugfix);
return metadata;
}

@@ -289,9 +289,11 @@ TEST(UserAgentUtilsTest, UserAgentMetadata) {
EXPECT_TRUE(contains_product_brand_version);
EXPECT_EQ(metadata.full_version, version_info::GetVersionNumber());
int32_t major, minor, bugfix = 0;
base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
EXPECT_EQ(metadata.platform_version,
content::GetOSVersion(content::IncludeAndroidBuildNumber::Exclude,
content::IncludeAndroidModel::Exclude));
base::StringPrintf("%d.%d.%d", major, minor, bugfix));
// This makes sure no extra information is added to the platform version.
EXPECT_EQ(metadata.platform_version.find(";"), std::string::npos);
// TODO(crbug.com/1103047): This can be removed/re-refactored once we use