#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/gtk/printing/print_dialog_gtk.h"
#include <algorithm>
#include <cmath>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/dcheck_is_on.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/sequence_checker.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "printing/buildflags/buildflags.h"
#include "printing/metafile.h"
#include "printing/mojom/print.mojom.h"
#include "printing/print_job_constants.h"
#include "printing/print_settings.h"
#include "printing/printing_features.h"
#include "ui/aura/window.h"
#include "ui/gtk/gtk_compat.h"
#include "ui/gtk/gtk_ui.h"
#include "ui/gtk/gtk_ui_platform.h"
#include "ui/gtk/gtk_util.h"
#include "ui/gtk/printing/printing_gtk_util.h"
PageRanges;
PrintSettings;
namespace {
#if BUILDFLAG(USE_CUPS)
const char kCUPSDuplex[] = …;
const char kDuplexNone[] = …;
const char kDuplexTumble[] = …;
const char kDuplexNoTumble[] = …;
#endif
constexpr int kPaperSizeTresholdMicrons = …;
constexpr int kMicronsInMm = …;
bool PaperSizeMatch(GtkPaperSize* gtk_paper_size,
const PrintSettings::RequestedMedia& media,
bool fuzzy_match) { … }
GtkPaperSize* FindPaperSizeMatch(GList* gtk_paper_sizes,
const PrintSettings::RequestedMedia& media) { … }
class StickyPrintSettingGtk { … };
StickyPrintSettingGtk& GetLastUsedSettings() { … }
class GtkPrinterList { … };
#if BUILDFLAG(ENABLE_OOP_PRINTING_NO_OOP_BASIC_PRINT_DIALOG)
ScopedGKeyFile GetGKeyFileFromDict(const base::Value::Dict& data,
std::string_view key) { … }
#endif
}
printing::PrintDialogLinuxInterface* PrintDialogGtk::CreatePrintDialog(
PrintingContextLinux* context) { … }
PrintDialogGtk::PrintDialogGtk(PrintingContextLinux* context)
: … { … }
PrintDialogGtk::~PrintDialogGtk() { … }
void PrintDialogGtk::UseDefaultSettings() { … }
void PrintDialogGtk::UpdateSettings(
std::unique_ptr<printing::PrintSettings> settings) { … }
#if BUILDFLAG(ENABLE_OOP_PRINTING_NO_OOP_BASIC_PRINT_DIALOG)
void PrintDialogGtk::LoadPrintSettings(const PrintSettings& settings) { … }
#endif
void PrintDialogGtk::ShowDialog(
gfx::NativeView parent_view,
bool has_selection,
PrintingContextLinux::PrintSettingsCallback callback) { … }
void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile,
const std::u16string& document_name) { … }
void PrintDialogGtk::ReleaseDialog() { … }
void PrintDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { … }
static void OnJobCompletedThunk(GtkPrintJob* print_job,
gpointer user_data,
const GError* error) { … }
void PrintDialogGtk::SendDocumentToPrinter(
const std::u16string& document_name) { … }
void PrintDialogGtk::OnJobCompleted(GtkPrintJob* print_job,
const GError* error) { … }
void PrintDialogGtk::InitPrintSettings(
std::unique_ptr<PrintSettings> settings) { … }
void PrintDialogGtk::OnWindowDestroying(aura::Window* window) { … }