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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: printing/backend/cups_printer.h
diff --git a/printing/backend/cups_printer.h b/printing/backend/cups_printer.h
new file mode 100644
index 0000000000000000000000000000000000000000..bac1f9459f1e476247983df8fc498d5152a1c631
--- /dev/null
+++ b/printing/backend/cups_printer.h
@@ -0,0 +1,101 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PRINTING_BACKEND_CUPS_PRINTER_H_
+#define PRINTING_BACKEND_CUPS_PRINTER_H_
+
+#include <cups/cups.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/memory/weak_ptr.h"
+#include "printing/backend/cups_deleters.h"
+#include "printing/printing_export.h"
+#include "url/gurl.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace printing {
+
+struct PrinterBasicInfo;
+
+// Represents a CUPS printer.
+// Retrieves information from CUPS printer objects as requested.
+class PRINTING_EXPORT CupsPrinter {
+ public:
+ // This object now owns |dest| and |info|.
+ CupsPrinter(base::WeakPtr<http_t> http,
+ std::unique_ptr<cups_dest_t, DestinationDeleter> dest,
+ std::unique_ptr<cups_dinfo_t, DestInfoDeleter> info);
+
+ CupsPrinter(CupsPrinter&& printer);
+
+ ~CupsPrinter();
+
+ // Returns true if this is the default printer
+ bool is_default() const;
+
+ // Returns the supported ipp attributes for the given |option_name|.
+ // ipp_attribute_t* is owned by CupsPrinter.
+ ipp_attribute_t* GetSupportedOptionValues(
+ base::StringPiece option_name) const;
+
+ // Returns supported attribute values for |option_name| where the value can be
+ // convered to a string.
+ std::vector<base::StringPiece> GetSupportedOptionValueStrings(
+ base::StringPiece option_name) const;
+
+ // Returns the default ipp attributes for the given |option_name|.
+ // ipp_attribute_t* is owned by CupsPrinter.
+ ipp_attribute_t* GetDefaultOptionValue(base::StringPiece option_name) const;
+
+ bool CheckOptionSupported(base::StringPiece name,
+ base::StringPiece value) const;
+
+ // Returns the file name for the PPD retrieved from the print server.
+ base::FilePath GetPPD() const;
+
+ // Returns the name of the printer as configured in CUPS
+ const std::string GetName() const;
+
+ const std::string GetMakeAndModel() const;
+
+ // Returns true if the printer is currently reachable and working.
+ bool IsAvailable() const;
+
+ // Populates |basic_info| with the relevant information about the printer
+ bool ToPrinterInfo(PrinterBasicInfo* basic_info) const;
+
+ ipp_status_t CreateJob(int* job_id,
+ base::StringPiece job_title,
+ const std::vector<cups_option_t>& options);
+
+ bool StartDocument(int job_id,
+ base::StringPiece document_name,
+ bool last_doc,
+ const std::vector<cups_option_t>& options);
+
+ bool StreamData(const std::vector<char>& buffer);
+
+ bool FinishDocument();
+
+ ipp_status_t CloseJob(int job_id);
+
+ private:
+ bool InitializeDestInfo() const;
+
+ base::WeakPtr<http_t> cups_http_;
+ std::unique_ptr<cups_dest_t, DestinationDeleter> destination_;
+ mutable std::unique_ptr<cups_dinfo_t, DestInfoDeleter> dest_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(CupsPrinter);
+};
+
+} // namespace printing
+
+#endif // PRINTING_BACKEND_CUPS_PRINTER_H_

Powered by Google App Engine
This is Rietveld 408576698