bool IsDeviceNameValid(const std::u16string& device_name) {
#if BUILDFLAG(IS_MAC)
  base::ScopedCFTypeRef<CFStringRef> new_printer_id(
      base::SysUTF16ToCFStringRef(device_name));
  PMPrinter new_printer = PMPrinterCreateFromPrinterID(new_printer_id.get());
  bool printer_exists = new_printer != nullptr;
  PMRelease(new_printer);
  return printer_exists;
#elif BUILDFLAG(IS_WIN)
  printing::ScopedPrinterHandle printer;
  return printer.OpenPrinterWithName(base::as_wcstr(device_name));
#else
  return true;
#endif
}
bool IsDeviceNameValid(const std::u16string& device_name) {
#if BUILDFLAG(IS_MAC)
  base::ScopedCFTypeRef<CFStringRef> new_printer_id(
      base::SysUTF16ToCFStringRef(device_name));
  PMPrinter new_printer = PMPrinterCreateFromPrinterID(new_printer_id.get());
  bool printer_exists = new_printer != nullptr;
  PMRelease(new_printer);
  return printer_exists;
#elif BUILDFLAG(IS_WIN)
  printing::ScopedPrinterHandle printer;
  return printer.OpenPrinterWithName(base::as_wcstr(device_name));
#else
  return true;
#endif
}