#include "chrome/browser/ui/webui/print_preview/local_printer_handler_default.h"
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "chrome/common/printing/printer_capabilities.h"
#include "components/device_event_log/device_event_log.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "printing/buildflags/buildflags.h"
#include "printing/mojom/print.mojom.h"
#if BUILDFLAG(IS_MAC)
#include "chrome/common/printing/printer_capabilities_mac.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "base/threading/thread_restrictions.h"
#endif
#if BUILDFLAG(ENABLE_OOP_PRINTING)
#include "chrome/browser/printing/oop_features.h"
#include "chrome/browser/printing/print_backend_service_manager.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
#endif
namespace printing {
namespace {
scoped_refptr<base::TaskRunner> CreatePrinterHandlerTaskRunner() { … }
}
PrinterList LocalPrinterHandlerDefault::EnumeratePrintersOnBlockingTaskRunner(
const std::string& locale) { … }
base::Value::Dict
LocalPrinterHandlerDefault::FetchCapabilitiesOnBlockingTaskRunner(
const std::string& device_name,
const std::string& locale) { … }
std::string LocalPrinterHandlerDefault::GetDefaultPrinterOnBlockingTaskRunner(
const std::string& locale) { … }
LocalPrinterHandlerDefault::LocalPrinterHandlerDefault(
content::WebContents* preview_web_contents)
: … { … }
LocalPrinterHandlerDefault::~LocalPrinterHandlerDefault() = default;
void LocalPrinterHandlerDefault::Reset() { … }
void LocalPrinterHandlerDefault::GetDefaultPrinter(DefaultPrinterCallback cb) { … }
void LocalPrinterHandlerDefault::StartGetPrinters(
AddedPrintersCallback callback,
GetPrintersDoneCallback done_callback) { … }
void LocalPrinterHandlerDefault::StartGetCapability(
const std::string& device_name,
GetCapabilityCallback cb) { … }
void LocalPrinterHandlerDefault::StartPrint(
const std::u16string& job_title,
base::Value::Dict settings,
scoped_refptr<base::RefCountedMemory> print_data,
PrintCallback callback) { … }
#if BUILDFLAG(ENABLE_OOP_PRINTING)
void LocalPrinterHandlerDefault::
OnDidGetDefaultPrinterNameFromPrintBackendService(
base::TimeTicks query_start_time,
DefaultPrinterCallback callback,
mojom::DefaultPrinterNameResultPtr result) { … }
void LocalPrinterHandlerDefault::OnDidEnumeratePrintersFromPrintBackendService(
base::TimeTicks query_start_time,
AddedPrintersCallback added_printers_callback,
GetPrintersDoneCallback done_callback,
mojom::PrinterListResultPtr result) { … }
void LocalPrinterHandlerDefault::OnDidFetchCapabilitiesFromPrintBackendService(
const std::string& device_name,
bool elevated_privileges,
base::TimeTicks query_start_time,
GetCapabilityCallback callback,
mojom::PrinterCapsAndInfoResultPtr result) { … }
#endif
}