Update DeviceType cpp enum

(First patch for Bug 1358151)

Introduced new cpp enums to describe the device type; OsType and
FormFactor.

1. Enum OsType.
2. Enum FormFactor, defines device type; desktop, phone, tablet.

Callers and tests of DeviceInfo are updated to populate the new types.
The old DeviceType enum is kept as it is for backward compatibility.

This change is needed as the old DeviceType enum is missing entries.

There should be no behavioral changes.

Bug: 1358151
Change-Id: I1d50e02ae1a593ff65dafb69afe446b14f6ab2ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3899073
Reviewed-by: Rushan Suleymanov <[email protected]>
Reviewed-by: Elly Fong-Jones <[email protected]>
Reviewed-by: Maksim Moskvitin <[email protected]>
Commit-Queue: Jood Hajeer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1051739}
diff --git a/chrome/browser/sharing/fake_device_info.cc b/chrome/browser/sharing/fake_device_info.cc
index 0967290..fbb9c0f0 100644
--- a/chrome/browser/sharing/fake_device_info.cc
+++ b/chrome/browser/sharing/fake_device_info.cc
@@ -11,14 +11,17 @@
     const std::string& name,
     const absl::optional<syncer::DeviceInfo::SharingInfo>& sharing_info,
     sync_pb::SyncEnums_DeviceType device_type,
+    syncer::DeviceInfo::OsType os_type,
+    syncer::DeviceInfo::FormFactor form_factor,
     const std::string& manufacturer_name,
     const std::string& model_name,
     const std::string& full_hardware_class,
     base::Time last_updated_timestamp) {
   return std::make_unique<syncer::DeviceInfo>(
-      guid, name, "chrome_version", "user_agent", device_type, "device_id",
-      manufacturer_name, model_name, full_hardware_class,
-      last_updated_timestamp, syncer::DeviceInfoUtil::GetPulseInterval(),
+      guid, name, "chrome_version", "user_agent", device_type, os_type,
+      form_factor, "device_id", manufacturer_name, model_name,
+      full_hardware_class, last_updated_timestamp,
+      syncer::DeviceInfoUtil::GetPulseInterval(),
       /*send_tab_to_self_receiving_enabled=*/false, sharing_info,
       /*paask_info=*/absl::nullopt,
       /*fcm_registration_token=*/std::string(),
diff --git a/chrome/browser/sharing/fake_device_info.h b/chrome/browser/sharing/fake_device_info.h
index 9501a7d2..d2fc30b 100644
--- a/chrome/browser/sharing/fake_device_info.h
+++ b/chrome/browser/sharing/fake_device_info.h
@@ -24,6 +24,9 @@
         absl::nullopt,
     sync_pb::SyncEnums_DeviceType device_type =
         sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+    syncer::DeviceInfo::OsType os_type = syncer::DeviceInfo::OsType::kLinux,
+    syncer::DeviceInfo::FormFactor form_factor =
+        syncer::DeviceInfo::FormFactor::kDesktop,
     const std::string& manufacturer_name = "manufacturer",
     const std::string& model_name = "model",
     const std::string& full_hardware_class = std::string(),
diff --git a/chrome/browser/sharing/sharing_device_source_sync_unittest.cc b/chrome/browser/sharing/sharing_device_source_sync_unittest.cc
index 19cc6ac..26b3e0d 100644
--- a/chrome/browser/sharing/sharing_device_source_sync_unittest.cc
+++ b/chrome/browser/sharing/sharing_device_source_sync_unittest.cc
@@ -53,7 +53,9 @@
 
   return CreateFakeDeviceInfo(
       base::GenerateGUID(), client_name, std::move(sharing_info),
-      sync_pb::SyncEnums_DeviceType_TYPE_LINUX, manufacturer_name, model_name);
+      sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+      syncer::DeviceInfo::OsType::kLinux,
+      syncer::DeviceInfo::FormFactor::kDesktop, manufacturer_name, model_name);
 }
 
 class SharingDeviceSourceSyncTest : public testing::Test {
diff --git a/chrome/browser/sharing/sharing_utils_unittest.cc b/chrome/browser/sharing/sharing_utils_unittest.cc
index 931aadb..0427c05 100644
--- a/chrome/browser/sharing/sharing_utils_unittest.cc
+++ b/chrome/browser/sharing/sharing_utils_unittest.cc
@@ -137,52 +137,70 @@
 TEST_F(SharingUtilsTest, GetDevicePlatform) {
   EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
                 kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-                sync_pb::SyncEnums_DeviceType_TYPE_CROS)),
