Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: printing/backend/cups_printer.h

Issue 2105463002: Create a new print backend for the updated CUPS APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_BACKEND_CUPS_PRINTER_H_
6 #define PRINTING_BACKEND_CUPS_PRINTER_H_
7
8 #include <cups/cups.h>
9
10 #include <memory>
11 #include <string>
12 #include <vector>
13
14 #include "base/memory/weak_ptr.h"
15 #include "printing/backend/cups_deleters.h"
16 #include "printing/printing_export.h"
17 #include "url/gurl.h"
18
19 namespace base {
20 class FilePath;
21 }
22
23 namespace printing {
24
25 struct PrinterBasicInfo;
26
27 // Represents a CUPS printer.
28 // Retrieves information from CUPS printer objects as requested.
29 class PRINTING_EXPORT CupsPrinter {
30 public:
31 // This object now owns |dest| and |info|.
32 CupsPrinter(base::WeakPtr<http_t> http,
33 std::unique_ptr<cups_dest_t, DestinationDeleter> dest,
34 std::unique_ptr<cups_dinfo_t, DestInfoDeleter> info);
35
36 CupsPrinter(CupsPrinter&& printer);
37
38 ~CupsPrinter();
39
40 // Returns true if this is the default printer
41 bool is_default() const;
42
43 // Returns the supported ipp attributes for the given |option_name|.
44 // ipp_attribute_t* is owned by CupsPrinter.
45 ipp_attribute_t* GetSupportedOptionValues(
46 base::StringPiece option_name) const;
47
48 // Returns supported attribute values for |option_name| where the value can be
49 // convered to a string.
50 std::vector<base::StringPiece> GetSupportedOptionValueStrings(
51 base::StringPiece option_name) const;
52
53 // Returns the default ipp attributes for the given |option_name|.
54 // ipp_attribute_t* is owned by CupsPrinter.
55 ipp_attribute_t* GetDefaultOptionValue(base::StringPiece option_name) const;
56
57 bool CheckOptionSupported(base::StringPiece name,
58 base::StringPiece value) const;
59
60 // Returns the file name for the PPD retrieved from the print server.
61 base::FilePath GetPPD() const;
62
63 // Returns the name of the printer as configured in CUPS
64 const std::string GetName() const;
65
66 const std::string GetMakeAndModel() const;
67
68 // Returns true if the printer is currently reachable and working.
69 bool IsAvailable() const;
70
71 // Populates |basic_info| with the relevant information about the printer
72 bool ToPrinterInfo(PrinterBasicInfo* basic_info) const;
73
74 ipp_status_t CreateJob(int* job_id,
75 base::StringPiece job_title,
76 const std::vector<cups_option_t>& options);
77
78 bool StartDocument(int job_id,
79 base::StringPiece document_name,
80 bool last_doc,
81 const std::vector<cups_option_t>& options);
82
83 bool StreamData(const std::vector<char>& buffer);
84
85 bool FinishDocument();
86
87 ipp_status_t CloseJob(int job_id);
88
89 private:
90 bool InitializeDestInfo() const;
91
92 base::WeakPtr<http_t> cups_http_;
93 std::unique_ptr<cups_dest_t, DestinationDeleter> destination_;
94 mutable std::unique_ptr<cups_dinfo_t, DestInfoDeleter> dest_info_;
95
96 DISALLOW_COPY_AND_ASSIGN(CupsPrinter);
97 };
98
99 } // namespace printing
100
101 #endif // PRINTING_BACKEND_CUPS_PRINTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698