Refactor device name from c/b/sharing to components/STTS

For all sharing features in the case where the device name is not
useful we should fall back to using a common naming scheme. This CL
adopts that common naming scheme and moves it and the required helper
functions into components for cross platform access.

Bug: 1025362
Change-Id: Ibb20dc9db3a99b24f9688fd51838febab0419694
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1919738
Commit-Queue: Jeffrey Cohen <[email protected]>
Reviewed-by: Sadrul Chowdhury <[email protected]>
Reviewed-by: Alex Chau <[email protected]>
Reviewed-by: Richard Knoll <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Cr-Commit-Position: refs/heads/master@{#717208}
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index d9144cd..9c8d16fd 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6763,20 +6763,6 @@
         Download
       </message>
 
-    <!-- Different device types using in Sharing. -->
-      <message name="IDS_BROWSER_SHARING_DEVICE_TYPE_COMPUTER" desc = "The label for a device of type computer.">
-        Computer
-      </message>
-      <message name="IDS_BROWSER_SHARING_DEVICE_TYPE_DEVICE" desc = "The label for a generic device.">
-        Device
-      </message>
-      <message name="IDS_BROWSER_SHARING_DEVICE_TYPE_PHONE" desc = "The label for a device of type phone.">
-        Phone
-      </message>
-      <message name="IDS_BROWSER_SHARING_DEVICE_TYPE_TABLET" desc = "The label for a device of type tablet.">
-        Tablet
-      </message>
-
       <!-- Sharing features. -->
       <message name="IDS_SHARING_REMOTE_COPY_NOTIFICATION_TITLE_TEXT_CONTENT_UNKNOWN_DEVICE" desc="Title text displayed in a Remote Copy (for text content) notification when the source device name is unknown.">
         Text shared from other device
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 8ea26d28..77f84543 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -3864,7 +3864,7 @@
 
     {"sharing-rename-devices", flag_descriptions::kSharingRenameDevicesName,
      flag_descriptions::kSharingRenameDevicesDescription, kOsAll,
-     FEATURE_VALUE_TYPE(kSharingRenameDevices)},
+     FEATURE_VALUE_TYPE(send_tab_to_self::kSharingRenameDevices)},
 
 #if defined(OS_CHROMEOS)
     {"discover-app", flag_descriptions::kEnableDiscoverAppName,
diff --git a/chrome/browser/sharing/features.cc b/chrome/browser/sharing/features.cc
index f4457c6..9724dc4e 100644
--- a/chrome/browser/sharing/features.cc
+++ b/chrome/browser/sharing/features.cc
@@ -15,6 +15,3 @@
 
 const base::Feature kSharingDeriveVapidKey{"SharingDeriveVapidKey",
                                            base::FEATURE_DISABLED_BY_DEFAULT};
-
-const base::Feature kSharingRenameDevices{"SharingRenameDevices",
-                                          base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/chrome/browser/sharing/features.h b/chrome/browser/sharing/features.h
index 8c88a5a..384e87b 100644
--- a/chrome/browser/sharing/features.h
+++ b/chrome/browser/sharing/features.h
@@ -20,7 +20,4 @@
 // Feature flag to enable deriving VAPID key from Sync.
 extern const base::Feature kSharingDeriveVapidKey;
 
-// Feature flag to enable device renaming.
-extern const base::Feature kSharingRenameDevices;
-
 #endif  // CHROME_BROWSER_SHARING_FEATURES_H_
diff --git a/chrome/browser/sharing/sharing_device_source_sync.cc b/chrome/browser/sharing/sharing_device_source_sync.cc
index 2b976129..c1d6d96 100644
--- a/chrome/browser/sharing/sharing_device_source_sync.cc
+++ b/chrome/browser/sharing/sharing_device_source_sync.cc
@@ -11,6 +11,7 @@
 #include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/sharing/sharing_utils.h"
+#include "components/send_tab_to_self/target_device_info.h"
 #include "components/sync/driver/sync_service.h"
 #include "components/sync_device_info/device_info.h"
 #include "components/sync_device_info/local_device_info_provider.h"
@@ -60,7 +61,7 @@
     return nullptr;
 
   device_info->set_client_name(
-      GetSharingDeviceNames(device_info.get()).full_name);
+      send_tab_to_self::GetSharingDeviceNames(device_info.get()).full_name);
   return device_info;
 }
 
@@ -117,19 +118,21 @@
                      device2->last_updated_timestamp();
             });
 
-  std::unordered_map<syncer::DeviceInfo*, SharingDeviceNames> device_names_map;
+  std::unordered_map<syncer::DeviceInfo*, send_tab_to_self::SharingDeviceNames>
+      device_names_map;
   std::unordered_set<std::string> full_names;
   std::unordered_map<std::string, int> short_names_counter;
 
   // To prevent adding candidates with same full name as local device.