+                sync_pb::SyncEnums_DeviceType_TYPE_CROS,
+                syncer::DeviceInfo::OsType::kChromeOsAsh,
+                syncer::DeviceInfo::FormFactor::kDesktop)),
             SharingDevicePlatform::kChromeOS);
 
   EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
                 kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-                sync_pb::SyncEnums_DeviceType_TYPE_LINUX)),
+                sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+                syncer::DeviceInfo::OsType::kLinux,
+                syncer::DeviceInfo::FormFactor::kDesktop)),
             SharingDevicePlatform::kLinux);
 
   EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
                 kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-                sync_pb::SyncEnums_DeviceType_TYPE_MAC)),
+                sync_pb::SyncEnums_DeviceType_TYPE_MAC,
+                syncer::DeviceInfo::OsType::kMac,
+                syncer::DeviceInfo::FormFactor::kDesktop)),
             SharingDevicePlatform::kMac);
 
   EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
                 kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-                sync_pb::SyncEnums_DeviceType_TYPE_WIN)),
+                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+                syncer::DeviceInfo::OsType::kWindows,
+                syncer::DeviceInfo::FormFactor::kDesktop)),
             SharingDevicePlatform::kWindows);
 
   EXPECT_EQ(
       GetDevicePlatform(*CreateFakeDeviceInfo(
           kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-          sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "Apple Inc.", "iPhone 50")),
+          sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+          syncer::DeviceInfo::OsType::kIOS,
+          syncer::DeviceInfo::FormFactor::kPhone, "Apple Inc.", "iPhone 50")),
       SharingDevicePlatform::kIOS);
   EXPECT_EQ(
       GetDevicePlatform(*CreateFakeDeviceInfo(
           kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-          sync_pb::SyncEnums_DeviceType_TYPE_TABLET, "Apple Inc.", "iPad 99")),
+          sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
+          syncer::DeviceInfo::OsType::kIOS,
+          syncer::DeviceInfo::FormFactor::kTablet, "Apple Inc.", "iPad 99")),
       SharingDevicePlatform::kIOS);
 
-  EXPECT_EQ(
-      GetDevicePlatform(*CreateFakeDeviceInfo(
-          kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-          sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "Google", "Pixel 777")),
-      SharingDevicePlatform::kAndroid);
-  EXPECT_EQ(
-      GetDevicePlatform(*CreateFakeDeviceInfo(
-          kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-          sync_pb::SyncEnums_DeviceType_TYPE_TABLET, "Google", "Pixel Z")),
-      SharingDevicePlatform::kAndroid);
-
   EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
                 kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-                sync_pb::SyncEnums_DeviceType_TYPE_UNSET)),
+                sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+                syncer::DeviceInfo::OsType::kAndroid,
+                syncer::DeviceInfo::FormFactor::kPhone, "Google", "Pixel 777")),
+            SharingDevicePlatform::kAndroid);
+  EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
+                kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
+                sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
+                syncer::DeviceInfo::OsType::kAndroid,
+                syncer::DeviceInfo::FormFactor::kTablet, "Google", "Pixel Z")),
+            SharingDevicePlatform::kAndroid);
+
+  EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
+                kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
+                sync_pb::SyncEnums_DeviceType_TYPE_UNSET,
+                syncer::DeviceInfo::OsType::kUnknown,
+                syncer::DeviceInfo::FormFactor::kUnknown)),
             SharingDevicePlatform::kUnknown);
   EXPECT_EQ(GetDevicePlatform(*CreateFakeDeviceInfo(
                 kDeviceGuid, kDeviceName, /*sharing_info=*/absl::nullopt,
-                sync_pb::SyncEnums_DeviceType_TYPE_OTHER)),
+                sync_pb::SyncEnums_DeviceType_TYPE_OTHER,
+                syncer::DeviceInfo::OsType::kUnknown,
+                syncer::DeviceInfo::FormFactor::kUnknown)),
             SharingDevicePlatform::kUnknown);
 }
diff --git a/chrome/browser/ui/views/sharing/sharing_browsertest.cc b/chrome/browser/ui/views/sharing/sharing_browsertest.cc
index 940cf77..1ae5377 100644
--- a/chrome/browser/ui/views/sharing/sharing_browsertest.cc
+++ b/chrome/browser/ui/views/sharing/sharing_browsertest.cc
@@ -152,7 +152,8 @@
           base::StrCat(
               {"testing_device_", base::NumberToString(fake_device_id)}),
           original_device.chrome_version(), original_device.sync_user_agent(),
-          original_device.device_type(),
+          original_device.device_type(), original_device.os_type(),
+          original_device.form_factor(),
           original_device.signin_scoped_device_id(), "Google",
           base::StrCat({"model", base::NumberToString(fake_device_id)}),
           original_device.full_hardware_class(),