skau | b793195 | 2016-07-27 18:04:51 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef PRINTING_PRINTING_CONTEXT_CHROMEOS_H_ |
| 6 | #define PRINTING_PRINTING_CONTEXT_CHROMEOS_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include "base/macros.h" |
| 13 | #include "printing/backend/cups_connection.h" |
| 14 | #include "printing/backend/cups_printer.h" |
| 15 | #include "printing/printing_context.h" |
| 16 | |
skau | b793195 | 2016-07-27 18:04:51 | [diff] [blame] | 17 | namespace printing { |
| 18 | |
| 19 | class PRINTING_EXPORT PrintingContextChromeos : public PrintingContext { |
| 20 | public: |
| 21 | explicit PrintingContextChromeos(Delegate* delegate); |
| 22 | ~PrintingContextChromeos() override; |
| 23 | |
| 24 | // PrintingContext implementation. |
| 25 | void AskUserForSettings(int max_pages, |
| 26 | bool has_selection, |
| 27 | bool is_scripted, |
| 28 | const PrintSettingsCallback& callback) override; |
| 29 | Result UseDefaultSettings() override; |
| 30 | gfx::Size GetPdfPaperSizeDeviceUnits() override; |
| 31 | Result UpdatePrinterSettings(bool external_preview, |
| 32 | bool show_system_dialog, |
| 33 | int page_count) override; |
skau | b793195 | 2016-07-27 18:04:51 | [diff] [blame] | 34 | Result NewDocument(const base::string16& document_name) override; |
| 35 | Result NewPage() override; |
| 36 | Result PageDone() override; |
| 37 | Result DocumentDone() override; |
| 38 | void Cancel() override; |
| 39 | void ReleaseContext() override; |
tfarina | 876d1e0 | 2016-10-11 23:12:53 | [diff] [blame] | 40 | skia::NativeDrawingContext context() const override; |
skau | b793195 | 2016-07-27 18:04:51 | [diff] [blame] | 41 | |
| 42 | Result StreamData(const std::vector<char>& buffer); |
| 43 | |
| 44 | private: |
| 45 | // Lazily initializes |printer_|. |
| 46 | Result InitializeDevice(const std::string& device); |
| 47 | |
| 48 | // id for ongoing print job. 0 if no job is active. |
| 49 | int job_id_; |
| 50 | |
| 51 | CupsConnection connection_; |
| 52 | std::unique_ptr<CupsPrinter> printer_; |
| 53 | |
| 54 | DISALLOW_COPY_AND_ASSIGN(PrintingContextChromeos); |
| 55 | }; |
| 56 | |
| 57 | } // namespace printing |
| 58 | |
| 59 | #endif // PRINTING_PRINTING_CONTEXT_CHROMEOS_H_ |