#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "printing/backend/print_backend_cups.h"
#include <cups/cups.h>
#include <cups/ppd.h>
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <string>
#include <string_view>
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/lock.h"
#include "build/build_config.h"
#include "printing/backend/cups_helper.h"
#include "printing/backend/cups_weak_functions.h"
#include "printing/backend/print_backend_consts.h"
#include "printing/backend/print_backend_utils.h"
#include "printing/mojom/print.mojom.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)
#include "base/feature_list.h"
#include "printing/backend/cups_connection.h"
#include "printing/backend/print_backend_cups_ipp.h"
#include "printing/printing_features.h"
#endif
namespace printing {
namespace {
struct CupsDestsData { … };
int CaptureCupsDestCallback(void* data, unsigned flags, cups_dest_t* dest) { … }
}
PrintBackendCUPS::PrintBackendCUPS(const GURL& print_server_url,
http_encryption_t encryption,
bool blocking,
const std::string& locale)
: … { … }
PrintBackendCUPS::~PrintBackendCUPS() = default;
mojom::ResultCode PrintBackendCUPS::PrinterBasicInfoFromCUPS(
const cups_dest_t& printer,
PrinterBasicInfo* printer_info) { … }
std::string PrintBackendCUPS::PrinterDriverInfoFromCUPS(
const cups_dest_t& printer) { … }
mojom::ResultCode PrintBackendCUPS::EnumeratePrinters(
PrinterList& printer_list) { … }
mojom::ResultCode PrintBackendCUPS::GetDefaultPrinterName(
std::string& default_printer) { … }
mojom::ResultCode PrintBackendCUPS::GetPrinterBasicInfo(
const std::string& printer_name,
PrinterBasicInfo* printer_info) { … }
mojom::ResultCode PrintBackendCUPS::GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
PrinterSemanticCapsAndDefaults* printer_info) { … }
std::string PrintBackendCUPS::GetPrinterCapabilities(
const std::string& printer_name) { … }
std::vector<std::string> PrintBackendCUPS::GetPrinterDriverInfo(
const std::string& printer_name) { … }
bool PrintBackendCUPS::IsValidPrinter(const std::string& printer_name) { … }
#if !BUILDFLAG(IS_CHROMEOS)
scoped_refptr<PrintBackend> PrintBackend::CreateInstanceImpl(
const std::string& locale) { … }
#endif
int PrintBackendCUPS::GetDests(cups_dest_t** dests) { … }
base::FilePath PrintBackendCUPS::GetPPD(const char* name) { … }
ScopedDestination PrintBackendCUPS::GetNamedDest(
const std::string& printer_name) { … }
}