-  full_names.insert(
-      GetSharingDeviceNames(local_device_info_provider_->GetLocalDeviceInfo())
-          .full_name);
+  full_names.insert(send_tab_to_self::GetSharingDeviceNames(
+                        local_device_info_provider_->GetLocalDeviceInfo())
+                        .full_name);
   // To prevent M78- instances of Chrome with same device model from showing up.
   full_names.insert(*personalizable_local_device_name_);
 
   for (const auto& device : devices) {
-    SharingDeviceNames device_names = GetSharingDeviceNames(device.get());
+    send_tab_to_self::SharingDeviceNames device_names =
+        send_tab_to_self::GetSharingDeviceNames(device.get());
 
     // Only insert the first occurrence of each device name.
     auto inserted = full_names.insert(device_names.full_name);
@@ -147,7 +150,7 @@
     if (it == device_names_map.end())
       return true;
 
-    const SharingDeviceNames& device_names = it->second;
+    const send_tab_to_self::SharingDeviceNames& device_names = it->second;
     bool unique_short_name = short_names_counter[device_names.short_name] == 1;
     device->set_client_name(unique_short_name ? device_names.short_name
                                               : device_names.full_name);
diff --git a/chrome/browser/sharing/sharing_device_source_sync_unittest.cc b/chrome/browser/sharing/sharing_device_source_sync_unittest.cc
index 69e60599..6606f7ca 100644
--- a/chrome/browser/sharing/sharing_device_source_sync_unittest.cc
+++ b/chrome/browser/sharing/sharing_device_source_sync_unittest.cc
@@ -14,6 +14,8 @@
 #include "base/time/time.h"
 #include "chrome/browser/sharing/features.h"
 #include "chrome/browser/sharing/sharing_utils.h"
+#include "components/send_tab_to_self/features.h"
+#include "components/send_tab_to_self/target_device_info.h"
 #include "components/sync/driver/test_sync_service.h"
 #include "components/sync_device_info/device_info.h"
 #include "components/sync_device_info/fake_device_info_tracker.h"
@@ -39,7 +41,8 @@
 class SharingDeviceSourceSyncTest : public testing::Test {
  public:
   SharingDeviceSourceSyncTest() {
-    scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
+    scoped_feature_list_.InitAndEnableFeature(
+        send_tab_to_self::kSharingRenameDevices);
   }
 
   std::unique_ptr<SharingDeviceSourceSync> CreateDeviceSource(
@@ -211,12 +214,16 @@
 
   auto devices = device_source->GetAllDevices();
   ASSERT_EQ(4u, devices.size());
-  EXPECT_EQ(GetSharingDeviceNames(device_info_4.get()).short_name,
-            devices[0]->client_name());
-  EXPECT_EQ(GetSharingDeviceNames(device_info_3.get()).full_name,
-            devices[1]->client_name());
-  EXPECT_EQ(GetSharingDeviceNames(device_info_2.get()).full_name,
-            devices[2]->client_name());
-  EXPECT_EQ(GetSharingDeviceNames(device_info_1.get()).short_name,
-            devices[3]->client_name());
+  EXPECT_EQ(
+      send_tab_to_self::GetSharingDeviceNames(device_info_4.get()).short_name,
+      devices[0]->client_name());
+  EXPECT_EQ(
+      send_tab_to_self::GetSharingDeviceNames(device_info_3.get()).full_name,
+      devices[1]->client_name());
+  EXPECT_EQ(
+      send_tab_to_self::GetSharingDeviceNames(device_info_2.get()).full_name,
+      devices[2]->client_name());
+  EXPECT_EQ(
+      send_tab_to_self::GetSharingDeviceNames(device_info_1.get()).short_name,
+      devices[3]->client_name());
 }
diff --git a/chrome/browser/sharing/sharing_message_sender.cc b/chrome/browser/sharing/sharing_message_sender.cc
index e735df2f6..e02c1ae 100644
--- a/chrome/browser/sharing/sharing_message_sender.cc
+++ b/chrome/browser/sharing/sharing_message_sender.cc
@@ -9,6 +9,7 @@
 #include "chrome/browser/sharing/sharing_metrics.h"
 #include "chrome/browser/sharing/sharing_sync_preference.h"
 #include "chrome/browser/sharing/sharing_utils.h"
+#include "components/send_tab_to_self/target_device_info.h"
 #include "components/sync_device_info/local_device_info_provider.h"
 #include "content/public/browser/browser_task_traits.h"
 
@@ -75,7 +76,7 @@
 
   message.set_sender_guid(local_device_info->guid());
   message.set_sender_device_name(
-      GetSharingDeviceNames(local_device_info).full_name);
+      send_tab_to_self::GetSharingDeviceNames(local_device_info).full_name);
 
   auto* sender_info = message.mutable_sender_info();
   sender_info->set_fcm_token(sharing_info->vapid_target_info.fcm_token);
diff --git a/chrome/browser/sharing/sharing_message_sender_unittest.cc b/chrome/browser/sharing/sharing_message_sender_unittest.cc
index 86ec054..619e196 100644
--- a/chrome/browser/sharing/sharing_message_sender_unittest.cc
+++ b/chrome/browser/sharing/sharing_message_sender_unittest.cc
@@ -10,6 +10,7 @@
 #include "chrome/browser/sharing/sharing_metrics.h"
 #include "chrome/browser/sharing/sharing_sync_preference.h"
 #include "chrome/browser/sharing/sharing_utils.h"
+#include "components/send_tab_to_self/target_device_info.h"
 #include "components/sync_device_info/device_info.h"
 #include "components/sync_device_info/fake_device_info_sync_service.h"
 #include "components/sync_device_info/fake_local_device_info_provider.h"
@@ -223,8 +224,9 @@
             fake_device_info_sync_service_.GetLocalDeviceInfoProvider()
                 ->GetLocalDeviceInfo();
         ASSERT_EQ(local_device->guid(), message.sender_guid());
-        ASSERT_EQ(GetSharingDeviceNames(local_device).full_name,
-                  message.sender_device_name());
+        ASSERT_EQ(
+            send_tab_to_self::GetSharingDeviceNames(local_device).full_name,
+            message.sender_device_name());
         ASSERT_TRUE(local_device->sharing_info().has_value());
         ASSERT_EQ(kSenderVapidFcmToken, message.sender_info().fcm_token());
         ASSERT_EQ(kSenderP256dh, message.sender_info().p256dh());
diff --git a/chrome/browser/sharing/sharing_utils.cc b/chrome/browser/sharing/sharing_utils.cc
index c1913db4..16fe76d3 100644
--- a/chrome/browser/sharing/sharing_utils.cc
+++ b/chrome/browser/sharing/sharing_utils.cc
@@ -5,52 +5,10 @@
 #include "chrome/browser/sharing/sharing_utils.h"
 
 #include "base/feature_list.h"
-#include "base/strings/strcat.h"
 #include "chrome/browser/sharing/features.h"
-#include "chrome/grit/generated_resources.h"
 #include "components/sync/driver/sync_service.h"
-#include "components/sync_device_info/device_info.h"
-#include "ui/base/l10n/l10n_util.h"
 
 namespace {
-// Util function to return a string denoting the type of device.
-std::string GetDeviceType(sync_pb::SyncEnums::DeviceType type) {
-  int device_type_message_id = -1;
-
-  switch (type) {
-    case sync_pb::SyncEnums::TYPE_LINUX:
-    case sync_pb::SyncEnums::TYPE_WIN:
-    case sync_pb::SyncEnums::TYPE_CROS:
-    case sync_pb::SyncEnums::TYPE_MAC:
-      device_type_message_id = IDS_BROWSER_SHARING_DEVICE_TYPE_COMPUTER;
-      break;
-
-    case sync_pb::SyncEnums::TYPE_UNSET:
-    case sync_pb::SyncEnums::TYPE_OTHER:
-      device_type_message_id = IDS_BROWSER_SHARING_DEVICE_TYPE_DEVICE;
-      break;
-
-    case sync_pb::SyncEnums::TYPE_PHONE:
-      device_type_message_id = IDS_BROWSER_SHARING_DEVICE_TYPE_PHONE;
-      break;
-
-    case sync_pb::SyncEnums::TYPE_TABLET:
-      device_type_message_id = IDS_BROWSER_SHARING_DEVICE_TYPE_TABLET;
-      break;
-  }
-
-  return l10n_util::GetStringUTF8(device_type_message_id);
-}
-
-std::string CapitalizeWords(const std::string& sentence) {
-  std::string capitalized_sentence;
-  bool use_upper_case = true;
-  for (char ch : sentence) {
-    capitalized_sentence += (use_upper_case ? toupper(ch) : ch);
-    use_upper_case = !isalpha(ch);
-  }
-  return capitalized_sentence;
-}
 
 syncer::ModelTypeSet GetRequiredSyncDataTypes() {
   // DeviceInfo is always required to list devices.
@@ -67,51 +25,6 @@
 
 }  // namespace
 
-SharingDeviceNames GetSharingDeviceNames(const syncer::DeviceInfo* device) {
-  DCHECK(device);
-  SharingDeviceNames device_names;
-
-  base::SysInfo::HardwareInfo hardware_info = device->hardware_info();
-  sync_pb::SyncEnums::DeviceType type = device->device_type();
-  // 1. Skip renaming for M78- devices where HardwareInfo is not available.
-  // 2. Skip renaming if client_name is high quality i.e. not equals to model.
-  // 3. Skip renaming for Android and Chrome OS devices if feature is not
-  //    enabled, which always have low quality client_name.
-  if (hardware_info.model.empty() ||
-      hardware_info.model != device->client_name() ||
-      (!base::FeatureList::IsEnabled(kSharingRenameDevices) &&
-       (type == sync_pb::SyncEnums::TYPE_CROS ||
-        type == sync_pb::SyncEnums::TYPE_PHONE ||
-        type == sync_pb::SyncEnums::TYPE_TABLET))) {
-    device_names.full_name = device_names.short_name = device->client_name();
-    return device_names;
-  }
-
-  hardware_info.manufacturer = CapitalizeWords(hardware_info.manufacturer);
-
-  // For chromeOS, return manufacturer + model.
-  if (type == sync_pb::SyncEnums::TYPE_CROS) {
-    device_names.short_name = device_names.full_name =
-        base::StrCat({hardware_info.manufacturer, " ", hardware_info.model});
-    return device_names;
-  }
-
-  if (hardware_info.manufacturer == "Apple Inc.") {
-    // Internal names of Apple devices are formatted as MacbookPro2,3 or
-    // iPhone2,1 or Ipad4,1.
-    device_names.short_name = hardware_info.model.substr(
-        0, hardware_info.model.find_first_of("0123456789,"));
-    device_names.full_name = hardware_info.model;
-    return device_names;
-  }
-
-  device_names.short_name =
-      base::StrCat({hardware_info.manufacturer, " ", GetDeviceType(type)});
-  device_names.full_name =
-      base::StrCat({device_names.short_name, " ", hardware_info.model});
-  return device_names;
-}
-
 bool IsSyncEnabledForSharing(syncer::SyncService* sync_service) {
   if (!sync_service)
     return false;
diff --git a/chrome/browser/sharing/sharing_utils.h b/chrome/browser/sharing/sharing_utils.h
index 040666e9..1eb41bd 100644
--- a/chrome/browser/sharing/sharing_utils.h
+++ b/chrome/browser/sharing/sharing_utils.h
@@ -8,18 +8,9 @@
 #include <string>
 
 namespace syncer {
-class DeviceInfo;
 class SyncService;
 }  // namespace syncer
 
-struct SharingDeviceNames {
-  std::string full_name;
-  std::string short_name;
-};
-
-// Returns full and short names for |device|.
-SharingDeviceNames GetSharingDeviceNames(const syncer::DeviceInfo* device);
-
 // Returns true if required sync feature is enabled.
 bool IsSyncEnabledForSharing(syncer::SyncService* sync_service);
 
diff --git a/chrome/browser/sharing/sharing_utils_unittest.cc b/chrome/browser/sharing/sharing_utils_unittest.cc
index 54c52b6..faa2f1d 100644
--- a/chrome/browser/sharing/sharing_utils_unittest.cc
+++ b/chrome/browser/sharing/sharing_utils_unittest.cc
@@ -21,186 +21,8 @@
   syncer::TestSyncService test_sync_service_;
 };
 
-static std::unique_ptr<syncer::DeviceInfo> CreateFakeDeviceInfo(
-    const std::string& id,
-    const std::string& name,
-    sync_pb::SyncEnums_DeviceType device_type =
-        sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
-    base::SysInfo::HardwareInfo hardware_info = base::SysInfo::HardwareInfo()) {
-  return std::make_unique<syncer::DeviceInfo>(
-      id, name, "chrome_version", "user_agent", device_type, "device_id",
-      hardware_info,
-      /*last_updated_timestamp=*/base::Time::Now(),
-      /*send_tab_to_self_receiving_enabled=*/false,
-      syncer::DeviceInfo::SharingInfo(
-          {"vapid_fcm_token", "vapid_p256dh", "vapid_auth_secret"},
-          {"sender_id_fcm_token", "sender_id_p256dh", "sender_id_auth_secret"},
-          std::set<sync_pb::SharingSpecificFields::EnabledFeatures>{
-              sync_pb::SharingSpecificFields::CLICK_TO_CALL}));
-}
-
 }  // namespace
 
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_AppleDevices_SigninOnly) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "MacbookPro1,1", sync_pb::SyncEnums_DeviceType_TYPE_MAC,
-      {"Apple Inc.", "MacbookPro1,1", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("MacbookPro1,1", names.full_name);
-  EXPECT_EQ("MacbookPro", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_AppleDevices_FullySynced) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Bobs-iMac", sync_pb::SyncEnums_DeviceType_TYPE_MAC,
-      {"Apple Inc.", "MacbookPro1,1", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Bobs-iMac", names.full_name);
-  EXPECT_EQ("Bobs-iMac", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_ChromeOSDevices_FeatureEnabled) {
-  scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Chromebook", sync_pb::SyncEnums_DeviceType_TYPE_CROS,
-      {"Google", "Chromebook", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Google Chromebook", names.full_name);
-  EXPECT_EQ("Google Chromebook", names.short_name);
-}
-
-TEST_F(SharingUtilsTest,
-       GetSharingDeviceNames_ChromeOSDevices_FeatureDisabled) {
-  scoped_feature_list_.InitAndDisableFeature(kSharingRenameDevices);
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Chromebook", sync_pb::SyncEnums_DeviceType_TYPE_CROS,
-      {"Google", "Chromebook", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Chromebook", names.full_name);
-  EXPECT_EQ("Chromebook", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidPhones_FeatureEnabled) {
-  scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Pixel 2", sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
-      {"Google", "Pixel 2", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Google Phone Pixel 2", names.full_name);
-  EXPECT_EQ("Google Phone", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidPhones_FeatureDisabled) {
-  scoped_feature_list_.InitAndDisableFeature(kSharingRenameDevices);
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Pixel 2", sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
-      {"Google", "Pixel 2", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Pixel 2", names.full_name);
-  EXPECT_EQ("Pixel 2", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidTablets_FeatureEnabled) {
-  scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Pixel C", sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
-      {"Google", "Pixel C", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Google Tablet Pixel C", names.full_name);
-  EXPECT_EQ("Google Tablet", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidTablets_FeatureDisabled) {
-  scoped_feature_list_.InitAndDisableFeature(kSharingRenameDevices);
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "Pixel C", sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
-      {"Google", "Pixel C", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Pixel C", names.full_name);
-  EXPECT_EQ("Pixel C", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_Windows_SigninOnly) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "BX123", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
-      {"Dell", "BX123", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Dell Computer BX123", names.full_name);
-  EXPECT_EQ("Dell Computer", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_Windows_FullySynced) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "BOBS-WINDOWS-1", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
-      {"Dell", "BX123", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("BOBS-WINDOWS-1", names.full_name);
-  EXPECT_EQ("BOBS-WINDOWS-1", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_Linux_SigninOnly) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "30BDS0RA0G", sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
-      {"LENOVO", "30BDS0RA0G", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("LENOVO Computer 30BDS0RA0G", names.full_name);
-  EXPECT_EQ("LENOVO Computer", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, GetSharingDeviceNames_Linux_FullySynced) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "bob.chromium.org", sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
-      {"LENOVO", "30BDS0RA0G", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("bob.chromium.org", names.full_name);
-  EXPECT_EQ("bob.chromium.org", names.short_name);
-}
-
-TEST_F(SharingUtilsTest, CheckManufacturerNameCapitalization) {
-  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
-      "guid", "model", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
-      {"foo bar", "model", ""});
-  SharingDeviceNames names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Foo Bar Computer model", names.full_name);
-  EXPECT_EQ("Foo Bar Computer", names.short_name);
-
-  device = CreateFakeDeviceInfo("guid", "model",
-                                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
-                                {"foo1bar", "model", ""});
-  names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Foo1Bar Computer model", names.full_name);
-  EXPECT_EQ("Foo1Bar Computer", names.short_name);
-
-  device = CreateFakeDeviceInfo("guid", "model",
-                                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
-                                {"foo_bar-FOO", "model", ""});
-  names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Foo_Bar-FOO Computer model", names.full_name);
-  EXPECT_EQ("Foo_Bar-FOO Computer", names.short_name);
-
-  device = CreateFakeDeviceInfo("guid", "model",
-                                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
-                                {"foo&bar foo", "model", ""});
-  names = GetSharingDeviceNames(device.get());
-
-  EXPECT_EQ("Foo&Bar Foo Computer model", names.full_name);
-  EXPECT_EQ("Foo&Bar Foo Computer", names.short_name);
-}
 
 TEST_F(SharingUtilsTest, SyncEnabled_SigninOnly) {
   // Enable transport mode required features.
diff --git a/chrome/browser/ui/send_tab_to_self/send_tab_to_self_sub_menu_model_unittest.cc b/chrome/browser/ui/send_tab_to_self/send_tab_to_self_sub_menu_model_unittest.cc
index 16f6d73c..4798bf0 100644
--- a/chrome/browser/ui/send_tab_to_self/send_tab_to_self_sub_menu_model_unittest.cc
+++ b/chrome/browser/ui/send_tab_to_self/send_tab_to_self_sub_menu_model_unittest.cc
@@ -55,7 +55,7 @@
 
 TargetDeviceInfo BuildTargetDeviceInfo(const std::string& device_name,
                                        const std::string& cache_guid) {
-  return TargetDeviceInfo(device_name, cache_guid,
+  return TargetDeviceInfo(device_name, device_name, cache_guid,
                           sync_pb::SyncEnums_DeviceType_TYPE_OTHER,
                           base::Time());
 }
diff --git a/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_bubble_view_impl_unittest.cc b/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_bubble_view_impl_unittest.cc
index 1649c50..54a3580 100644
--- a/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_bubble_view_impl_unittest.cc
+++ b/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_bubble_view_impl_unittest.cc
@@ -75,13 +75,16 @@
     base::SimpleTestClock clock;
     std::vector<TargetDeviceInfo> list;
     TargetDeviceInfo valid_device_1(
-        "Device_1", "device_guid_1", sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+        "Device_1", "Device_1", "device_guid_1",
+        sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
         /*last_updated_timestamp=*/clock.Now() - base::TimeDelta::FromDays(0));
     TargetDeviceInfo valid_device_2(
-        "Device_2", "device_guid_2", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+        "Device_2", "Device_2", "device_guid_2",
+        sync_pb::SyncEnums_DeviceType_TYPE_WIN,
         /*last_updated_timestamp=*/clock.Now() - base::TimeDelta::FromDays(1));
     TargetDeviceInfo valid_device_3(
-        "Device_3", "device_guid_3", sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+        "Device_3", "Device_3", "device_guid_3",
+        sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
         /*last_updated_timestamp=*/clock.Now() - base::TimeDelta::FromDays(5));
     list.push_back(valid_device_1);
     list.push_back(valid_device_2);
diff --git a/components/OWNERS b/components/OWNERS
index cbbf1d9..df01025 100644
--- a/components/OWNERS
+++ b/components/OWNERS
@@ -30,6 +30,7 @@
 per-file reset_password_strings.grdp=file://components/safe_browsing/OWNERS
 per-file security_interstitials_strings.grdp=file://components/security_interstitials/OWNERS
 per-file security_state_strings.grdp=file://components/security_state/OWNERS
+per-file send_tab_to_self_strings.grdp=file://components/send_tab_to_self/OWNERS
 per-file ssl_errors_strings.grdp=file://components/ssl_errors/OWNERS
 per-file sync_ui_strings.grdp=file://components/sync/OWNERS
 per-file translate_strings.grdp=file://components/translate/OWNERS
diff --git a/components/components_strings.grd b/components/components_strings.grd
index a8cfbd9..69df2ec 100644
--- a/components/components_strings.grd
+++ b/components/components_strings.grd
@@ -223,6 +223,7 @@
       <part file="safe_browsing_strings.grdp" />
       <part file="security_interstitials_strings.grdp" />
       <part file="security_state_strings.grdp" />
+      <part file="send_tab_to_self_strings.grdp" />
       <part file="ssl_errors_strings.grdp" />
       <part file="sync_ui_strings.grdp" />
       <part file="translate_strings.grdp" />
diff --git a/components/send_tab_to_self/BUILD.gn b/components/send_tab_to_self/BUILD.gn
index 162d558..d00fedc 100644
--- a/components/send_tab_to_self/BUILD.gn
+++ b/components/send_tab_to_self/BUILD.gn
@@ -27,10 +27,12 @@
     "//components/history/core/browser",
     "//components/keyed_service/core",
     "//components/send_tab_to_self/proto:send_tab_to_self_proto",
+    "//components/strings",
     "//components/sync",
     "//components/sync_device_info",
     "//components/version_info",
     "//google_apis",
+    "//ui/base",
     "//url",
   ]
   public_deps = [
@@ -66,6 +68,7 @@
     "features_unittest.cc",
     "send_tab_to_self_bridge_unittest.cc",
     "send_tab_to_self_entry_unittest.cc",
+    "target_device_info_unittest.cc",
   ]
   deps = [
     ":send_tab_to_self",
diff --git a/components/send_tab_to_self/DEPS b/components/send_tab_to_self/DEPS
index 153f0a6..1c57b57d 100644
--- a/components/send_tab_to_self/DEPS
+++ b/components/send_tab_to_self/DEPS
@@ -2,10 +2,12 @@
   "+components/history",
   "+components/infobars",
   "+components/keyed_service/core",
+  "+components/strings",
   "+components/sync",
   "+components/sync_device_info",
   "+components/sync_preferences",
   "+components/version_info",
   "+content/public/browser",
   "+google_apis",
+  "+ui/base",
 ]
diff --git a/components/send_tab_to_self/OWNERS b/components/send_tab_to_self/OWNERS
index 37c75ef..4c3ab08 100644
--- a/components/send_tab_to_self/OWNERS
+++ b/components/send_tab_to_self/OWNERS
@@ -4,4 +4,7 @@
 [email protected]
 [email protected]
 
+# target_device_info is used by multiple sharing teams.
+per-file target_device_info.*=file://chrome/browser/sharing/OWNERS
+
 # COMPONENT: UI>Browser>Sharing
diff --git a/components/send_tab_to_self/features.cc b/components/send_tab_to_self/features.cc
index 0f744f7a4..795a4949 100644
--- a/components/send_tab_to_self/features.cc
+++ b/components/send_tab_to_self/features.cc
@@ -15,6 +15,9 @@
 const base::Feature kSendTabToSelfWhenSignedIn{
     "SendTabToSelfWhenSignedIn", base::FEATURE_DISABLED_BY_DEFAULT};
 
+const base::Feature kSharingRenameDevices{"SharingRenameDevices",
+                                          base::FEATURE_DISABLED_BY_DEFAULT};
+
 bool IsReceivingEnabledByUserOnThisDevice(PrefService* prefs) {
   // TODO(crbug.com/1015322): SyncPrefs is used directly instead of methods in
   // SyncService due to a dependency of ProfileSyncService on
diff --git a/components/send_tab_to_self/features.h b/components/send_tab_to_self/features.h
index f34ac57..2689d2a2 100644
--- a/components/send_tab_to_self/features.h
+++ b/components/send_tab_to_self/features.h
@@ -20,6 +20,9 @@
 // of whether they have the sync feature enabled.
 extern const base::Feature kSendTabToSelfWhenSignedIn;
 
+// Feature flag to enable device renaming.
+extern const base::Feature kSharingRenameDevices;
+
 // Returns whether the receiving components of the feature is enabled on this
 // device. This is different from IsReceivingEnabled in SendTabToSelfUtil
 // because it doesn't rely on the SendTabToSelfSyncService to be actively up and
diff --git a/components/send_tab_to_self/send_tab_to_self_bridge.cc b/components/send_tab_to_self/send_tab_to_self_bridge.cc
index 6ee1228b4..d52655a1 100644
--- a/components/send_tab_to_self/send_tab_to_self_bridge.cc
+++ b/components/send_tab_to_self/send_tab_to_self_bridge.cc
@@ -728,6 +728,7 @@
 
   target_device_name_to_cache_info_.clear();
   std::set<std::string> unique_device_names;
+  std::unordered_map<std::string, int> short_names_counter;
   for (const auto& device : all_devices) {
     // If the current device is considered expired for our purposes, stop here
     // since the next devices in the vector are at least as expired than this
@@ -749,16 +750,25 @@
       continue;
     }
 
+    SharingDeviceNames device_names = GetSharingDeviceNames(device.get());
+
     // Only keep one device per device name. We only keep the first occurrence
     // which is the most recent.
-    if (unique_device_names.insert(device->client_name()).second) {
-      TargetDeviceInfo target_device_info(device->client_name(), device->guid(),
-                                          device->device_type(),
-                                          device->last_updated_timestamp());
+    if (unique_device_names.insert(device_names.full_name).second) {
+      TargetDeviceInfo target_device_info(
+          device_names.full_name, device_names.short_name, device->guid(),
+          device->device_type(), device->last_updated_timestamp());
       target_device_name_to_cache_info_.push_back(target_device_info);
       oldest_non_expired_device_timestamp_ = device->last_updated_timestamp();
+
+      short_names_counter[device_names.short_name]++;
     }
   }
+  for (auto& device_info : target_device_name_to_cache_info_) {
+    bool unique_short_name = short_names_counter[device_info.short_name] == 1;
+    device_info.device_name =
+        (unique_short_name ? device_info.short_name : device_info.full_name);
+  }
 }
 
 void SendTabToSelfBridge::DeleteEntryWithBatch(
diff --git a/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc b/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
index 86df516..0261a61 100644
--- a/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
+++ b/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
@@ -675,8 +675,9 @@
   AddTestDevice(&older_device);
 
   TargetDeviceInfo target_device_info(
-      recent_device.client_name(), recent_device.guid(),
-      recent_device.device_type(), recent_device.last_updated_timestamp());
+      recent_device.client_name(), recent_device.client_name(),
+      recent_device.guid(), recent_device.device_type(),
+      recent_device.last_updated_timestamp());
 
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
               ElementsAre(target_device_info));
@@ -707,8 +708,9 @@
   AddTestDevice(&disabled_device);
 
   TargetDeviceInfo target_device_info(
-      enabled_device.client_name(), enabled_device.guid(),
-      enabled_device.device_type(), enabled_device.last_updated_timestamp());
+      enabled_device.client_name(), enabled_device.client_name(),
+      enabled_device.guid(), enabled_device.device_type(),
+      enabled_device.last_updated_timestamp());
 
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
               ElementsAre(target_device_info));
@@ -738,8 +740,9 @@
   AddTestDevice(&valid_device);
 
   TargetDeviceInfo target_device_info(
-      valid_device.client_name(), valid_device.guid(),
-      valid_device.device_type(), valid_device.last_updated_timestamp());
+      valid_device.client_name(), valid_device.client_name(),
+      valid_device.guid(), valid_device.device_type(),
+      valid_device.last_updated_timestamp());
 
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
               ElementsAre(target_device_info));
@@ -778,8 +781,9 @@
   AddTestDevice(&other_device);
 
   TargetDeviceInfo target_device_info(
-      other_device.client_name(), other_device.guid(),
-      other_device.device_type(), other_device.last_updated_timestamp());
+      other_device.client_name(), other_device.client_name(),
+      other_device.guid(), other_device.device_type(),
+      other_device.last_updated_timestamp());
 
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
               ElementsAre(target_device_info));
@@ -810,11 +814,13 @@
   AddTestDevice(&recent_device);
 
   TargetDeviceInfo older_device_info(
-      older_device.client_name(), older_device.guid(),
-      older_device.device_type(), older_device.last_updated_timestamp());
+      older_device.client_name(), older_device.client_name(),
+      older_device.guid(), older_device.device_type(),
+      older_device.last_updated_timestamp());
   TargetDeviceInfo recent_device_info(
-      recent_device.client_name(), recent_device.guid(),
-      recent_device.device_type(), recent_device.last_updated_timestamp());
+      recent_device.client_name(), recent_device.client_name(),
+      recent_device.guid(), recent_device.device_type(),
+      recent_device.last_updated_timestamp());
 
   // Set the map by calling it. Make sure it has the 2 devices.
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
@@ -843,8 +849,8 @@
   AddTestDevice(&device);
 
   // Set the map by calling it. Make sure it has the device.
-  TargetDeviceInfo device_info(device.client_name(), device.guid(),
-                               device.device_type(),
+  TargetDeviceInfo device_info(device.client_name(), device.client_name(),
+                               device.guid(), device.device_type(),
                                device.last_updated_timestamp());
 
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
@@ -860,9 +866,9 @@
   AddTestDevice(&new_device);
 
   // Make sure both devices are in the map.
-  TargetDeviceInfo new_device_info(new_device.client_name(), new_device.guid(),
-                                   new_device.device_type(),
-                                   new_device.last_updated_timestamp());
+  TargetDeviceInfo new_device_info(
+      new_device.client_name(), new_device.client_name(), new_device.guid(),
+      new_device.device_type(), new_device.last_updated_timestamp());
 
   EXPECT_THAT(bridge()->GetTargetDeviceInfoSortedList(),
               ElementsAre(device_info, new_device_info));
diff --git a/components/send_tab_to_self/target_device_info.cc b/components/send_tab_to_self/target_device_info.cc
index 5baffdce..d19ecda 100644
--- a/components/send_tab_to_self/target_device_info.cc
+++ b/components/send_tab_to_self/target_device_info.cc
@@ -4,23 +4,129 @@
 
 #include "components/send_tab_to_self/target_device_info.h"
 
+#include "base/feature_list.h"
+#include "base/strings/strcat.h"
+#include "components/send_tab_to_self/features.h"
+#include "components/strings/grit/components_strings.h"
+#include "components/sync_device_info/device_info.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+std::string GetDeviceType(sync_pb::SyncEnums::DeviceType type) {
+  int device_type_message_id = -1;
+
+  switch (type) {
+    case sync_pb::SyncEnums::TYPE_LINUX:
+    case sync_pb::SyncEnums::TYPE_WIN:
+    case sync_pb::SyncEnums::TYPE_CROS:
+    case sync_pb::SyncEnums::TYPE_MAC:
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_COMPUTER;
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_COMPUTER;
+      break;
+
+    case sync_pb::SyncEnums::TYPE_UNSET:
+    case sync_pb::SyncEnums::TYPE_OTHER:
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_DEVICE;
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_DEVICE;
+      break;
+
+    case sync_pb::SyncEnums::TYPE_PHONE:
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_PHONE;
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_PHONE;
+      break;
+
+    case sync_pb::SyncEnums::TYPE_TABLET:
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_TABLET;
+      device_type_message_id = IDS_SHARING_DEVICE_TYPE_TABLET;
+      break;
+  }
+
+  return l10n_util::GetStringUTF8(device_type_message_id);
+}
+
+std::string CapitalizeWords(const std::string& sentence) {
+  std::string capitalized_sentence;
+  bool use_upper_case = true;
+  for (char ch : sentence) {
+    capitalized_sentence += (use_upper_case ? toupper(ch) : ch);
+    use_upper_case = !isalpha(ch);
+  }
+  return capitalized_sentence;
+}
+
+}  // namespace
+
 namespace send_tab_to_self {
 
 TargetDeviceInfo::TargetDeviceInfo(
-    const std::string& device_name,
+    const std::string& full_name,
+    const std::string& short_name,
     const std::string& cache_guid,
     const sync_pb::SyncEnums::DeviceType device_type,
     base::Time last_updated_timestamp)
-    : device_name(device_name),
+    : full_name(full_name),
+      short_name(short_name),
+      device_name(short_name),
       cache_guid(cache_guid),
       device_type(device_type),
       last_updated_timestamp(last_updated_timestamp) {}
 
+TargetDeviceInfo::TargetDeviceInfo(const TargetDeviceInfo& other) = default;
+TargetDeviceInfo::~TargetDeviceInfo() {}
+
 bool TargetDeviceInfo::operator==(const TargetDeviceInfo& rhs) const {
-  return this->device_name == rhs.device_name &&
+  return this->full_name == rhs.full_name &&
+         this->short_name == rhs.short_name &&
+         this->device_name == rhs.device_name &&
          this->cache_guid == rhs.cache_guid &&
          this->device_type == rhs.device_type &&
          this->last_updated_timestamp == rhs.last_updated_timestamp;
 }
 
+SharingDeviceNames GetSharingDeviceNames(const syncer::DeviceInfo* device) {
+  DCHECK(device);
+  SharingDeviceNames device_names;
+
+  base::SysInfo::HardwareInfo hardware_info = device->hardware_info();
+  hardware_info.manufacturer = CapitalizeWords(hardware_info.manufacturer);
+  sync_pb::SyncEnums::DeviceType type = device->device_type();
+
+  // 1. Skip renaming for M78- devices where HardwareInfo is not available.
+  // 2. Skip renaming if client_name is high quality i.e. not equals to model.
+  // 3. Skip renaming for Android and Chrome OS devices if feature is not
+  //    enabled, which always have low quality client_name.
+  if (hardware_info.model.empty() ||
+      hardware_info.model != device->client_name() ||
+      (!base::FeatureList::IsEnabled(kSharingRenameDevices) &&
+       (type == sync_pb::SyncEnums::TYPE_CROS ||
+        type == sync_pb::SyncEnums::TYPE_PHONE ||
+        type == sync_pb::SyncEnums::TYPE_TABLET))) {
+    device_names.full_name = device_names.short_name = device->client_name();
+    return device_names;
+  }
+
+  // For chromeOS, return manufacturer + model.
+  if (type == sync_pb::SyncEnums::TYPE_CROS) {
+    device_names.short_name = device_names.full_name =
+        base::StrCat({hardware_info.manufacturer, " ", hardware_info.model});
+    return device_names;
+  }
+
+  if (hardware_info.manufacturer == "Apple Inc.") {
+    // Internal names of Apple devices are formatted as MacbookPro2, 3 or //
+    // iPhone2,1 or Ipad4, 1.
+    device_names.short_name = hardware_info.model.substr(
+        0, hardware_info.model.find_first_of("0123456789,"));
+    device_names.full_name = hardware_info.model;
+    return device_names;
+  }
+
+  device_names.short_name =
+      base::StrCat({hardware_info.manufacturer, " ", GetDeviceType(type)});
+  device_names.full_name =
+      base::StrCat({device_names.short_name, " ", hardware_info.model});
+  return device_names;
+}
+
 }  // namespace send_tab_to_self
diff --git a/components/send_tab_to_self/target_device_info.h b/components/send_tab_to_self/target_device_info.h
index 872d2f8..22a52986 100644
--- a/components/send_tab_to_self/target_device_info.h
+++ b/components/send_tab_to_self/target_device_info.h
@@ -10,20 +10,35 @@
 #include "base/time/time.h"
 #include "components/sync/protocol/sync.pb.h"
 
+namespace syncer {
+class DeviceInfo;
+}  // namespace syncer
+
 namespace send_tab_to_self {
+
+struct SharingDeviceNames {
+  std::string full_name;
+  std::string short_name;
+};
+
 // Device information for generating send tab to self UI.
 struct TargetDeviceInfo {
  public:
-  TargetDeviceInfo(const std::string& device_name,
+  TargetDeviceInfo(const std::string& full_name,
+                   const std::string& short_name,
                    const std::string& cache_guid,
                    const sync_pb::SyncEnums::DeviceType device_type,
                    base::Time last_updated_timestamp);
-  TargetDeviceInfo(const TargetDeviceInfo& other) = default;
-  ~TargetDeviceInfo() = default;
+  TargetDeviceInfo(const TargetDeviceInfo& other);
+  ~TargetDeviceInfo();
 
   bool operator==(const TargetDeviceInfo& rhs) const;
 
-  // Device name.
+  // Device full name.
+  std::string full_name;
+  // Device short name.
+  std::string short_name;
+  // Device name
   std::string device_name;
   // Device guid.
   std::string cache_guid;
@@ -33,6 +48,9 @@
   base::Time last_updated_timestamp;
 };
 
+// Returns full and short names for |device|.
+SharingDeviceNames GetSharingDeviceNames(const syncer::DeviceInfo* device);
+
 }  // namespace send_tab_to_self
 
 #endif  // COMPONENTS_SEND_TAB_TO_SELF_TARGET_DEVICE_INFO_H_
diff --git a/components/send_tab_to_self/target_device_info_unittest.cc b/components/send_tab_to_self/target_device_info_unittest.cc
new file mode 100644
index 0000000..be470bb
--- /dev/null
+++ b/components/send_tab_to_self/target_device_info_unittest.cc
@@ -0,0 +1,207 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/send_tab_to_self/target_device_info.h"
+
+#include "base/test/scoped_feature_list.h"
+#include "components/send_tab_to_self/features.h"
+#include "components/sync/driver/test_sync_service.h"
+#include "components/sync_device_info/device_info.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace send_tab_to_self {
+
+namespace {
+
+class SharingUtilsTest : public testing::Test {
+ public:
+  SharingUtilsTest() = default;
+
+ protected:
+  base::test::ScopedFeatureList scoped_feature_list_;
+  syncer::TestSyncService test_sync_service_;
+};
+
+static std::unique_ptr<syncer::DeviceInfo> CreateFakeDeviceInfo(
+    const std::string& id,
+    const std::string& name,
+    sync_pb::SyncEnums_DeviceType device_type =
+        sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+    base::SysInfo::HardwareInfo hardware_info = base::SysInfo::HardwareInfo()) {
+  return std::make_unique<syncer::DeviceInfo>(
+      id, name, "chrome_version", "user_agent", device_type, "device_id",
+      hardware_info,
+      /*last_updated_timestamp=*/base::Time::Now(),
+      /*send_tab_to_self_receiving_enabled=*/false,
+      syncer::DeviceInfo::SharingInfo(
+          {"vapid_fcm_token", "vapid_p256dh", "vapid_auth_secret"},
+          {"sender_id_fcm_token", "sender_id_p256dh", "sender_id_auth_secret"},
+          std::set<sync_pb::SharingSpecificFields::EnabledFeatures>{
+              sync_pb::SharingSpecificFields::CLICK_TO_CALL}));
+}
+
+}  // namespace
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_AppleDevices_SigninOnly) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "MacbookPro1,1", sync_pb::SyncEnums_DeviceType_TYPE_MAC,
+      {"Apple Inc.", "MacbookPro1,1", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("MacbookPro1,1", names.full_name);
+  EXPECT_EQ("MacbookPro", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_AppleDevices_FullySynced) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Bobs-iMac", sync_pb::SyncEnums_DeviceType_TYPE_MAC,
+      {"Apple Inc.", "MacbookPro1,1", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Bobs-iMac", names.full_name);
+  EXPECT_EQ("Bobs-iMac", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_ChromeOSDevices_FeatureEnabled) {
+  scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Chromebook", sync_pb::SyncEnums_DeviceType_TYPE_CROS,
+      {"Google", "Chromebook", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Google Chromebook", names.full_name);
+  EXPECT_EQ("Google Chromebook", names.short_name);
+}
+
+TEST_F(SharingUtilsTest,
+       GetSharingDeviceNames_ChromeOSDevices_FeatureDisabled) {
+  scoped_feature_list_.InitAndDisableFeature(kSharingRenameDevices);
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Chromebook", sync_pb::SyncEnums_DeviceType_TYPE_CROS,
+      {"Google", "Chromebook", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Chromebook", names.full_name);
+  EXPECT_EQ("Chromebook", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidPhones_FeatureEnabled) {
+  scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Pixel 2", sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+      {"Google", "Pixel 2", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Google Phone Pixel 2", names.full_name);
+  EXPECT_EQ("Google Phone", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidPhones_FeatureDisabled) {
+  scoped_feature_list_.InitAndDisableFeature(kSharingRenameDevices);
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Pixel 2", sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
+      {"Google", "Pixel 2", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Pixel 2", names.full_name);
+  EXPECT_EQ("Pixel 2", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidTablets_FeatureEnabled) {
+  scoped_feature_list_.InitAndEnableFeature(kSharingRenameDevices);
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Pixel C", sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
+      {"Google", "Pixel C", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Google Tablet Pixel C", names.full_name);
+  EXPECT_EQ("Google Tablet", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_AndroidTablets_FeatureDisabled) {
+  scoped_feature_list_.InitAndDisableFeature(kSharingRenameDevices);
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "Pixel C", sync_pb::SyncEnums_DeviceType_TYPE_TABLET,
+      {"Google", "Pixel C", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Pixel C", names.full_name);
+  EXPECT_EQ("Pixel C", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_Windows_SigninOnly) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "BX123", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+      {"Dell", "BX123", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Dell Computer BX123", names.full_name);
+  EXPECT_EQ("Dell Computer", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_Windows_FullySynced) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "BOBS-WINDOWS-1", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+      {"Dell", "BX123", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("BOBS-WINDOWS-1", names.full_name);
+  EXPECT_EQ("BOBS-WINDOWS-1", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_Linux_SigninOnly) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "30BDS0RA0G", sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+      {"LENOVO", "30BDS0RA0G", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("LENOVO Computer 30BDS0RA0G", names.full_name);
+  EXPECT_EQ("LENOVO Computer", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, GetSharingDeviceNames_Linux_FullySynced) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "bob.chromium.org", sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
+      {"LENOVO", "30BDS0RA0G", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("bob.chromium.org", names.full_name);
+  EXPECT_EQ("bob.chromium.org", names.short_name);
+}
+
+TEST_F(SharingUtilsTest, CheckManufacturerNameCapitalization) {
+  std::unique_ptr<syncer::DeviceInfo> device = CreateFakeDeviceInfo(
+      "guid", "model", sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+      {"foo bar", "model", ""});
+  SharingDeviceNames names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Foo Bar Computer model", names.full_name);
+  EXPECT_EQ("Foo Bar Computer", names.short_name);
+
+  device = CreateFakeDeviceInfo("guid", "model",
+                                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+                                {"foo1bar", "model", ""});
+  names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Foo1Bar Computer model", names.full_name);
+  EXPECT_EQ("Foo1Bar Computer", names.short_name);
+
+  device = CreateFakeDeviceInfo("guid", "model",
+                                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+                                {"foo_bar-FOO", "model", ""});
+  names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Foo_Bar-FOO Computer model", names.full_name);
+  EXPECT_EQ("Foo_Bar-FOO Computer", names.short_name);
+
+  device = CreateFakeDeviceInfo("guid", "model",
+                                sync_pb::SyncEnums_DeviceType_TYPE_WIN,
+                                {"foo&bar foo", "model", ""});
+  names = GetSharingDeviceNames(device.get());
+
+  EXPECT_EQ("Foo&Bar Foo Computer model", names.full_name);
+  EXPECT_EQ("Foo&Bar Foo Computer", names.short_name);
+}
+
+}  // namespace send_tab_to_self
diff --git a/components/send_tab_to_self_strings.grdp b/components/send_tab_to_self_strings.grdp
new file mode 100644
index 0000000..82cfb7e
--- /dev/null
+++ b/components/send_tab_to_self_strings.grdp
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grit-part>
+  <!-- Different device types using in Sharing. -->
+  <message name="IDS_SHARING_DEVICE_TYPE_COMPUTER" desc = "The label for a device of type computer.">
+    Computer
+  </message>
+  <message name="IDS_SHARING_DEVICE_TYPE_DEVICE" desc = "The label for a generic device.">
+    Device
+  </message>
+  <message name="IDS_SHARING_DEVICE_TYPE_PHONE" desc = "The label for a device of type phone.">
+    Phone
+  </message>
+  <message name="IDS_SHARING_DEVICE_TYPE_TABLET" desc = "The label for a device of type tablet.">
+    Tablet
+  </message>
+</grit-part>
diff --git a/chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_COMPUTER.png.sha1 b/components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_COMPUTER.png.sha1
similarity index 100%
rename from chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_COMPUTER.png.sha1
rename to components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_COMPUTER.png.sha1
diff --git a/chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_DEVICE.png.sha1 b/components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_DEVICE.png.sha1
similarity index 100%
rename from chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_DEVICE.png.sha1
rename to components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_DEVICE.png.sha1
diff --git a/chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_PHONE.png.sha1 b/components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_PHONE.png.sha1
similarity index 100%
rename from chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_PHONE.png.sha1
rename to components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_PHONE.png.sha1
diff --git a/chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_TABLET.png.sha1 b/components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_TABLET.png.sha1
similarity index 100%
rename from chrome/app/generated_resources_grd/IDS_BROWSER_SHARING_DEVICE_TYPE_TABLET.png.sha1
rename to components/send_tab_to_self_strings_grdp/IDS_SHARING_DEVICE_TYPE_TABLET.png.sha1
diff --git a/components/send_tab_to_self_strings_grdp/OWNERS b/components/send_tab_to_self_strings_grdp/OWNERS
new file mode 100644
index 0000000..e58f618
--- /dev/null
+++ b/components/send_tab_to_self_strings_grdp/OWNERS
@@ -0,0 +1,3 @@
+file://components/send_tab_to_self/OWNERS
+
+# COMPONENT: UI>Browser>Sharing