1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PRINTING_CONTEXT_CHROMEOS_H_
6 #define PRINTING_PRINTING_CONTEXT_CHROMEOS_H_
12 #include "printing/backend/cups_connection.h"
13 #include "printing/backend/cups_ipp_helper.h"
14 #include "printing/backend/cups_printer.h"
15 #include "printing/mojom/print.mojom.h"
16 #include "printing/printing_context.h"
20 class COMPONENT_EXPORT(PRINTING) PrintingContextChromeos
21 : public PrintingContext {
23 static std::unique_ptr<PrintingContextChromeos> CreateForTesting(
25 std::unique_ptr<CupsConnection> connection);
27 explicit PrintingContextChromeos(Delegate* delegate);
28 PrintingContextChromeos(const PrintingContextChromeos&) = delete;
29 PrintingContextChromeos& operator=(const PrintingContextChromeos&) = delete;
30 ~PrintingContextChromeos() override;
32 // PrintingContext implementation.
33 void AskUserForSettings(int max_pages,
36 PrintSettingsCallback callback) override;
37 mojom::ResultCode UseDefaultSettings() override;
38 gfx::Size GetPdfPaperSizeDeviceUnits() override;
39 mojom::ResultCode UpdatePrinterSettings(
40 const PrinterSettings& printer_settings) override;
41 mojom::ResultCode NewDocument(const std::u16string& document_name) override;
42 mojom::ResultCode PrintDocument(const MetafilePlayer& metafile,
43 const PrintSettings& settings,
44 uint32_t num_pages) override;
45 mojom::ResultCode DocumentDone() override;
46 void Cancel() override;
47 void ReleaseContext() override;
48 printing::NativeDrawingContext context() const override;
50 mojom::ResultCode StreamData(const std::vector<char>& buffer);
53 // For testing. Use CreateForTesting() to create.
54 PrintingContextChromeos(Delegate* delegate,
55 std::unique_ptr<CupsConnection> connection);
57 // Lazily initializes `printer_`.
58 mojom::ResultCode InitializeDevice(const std::string& device);
60 const std::unique_ptr<CupsConnection> connection_;
61 std::unique_ptr<CupsPrinter> printer_;
62 ScopedIppPtr ipp_options_;
63 bool send_user_info_ = false;
64 std::string username_;
67 COMPONENT_EXPORT(PRINTING)
68 ScopedIppPtr SettingsToIPPOptions(const PrintSettings& settings,
69 const gfx::Rect& printable_area_um);
71 } // namespace printing
73 #endif // PRINTING_PRINTING_CONTEXT_CHROMEOS_H_