Commit 0ddf2c13 authored by Himanshu Jaju's avatar Himanshu Jaju Committed by Commit Bot

Add device model and manufacturer name to DeviceInfo.

This CL adds model and manufacturer name to DeviceInfoSpecifics. They
will be used in a follow-up CL for non PII device name.

TBR=tbarzic@chromium.org,ramyan@chromium.org,djacobo@chromium.org

Bug: 1009454
Change-Id: Ic2b0472a88aaf20b52acfc54f3aebdd26dab7b4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834093
Commit-Queue: Himanshu Jaju <himanshujaju@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarAlex Chau <alexchau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704657}
parent 33fe1e75
......@@ -84,7 +84,7 @@ mojom::IntentHandlerInfoPtr Create(const std::string& name,
// TODO(crbug.com/1011364): Extract this into a common mock file.
class MockSharingService : public SharingService {
public:
explicit MockSharingService()
MockSharingService()
: SharingService(
/*sync_prefs=*/nullptr,
/*vapid_key_manager=*/nullptr,
......@@ -1021,6 +1021,7 @@ TEST_F(ArcExternalProtocolDialogTestUtils, TestSelectDeviceForTelLink) {
devices.emplace_back(std::make_unique<syncer::DeviceInfo>(
device_guid, "device_name", "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt));
......
......@@ -33,13 +33,15 @@ TEST(IdMappingHelperTest, SetIdsForDevices) {
devices.push_back(std::make_unique<DeviceInfo>(
base::GenerateGUID(), "abc Device", "XYZ v1", "XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id1", base::Time(),
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id1",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt));
devices.push_back(std::make_unique<DeviceInfo>(
base::GenerateGUID(), "def Device", "XYZ v1", "XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id2", base::Time(),
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id2",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt));
......@@ -58,7 +60,8 @@ TEST(IdMappingHelperTest, SetIdsForDevices) {
// Now add a third device.
devices.push_back(std::make_unique<DeviceInfo>(
base::GenerateGUID(), "ghi Device", "XYZ v1", "XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id3", base::Time(),
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id3",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt));
......
......@@ -40,17 +40,19 @@ TEST(SignedInDevicesAPITest, GetSignedInDevices) {
scoped_refptr<Extension> extension_test =
extension_prefs.AddExtension(extension_name);
DeviceInfo device_info1(
base::GenerateGUID(), "abc Device", "XYZ v1", "XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id", base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info2(
base::GenerateGUID(), "def Device", "XYZ v2", "XYZ SyncAgent v2",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id", base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info1(base::GenerateGUID(), "abc Device", "XYZ v1",
"XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info2(base::GenerateGUID(), "def Device", "XYZ v2",
"XYZ SyncAgent v2",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
device_tracker.Add(&device_info1);
device_tracker.Add(&device_info2);
......@@ -67,11 +69,12 @@ TEST(SignedInDevicesAPITest, GetSignedInDevices) {
// Add a third device and make sure the first 2 ids are retained and a new
// id is generated for the third device.
DeviceInfo device_info3(
base::GenerateGUID(), "def Device", "jkl v2", "XYZ SyncAgent v2",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id", base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info3(base::GenerateGUID(), "def Device", "jkl v2",
"XYZ SyncAgent v2",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
device_tracker.Add(&device_info3);
......@@ -133,17 +136,19 @@ TEST_F(ExtensionSignedInDevicesTest, GetAll) {
DeviceInfoSyncServiceFactory::GetForProfile(profile())
->GetDeviceInfoTracker());
DeviceInfo device_info1(
base::GenerateGUID(), "abc Device", "XYZ v1", "XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id", base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info2(
base::GenerateGUID(), "def Device", "XYZ v2", "XYZ SyncAgent v2",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id", base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info1(base::GenerateGUID(), "abc Device", "XYZ v1",
"XYZ SyncAgent v1",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
DeviceInfo device_info2(base::GenerateGUID(), "def Device", "XYZ v2",
"XYZ SyncAgent v2",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
device_tracker->Add(&device_info1);
device_tracker->Add(&device_info2);
......
......@@ -49,7 +49,7 @@ constexpr int kSeparatorCommandId = -1;
class MockSharingDeviceRegistration : public SharingDeviceRegistration {
public:
explicit MockSharingDeviceRegistration()
MockSharingDeviceRegistration()
: SharingDeviceRegistration(/* pref_service_= */ nullptr,
/* sharing_sync_preference_= */ nullptr,
/* instance_id_driver_= */ nullptr,
......@@ -130,6 +130,7 @@ class ClickToCallContextMenuObserverTest : public testing::Test {
base::StrCat({"guid", base::NumberToString(i)}), "name",
"chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt));
......
......@@ -121,12 +121,13 @@ MATCHER_P(ProtoEquals, message, "") {
// Check the call to sharing service when a device is chosen.
TEST_F(ClickToCallUiControllerTest, OnDeviceChosen) {
syncer::DeviceInfo device_info(
kReceiverGuid, kReceiverName, "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo device_info(kReceiverGuid, kReceiverName, "chrome_version",
"user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
"device_id", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
chrome_browser_sharing::SharingMessage sharing_message;
sharing_message.mutable_click_to_call_message()->set_phone_number(
......
......@@ -45,7 +45,7 @@ constexpr int kSeparatorCommandId = -1;
class MockSharingDeviceRegistration : public SharingDeviceRegistration {
public:
explicit MockSharingDeviceRegistration()
MockSharingDeviceRegistration()
: SharingDeviceRegistration(/* pref_service_= */ nullptr,
/* sharing_sync_preference_= */ nullptr,
/* instance_id_driver_= */ nullptr,
......@@ -127,6 +127,7 @@ class SharedClipboardContextMenuObserverTest : public testing::Test {
base::StrCat({"guid", base::NumberToString(i)}), "name",
"chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt));
......
......@@ -34,7 +34,7 @@ const char kDeviceNameInMessage[] = "DeviceNameInMessage";
class MockSharingDeviceRegistration : public SharingDeviceRegistration {
public:
explicit MockSharingDeviceRegistration()
MockSharingDeviceRegistration()
: SharingDeviceRegistration(/* pref_service_= */ nullptr,
/* sharing_sync_preference_= */ nullptr,
/* instance_id_driver_= */ nullptr,
......@@ -160,6 +160,7 @@ TEST_F(SharedClipboardMessageHandlerTest,
/*chrome_version=*/"78.0.0.0",
/*sync_user_agent=*/"Chrome", sync_pb::SyncEnums::TYPE_LINUX,
/*signin_scoped_device_id=*/base::GenerateGUID(),
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
......
......@@ -93,12 +93,13 @@ class SharedClipboardUiControllerTest : public testing::Test {
return std::make_unique<testing::NiceMock<MockSharingService>>(
std::make_unique<SharingFCMHandler>(nullptr, nullptr, nullptr));
}));
syncer::DeviceInfo device_info(
kReceiverGuid, kReceiverName, "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo device_info(kReceiverGuid, kReceiverName,
"chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
"device_id", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
controller_ = SharedClipboardUiController::GetOrCreateFromWebContents(
web_contents_.get());
controller_->OnDeviceSelected(base::UTF8ToUTF16(kText), device_info);
......@@ -126,12 +127,13 @@ MATCHER_P(ProtoEquals, message, "") {
// Check the call to sharing service when a device is chosen.
TEST_F(SharedClipboardUiControllerTest, OnDeviceChosen) {
syncer::DeviceInfo device_info(
kReceiverGuid, kReceiverName, "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo device_info(kReceiverGuid, kReceiverName, "chrome_version",
"user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
"device_id", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
chrome_browser_sharing::SharingMessage sharing_message;
sharing_message.mutable_shared_clipboard_message()->set_text(kExpectedText);
......
......@@ -87,7 +87,7 @@ void SharingBrowserTest::SetUpDevices(
{"testing_device_", base::NumberToString(device_id++)}),
device->chrome_version(), device->sync_user_agent(),
device->device_type(), device->signin_scoped_device_id(),
device->last_updated_timestamp(),
device->hardware_info(), device->last_updated_timestamp(),
device->send_tab_to_self_receiving_enabled(),
device->sharing_info());
fake_device_info_tracker_.Add(fake_device.get());
......
......@@ -64,6 +64,7 @@ class SharingFCMHandlerTest : public testing::Test {
fake_device_info_ = std::make_unique<syncer::DeviceInfo>(
kSenderGuid, kSenderName, "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
syncer::DeviceInfo::SharingInfo(
......
......@@ -207,6 +207,7 @@ class SharingServiceTest : public testing::Test {
return std::make_unique<syncer::DeviceInfo>(
id, name, "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
syncer::DeviceInfo::SharingInfo(
......
......@@ -152,6 +152,7 @@ TEST_F(SharingSyncPreferenceTest, GetSharingInfoFromProvider) {
std::make_unique<syncer::DeviceInfo>(
kDeviceGuid, kDeviceName, "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
......
......@@ -72,6 +72,7 @@ class SharingDialogViewTest : public ChromeViewsTestBase {
base::StrCat({"device_guid_", base::NumberToString(i)}),
base::StrCat({"device", base::NumberToString(i)}), "chrome_version",
"user_agent", sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt));
......@@ -144,12 +145,13 @@ TEST_F(SharingDialogViewTest, PopulateDialogView) {
}
TEST_F(SharingDialogViewTest, DevicePressed) {
syncer::DeviceInfo device_info(
"device_guid_1", "device1", "chrome_version", "user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE, "device_id",
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo device_info("device_guid_1", "device1", "chrome_version",
"user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_PHONE,
"device_id", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
EXPECT_CALL(device_callback, Call(DeviceEquals(&device_info)));
auto dialog_data = CreateDialogData(/*devices=*/3, /*apps=*/2);
......
......@@ -96,6 +96,7 @@ class SendTabToSelfBridgeTest : public testing::Test {
local_device_ = std::make_unique<syncer::DeviceInfo>(
kLocalDeviceCacheGuid, "device", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
clock()->Now() - base::TimeDelta::FromDays(1),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -649,6 +650,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo recent_device(
kRecentGuid, "device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
clock()->Now() - base::TimeDelta::FromDays(1),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -657,6 +659,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo old_device(
kOldGuid, "device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now() - base::TimeDelta::FromDays(3),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -665,6 +668,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo older_device(
kOlderGuid, "device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now() - base::TimeDelta::FromDays(5),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -684,17 +688,19 @@ TEST_F(SendTabToSelfBridgeTest,
GetTargetDeviceInfoSortedList_OnlyReceivingEnabled) {
InitializeBridge();
syncer::DeviceInfo enabled_device(
"enabled_guid", "enabled_device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo enabled_device("enabled_guid", "enabled_device_name", "72",
"agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"scoped_is", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
AddTestDevice(&enabled_device);
syncer::DeviceInfo disabled_device(
"disabled_guid", "disabled_device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt);
......@@ -716,6 +722,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo expired_device(
"expired_guid", "expired_device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now() - base::TimeDelta::FromDays(11),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -724,6 +731,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo valid_device(
"valid_guid", "valid_device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now() - base::TimeDelta::FromDays(1),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -742,28 +750,31 @@ TEST_F(SendTabToSelfBridgeTest, GetTargetDeviceInfoSortedList_NoLocalDevice) {
InitializeBridge();
bridge()->SetLocalDeviceNameForTest(kLocalDeviceName);
syncer::DeviceInfo local_device(
kLocalDeviceCacheGuid, kLocalDeviceName, "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo local_device(kLocalDeviceCacheGuid, kLocalDeviceName, "72",
"agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"scoped_is", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
AddTestDevice(&local_device);
syncer::DeviceInfo other_local_device(
"other_local_guid", kLocalDeviceName, "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
AddTestDevice(&local_device);
syncer::DeviceInfo other_device(
"other_guid", "other_device_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo other_device("other_guid", "other_device_name", "72",
"agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"scoped_is", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
AddTestDevice(&other_device);
TargetDeviceInfo target_device_info(
......@@ -783,6 +794,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo older_device(
"older_guid", "older_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now() - base::TimeDelta::FromDays(9),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -791,6 +803,7 @@ TEST_F(SendTabToSelfBridgeTest,
syncer::DeviceInfo recent_device(
"recent_guid", "recent_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "scoped_is",
base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now() - base::TimeDelta::FromDays(1),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......@@ -821,11 +834,12 @@ TEST_F(SendTabToSelfBridgeTest,
InitializeBridge();
// Set a valid device.
syncer::DeviceInfo device(
"guid", "name", "72", "agent", sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"scoped_is", /*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
syncer::DeviceInfo device("guid", "name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"scoped_is", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
AddTestDevice(&device);
// Set the map by calling it. Make sure it has the device.
......@@ -839,7 +853,7 @@ TEST_F(SendTabToSelfBridgeTest,
// Add a new device.
syncer::DeviceInfo new_device("new_guid", "new_name", "72", "agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"scoped_is",
"scoped_is", base::SysInfo::HardwareInfo(),
/*last_updated_timestamp=*/clock()->Now(),
/*send_tab_to_self_receiving_enabled=*/true,
/*sharing_info=*/base::nullopt);
......
......@@ -59,6 +59,12 @@ message DeviceInfoSpecifics {
// Device specific information for Sharing feature.
optional SharingSpecificFields sharing_fields = 10;
// Model of device.
optional string model = 11;
// Name of device manufacturer.
optional string manufacturer = 12;
}
// Feature specific information about the device that is running a sync-enabled
......
......@@ -317,6 +317,8 @@ VISIT_PROTO_FIELDS(const sync_pb::DeviceInfoSpecifics& proto) {
VISIT(sync_user_agent);
VISIT(chrome_version);
VISIT(signin_scoped_device_id);
VISIT(model);
VISIT(manufacturer);
VISIT(last_updated_timestamp);
VISIT(feature_fields);
VISIT(sharing_fields);
......
......@@ -39,6 +39,7 @@ DeviceInfo::DeviceInfo(const std::string& guid,
const std::string& sync_user_agent,
const sync_pb::SyncEnums::DeviceType device_type,
const std::string& signin_scoped_device_id,
const base::SysInfo::HardwareInfo& hardware_info,
base::Time last_updated_timestamp,
bool send_tab_to_self_receiving_enabled,
const base::Optional<SharingInfo>& sharing_info)
......@@ -48,6 +49,7 @@ DeviceInfo::DeviceInfo(const std::string& guid,
sync_user_agent_(sync_user_agent),
device_type_(device_type),
signin_scoped_device_id_(signin_scoped_device_id),
hardware_info_(hardware_info),
last_updated_timestamp_(last_updated_timestamp),
send_tab_to_self_receiving_enabled_(send_tab_to_self_receiving_enabled),
sharing_info_(sharing_info) {}
......@@ -82,6 +84,10 @@ const std::string& DeviceInfo::signin_scoped_device_id() const {
return signin_scoped_device_id_;
}
const base::SysInfo::HardwareInfo& DeviceInfo::hardware_info() const {
return hardware_info_;
}
base::Time DeviceInfo::last_updated_timestamp() const {
return last_updated_timestamp_;
}
......
......@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "components/sync/protocol/sync.pb.h"
......@@ -56,6 +57,7 @@ class DeviceInfo {
const std::string& sync_user_agent,
const sync_pb::SyncEnums::DeviceType device_type,
const std::string& signin_scoped_device_id,
const base::SysInfo::HardwareInfo& hardware_info,
base::Time last_updated_timestamp,
bool send_tab_to_self_receiving_enabled,
const base::Optional<SharingInfo>& sharing_info);
......@@ -88,6 +90,8 @@ class DeviceInfo {
// annotating login scoped refresh token.
const std::string& signin_scoped_device_id() const;
const base::SysInfo::HardwareInfo& hardware_info() const;
// Returns the time at which this device was last updated to the sync servers.
base::Time last_updated_timestamp() const;
......@@ -139,6 +143,8 @@ class DeviceInfo {
// and they are also reset when app/extension is uninstalled.
std::string public_id_;
base::SysInfo::HardwareInfo hardware_info_;
const base::Time last_updated_timestamp_;
bool send_tab_to_self_receiving_enabled_;
......
......@@ -74,11 +74,15 @@ base::Optional<DeviceInfo::SharingInfo> SpecificsToSharingInfo(
// Converts DeviceInfoSpecifics into a freshly allocated DeviceInfo.
std::unique_ptr<DeviceInfo> SpecificsToModel(
const DeviceInfoSpecifics& specifics) {
base::SysInfo::HardwareInfo hardware_info;
hardware_info.model = specifics.model();
hardware_info.manufacturer = specifics.manufacturer();
return std::make_unique<DeviceInfo>(
specifics.cache_guid(), specifics.client_name(),
specifics.chrome_version(), specifics.sync_user_agent(),
specifics.device_type(), specifics.signin_scoped_device_id(),
ProtoTimeToTime(specifics.last_updated_timestamp()),
hardware_info, ProtoTimeToTime(specifics.last_updated_timestamp()),
specifics.feature_fields().send_tab_to_self_receiving_enabled(),
SpecificsToSharingInfo(specifics));
}
......@@ -95,6 +99,7 @@ std::unique_ptr<EntityData> CopyToEntityData(
// Converts a local DeviceInfo into a freshly allocated DeviceInfoSpecifics.
std::unique_ptr<DeviceInfoSpecifics> MakeLocalDeviceSpecifics(
const DeviceInfo& info) {
auto hardware_info = info.hardware_info();
auto specifics = std::make_unique<DeviceInfoSpecifics>();
specifics->set_cache_guid(info.guid());
specifics->set_client_name(info.client_name());
......@@ -102,6 +107,8 @@ std::unique_ptr<DeviceInfoSpecifics> MakeLocalDeviceSpecifics(
specifics->set_sync_user_agent(info.sync_user_agent());
specifics->set_device_type(info.device_type());
specifics->set_signin_scoped_device_id(info.signin_scoped_device_id());
specifics->set_model(hardware_info.model);
specifics->set_manufacturer(hardware_info.manufacturer);
// The local device should have not been updated yet. Set the last updated
// timestamp to now.
DCHECK(info.last_updated_timestamp() == base::Time());
......@@ -210,7 +217,8 @@ base::Optional<ModelError> DeviceInfoSyncBridge::MergeSyncData(
DCHECK(!local_cache_guid_.empty());
local_device_info_provider_->Initialize(local_cache_guid_,
local_personalizable_device_name_);
local_personalizable_device_name_,
local_hardware_info_);
std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch();
for (const auto& change : entity_data) {
......@@ -399,6 +407,15 @@ void DeviceInfoSyncBridge::OnStoreCreated(
store_ = std::move(store);
base::SysInfo::GetHardwareInfo(
base::BindOnce(&DeviceInfoSyncBridge::OnHardwareInfoRetrieved,
weak_ptr_factory_.GetWeakPtr()));
}
void DeviceInfoSyncBridge::OnHardwareInfoRetrieved(
base::SysInfo::HardwareInfo hardware_info) {
local_hardware_info_ = std::move(hardware_info);
auto all_data = std::make_unique<ClientIdToSpecifics>();
ClientIdToSpecifics* all_data_copy = all_data.get();
......@@ -428,6 +445,7 @@ void DeviceInfoSyncBridge::OnReadAllData(
}
all_data_ = std::move(*all_data);
local_personalizable_device_name_ =
std::move(*local_personalizable_device_name);
......@@ -481,7 +499,8 @@ void DeviceInfoSyncBridge::OnReadAllMetadata(
// initialize the provider immediately.
local_cache_guid_ = local_cache_guid_in_metadata;
local_device_info_provider_->Initialize(local_cache_guid_,
local_personalizable_device_name_);
local_personalizable_device_name_,
local_hardware_info_);
// This probably isn't strictly needed, but in case the cache_guid has changed
// we save the new one to prefs.
......
......@@ -14,6 +14,7 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/optional.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/sync/model/model_error.h"
......@@ -101,6 +102,7 @@ class DeviceInfoSyncBridge : public ModelTypeSyncBridge,
// Methods used as callbacks given to DataTypeStore.
void OnStoreCreated(const base::Optional<syncer::ModelError>& error,
std::unique_ptr<ModelTypeStore> store);
void OnHardwareInfoRetrieved(base::SysInfo::HardwareInfo hardware_info);
void OnReadAllData(std::unique_ptr<ClientIdToSpecifics> all_data,
std::unique_ptr<std::string> session_name,
const base::Optional<syncer::ModelError>& error);
......@@ -142,6 +144,7 @@ class DeviceInfoSyncBridge : public ModelTypeSyncBridge,
std::string local_cache_guid_;
std::string local_personalizable_device_name_;
ClientIdToSpecifics all_data_;
base::SysInfo::HardwareInfo local_hardware_info_;
// Registered observers, not owned.
base::ObserverList<Observer, true>::Unchecked observers_;
......
......@@ -80,6 +80,8 @@ MATCHER_P(ModelEqualsSpecifics, expected_specifics, "") {
}
}
base::SysInfo::HardwareInfo hardware_info = arg.hardware_info();
// Note that we ignore the device name here to avoid having to inject the
// local device's.
return expected_specifics.cache_guid() == arg.guid() &&
......@@ -88,6 +90,8 @@ MATCHER_P(ModelEqualsSpecifics, expected_specifics, "") {
expected_specifics.chrome_version() == arg.chrome_version() &&
expected_specifics.signin_scoped_device_id() ==
arg.signin_scoped_device_id() &&
expected_specifics.model() == hardware_info.model &&
expected_specifics.manufacturer() == hardware_info.manufacturer &&
expected_specifics.feature_fields()
.send_tab_to_self_receiving_enabled() ==
arg.send_tab_to_self_receiving_enabled();
......@@ -136,6 +140,21 @@ std::string SigninScopedDeviceIdForSuffix(int suffix) {
return base::StringPrintf("signin scoped device id %d", suffix);
}
std::string ModelForSuffix(int suffix) {
return base::StringPrintf("model %d", suffix);
}
std::string ManufacturerForSuffix(int suffix) {
return base::StringPrintf("manufacturer %d", suffix);
}
base::SysInfo::HardwareInfo HardwareInfoForSuffix(int suffix) {
base::SysInfo::HardwareInfo info;
info.manufacturer = ManufacturerForSuffix(suffix);
info.model = ModelForSuffix(suffix);
return info;
}
std::string SharingFcmTokenForSuffix(int suffix) {
return base::StringPrintf("sharing fcm token %d", suffix);
}
......@@ -170,6 +189,8 @@ DeviceInfoSpecifics CreateSpecifics(
specifics.set_sync_user_agent(SyncUserAgentForSuffix(suffix));
specifics.set_chrome_version(ChromeVersionForSuffix(suffix));
specifics.set_signin_scoped_device_id(SigninScopedDeviceIdForSuffix(suffix));
specifics.set_model(ModelForSuffix(suffix));
specifics.set_manufacturer(ManufacturerForSuffix(suffix));
specifics.set_last_updated_timestamp(TimeToProtoTime(last_updated));
specifics.mutable_feature_fields()->set_send_tab_to_self_receiving_enabled(
true);
......@@ -233,15 +254,20 @@ class TestLocalDeviceInfoProvider : public MutableLocalDeviceInfoProvider {
~TestLocalDeviceInfoProvider() override = default;
// MutableLocalDeviceInfoProvider implementation.
// TODO(himanshujaju) - |hardware_info| is ignored right now. We could reuse
// it by calling GetHardwareInfo and storing locally before starting the
// tests.
void Initialize(const std::string& cache_guid,
const std::string& session_name) override {
const std::string& session_name,
const base::SysInfo::HardwareInfo& hardware_info) override {
std::set<sync_pb::SharingSpecificFields::EnabledFeatures>
sharing_enabled_features{SharingEnabledFeaturesForSuffix(kLocalSuffix)};
local_device_info_ = std::make_unique<DeviceInfo>(
cache_guid, session_name, ChromeVersionForSuffix(kLocalSuffix),
SyncUserAgentForSuffix(kLocalSuffix),
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
SigninScopedDeviceIdForSuffix(kLocalSuffix), base::Time(),
SigninScopedDeviceIdForSuffix(kLocalSuffix),
HardwareInfoForSuffix(kLocalSuffix), base::Time(),
/*send_tab_to_self_receiving_enabled=*/true,
DeviceInfo::SharingInfo(SharingFcmTokenForSuffix(kLocalSuffix),
SharingP256dhForSuffix(kLocalSuffix),
......@@ -305,7 +331,7 @@ class DeviceInfoSyncBridgeTest : public testing::Test,
// cause all initialization callbacks between the sevice and store to fire.
void InitializeAndPump() {
InitializeBridge();
base::RunLoop().RunUntilIdle();
task_environment_.RunUntilIdle();
}
// Creates the bridge with no prior data on the store, and mimics sync being
......
......@@ -16,7 +16,7 @@ std::unique_ptr<syncer::DeviceInfo> CloneDeviceInfo(
device_info.guid(), device_info.client_name(),
device_info.chrome_version(), device_info.sync_user_agent(),
device_info.device_type(), device_info.signin_scoped_device_id(),
device_info.last_updated_timestamp(),
device_info.hardware_info(), device_info.last_updated_timestamp(),
device_info.send_tab_to_self_receiving_enabled(),
device_info.sharing_info());
}
......
......@@ -4,20 +4,23 @@
#include "components/sync_device_info/fake_local_device_info_provider.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
namespace syncer {
FakeLocalDeviceInfoProvider::FakeLocalDeviceInfoProvider()
: device_info_("id",
"name",
"chrome_version",
"user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"device_id",
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt) {}
: device_info_(
"id",
"name",
"chrome_version",
"user_agent",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"device_id",
base::SysInfo::HardwareInfo{"model", "manufacturer", "serial"},
/*last_updated_timestamp=*/base::Time::Now(),
/*send_tab_to_self_receiving_enabled=*/false,
/*sharing_info=*/base::nullopt) {}
FakeLocalDeviceInfoProvider::~FakeLocalDeviceInfoProvider() = default;
......
......@@ -9,6 +9,7 @@
#include <string>
#include "base/callback_list.h"
#include "base/system/sys_info.h"
#include "components/version_info/version_info.h"
namespace syncer {
......@@ -42,7 +43,8 @@ class LocalDeviceInfoProvider {
class MutableLocalDeviceInfoProvider : public LocalDeviceInfoProvider {
public:
virtual void Initialize(const std::string& cache_guid,
const std::string& session_name) = 0;
const std::string& session_name,
const base::SysInfo::HardwareInfo& hardware_info) = 0;
virtual void Clear() = 0;
};
......
......@@ -50,8 +50,10 @@ LocalDeviceInfoProviderImpl::RegisterOnInitializedCallback(
return callback_list_.Add(callback);
}
void LocalDeviceInfoProviderImpl::Initialize(const std::string& cache_guid,
const std::string& session_name) {
void LocalDeviceInfoProviderImpl::Initialize(
const std::string& cache_guid,
const std::string& session_name,
const base::SysInfo::HardwareInfo& hardware_info) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!cache_guid.empty());
......@@ -60,6 +62,7 @@ void LocalDeviceInfoProviderImpl::Initialize(const std::string& cache_guid,
local_device_info_ = std::make_unique<DeviceInfo>(
cache_guid, session_name, version_, MakeUserAgentForSync(channel_),
GetLocalDeviceType(), sync_client_->GetSigninScopedDeviceId(),
hardware_info,
/*last_updated_timestamp=*/base::Time(),
sync_client_->GetSendTabToSelfReceivingEnabled(),
sync_client_->GetLocalSharingInfo());
......
......@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/system/sys_info.h"
#include "components/sync_device_info/device_info.h"
#include "components/sync_device_info/local_device_info_provider.h"
#include "components/version_info/version_info.h"
......@@ -29,7 +30,8 @@ class LocalDeviceInfoProviderImpl : public MutableLocalDeviceInfoProvider {
// MutableLocalDeviceInfoProvider implementation.
void Initialize(const std::string& cache_guid,
const std::string& session_name) override;
const std::string& session_name,
const base::SysInfo::HardwareInfo& hardware_info) override;
void Clear() override;
version_info::Channel GetChannel() const override;
const DeviceInfo* GetLocalDeviceInfo() const override;
......
......@@ -58,7 +58,8 @@ class LocalDeviceInfoProviderImplTest : public testing::Test {
void InitializeProvider() { InitializeProvider(kLocalDeviceGuid); }
void InitializeProvider(const std::string& guid) {
provider_->Initialize(guid, kLocalDeviceSessionName);
provider_->Initialize(guid, kLocalDeviceSessionName,
base::SysInfo::HardwareInfo());
}
testing::NiceMock<MockDeviceInfoSyncClient> device_info_sync_client_;
......
......@@ -13,6 +13,8 @@ namespace syncer {
sync_pb::SyncEnums::DeviceType GetLocalDeviceType();
// Returns the personalizable device name. This may contain
// personally-identifiable information - e.g. Alex's MacbookPro.
std::string GetPersonalizableDeviceNameBlocking();
} // namespace syncer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment