// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SYNC_DEVICE_INFO_LOCAL_DEVICE_INFO_UTIL_H_
#define COMPONENTS_SYNC_DEVICE_INFO_LOCAL_DEVICE_INFO_UTIL_H_

#include <string>

#include "base/functional/callback_forward.h"
#include "components/sync_device_info/device_info.h"

namespace syncer {

// Contains device specific names to be used by DeviceInfo. These are specific
// to the local device only. DeviceInfoSyncBridge uses either |model_name| or
// |personalizable_name| for the |client_name| depending on the current
// SyncMode. Only fully synced clients will use the personalizable name.
struct LocalDeviceNameInfo {
  LocalDeviceNameInfo();
  LocalDeviceNameInfo(const LocalDeviceNameInfo& other);
  ~LocalDeviceNameInfo();

  // Manufacturer name retrieved from SysInfo::GetHardwareInfo() - e.g. LENOVO.
  std::string manufacturer_name;
  // Model name retrieved from SysInfo::GetHardwareInfo() on non CrOS platforms.
  // On CrOS this will be set to GetChromeOSDeviceNameFromType() instead.
  std::string model_name;
  // Personalizable device name from GetPersonalizableDeviceNameBlocking(). See
  // documentation below for more information.
  std::string personalizable_name;
  // Unique hardware class string which details the
  // HW combination of a CrOS device. Empty on non-CrOS devices.
  std::string full_hardware_class;
  // The android.os.Build.FINGERPRINT. Populated on Android.
  std::optional<std::string> android_build_fingerprint;
};

DeviceInfo::DeviceType GetLocalDeviceType();

DeviceInfo::OsType GetLocalDeviceOSType();

DeviceInfo::FormFactor GetLocalDeviceFormFactor();

// Returns the personalizable device name. This may contain
// personally-identifiable information - e.g. Alex's MacbookPro.
// Note that this may not actually be a personalized name on all platforms
// (e.g. Android and iOS may return the model name or a generic string due to
// privacy or permission restrictions).
std::string GetPersonalizableDeviceNameBlocking();

void GetLocalDeviceNameInfo(
    base::OnceCallback<void(LocalDeviceNameInfo)> callback);

}  // namespace syncer

#endif  // COMPONENTS_SYNC_DEVICE_INFO_LOCAL_DEVICE_INFO_UTIL_H_
