Repository: electron/electron
File: shell/browser/serial/serial_chooser_controller.cc (C++)

Code before:
  if (!prevent_default) {
    RunCallback(/*port=*/nullptr);
  }
}

bool SerialChooserController::DisplayDevice(
    const device::mojom::SerialPortInfo& port) const {
  bool blocklist_disabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
      kDisableSerialBlocklist);
  if (!blocklist_disabled && SerialBlocklist::Get().IsExcluded(port)) {
    if (port.has_vendor_id && port.has_product_id) {
      AddMessageToConsole(
          blink::mojom::ConsoleMessageLevel::kInfo,
          base::StringPrintf(
              "Chooser dialog is not displaying a port blocked by "
              "the Serial blocklist: vendorId=%d, "
              "productId=%d, name='%s', serial='%s'",
              port.vendor_id, port.product_id,
              port.display_name ? port.display_name.value().c_str() : "",
              port.serial_number ? port.serial_number.value().c_str() : ""));
    } else if (port.bluetooth_service_class_id) {
      AddMessageToConsole(
          blink::mojom::ConsoleMessageLevel::kInfo,
          base::StringPrintf(
              "Chooser dialog is not displaying a port blocked by "
              "the Serial blocklist: bluetoothServiceClassId=%s, "
              "name='%s'",
              port.bluetooth_service_class_id->value().c_str(),
              port.display_name ? port.display_name.value().c_str() : ""));
    } else {
      NOTREACHED();
    }
    return false;
  }

  if (filters_.empty()) {
    return BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port);
  }

  for (const auto& filter : filters_) {
    if (FilterMatchesPort(*filter, port) &&
        BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port)) {
      return true;
    }
  }

  return false;
}

void SerialChooserController::AddMessageToConsole(
    blink::mojom::ConsoleMessageLevel level,

Review comment (suggestion):
```suggestion
              "Skipping a port blocked by "
              "the Serial blocklist: bluetoothServiceClassId=%s, "
```

Code after:
  if (!prevent_default) {
    RunCallback(/*port=*/nullptr);
  }
}

bool SerialChooserController::DisplayDevice(
    const device::mojom::SerialPortInfo& port) const {
  bool blocklist_disabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
      kDisableSerialBlocklist);
  if (!blocklist_disabled && SerialBlocklist::Get().IsExcluded(port)) {
    if (port.has_vendor_id && port.has_product_id) {
      AddMessageToConsole(
          blink::mojom::ConsoleMessageLevel::kInfo,
          base::StringPrintf(
              "Skipping a port blocked by "
              "the Serial blocklist: vendorId=%d, "
              "productId=%d, name='%s', serial='%s'",
              port.vendor_id, port.product_id,
              port.display_name ? port.display_name.value().c_str() : "",
              port.serial_number ? port.serial_number.value().c_str() : ""));
    } else if (port.bluetooth_service_class_id) {
      AddMessageToConsole(
          blink::mojom::ConsoleMessageLevel::kInfo,
          base::StringPrintf(
              "Skipping a port blocked by "
              "the Serial blocklist: bluetoothServiceClassId=%s, "
              "name='%s'",
              port.bluetooth_service_class_id->value().c_str(),
              port.display_name ? port.display_name.value().c_str() : ""));
    } else {
      NOTREACHED();
    }
    return false;
  }

  if (filters_.empty()) {
    return BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port);
  }

  for (const auto& filter : filters_) {
    if (FilterMatchesPort(*filter, port) &&
        BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port)) {
      return true;
    }
  }

  return false;
}

void SerialChooserController::AddMessageToConsole(
    blink::mojom::ConsoleMessageLevel level,