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

Side by Side Diff: chromeos/printing/printer_configuration.h

Issue 2343983004: Add PPDProvider barebones implementation and associated cache skeleton. (Closed)
Patch Set: Initial PPDProvider/PPDCache implementation. Also, add associated unittests. This doesn't plumb th… Created 4 years, 2 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_ 5 #ifndef CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_
6 #define CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_ 6 #define CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chromeos/chromeos_export.h" 12 #include "chromeos/chromeos_export.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 class CHROMEOS_EXPORT Printer { 16 class CHROMEOS_EXPORT Printer {
17 public: 17 public:
18 // Represents a Postscript Printer Description with which the printer was 18 // Information needed to find the PPD file for this printer.
19 // setup. 19 //
20 struct PPDFile { 20 // If you add fields to this struct, you almost certainly will
21 // Identifier from the quirks server. -1 otherwise. 21 // want to update PpdResolver and PpdCache::GetCachePath.
skau 2016/10/14 22:10:17 We should include the resolution hierarchy in this
Carlson 2016/10/14 23:05:56 Done.
22 int id = -1; 22 struct PpdReference {
23 // If non-empty, this is the url of a specific PPD the user has specified
24 // for use with this printer.
25 std::string user_supplied_ppd_url;
23 26
24 std::string file_name; 27 // The *effective* manufacturer and model of this printer, in other words,
25 28 // the manufacturer and model of the printer for which we grab a PPD.  This
26 // If there is a file with a later version on the quirks server, that file 29 // doesn’t have to (but can) be the actual manufacturer/model of the
27 // should be used. The default value is 0. 30 // printer.  We should always try to fill these fields in, even if we don’t
28 int version_number = 0; 31 // think they’ll be needed, as they provide a fallback mechanism for
29 32 // finding a PPD.
30 // This will be true if the file was retrived from the quirks server. 33 std::string effective_manufacturer;
31 // Otherwise, the file was saved to disk by the user. 34 std::string effective_model;
32 bool from_quirks_server = false;
33 }; 35 };
34 36
35 // Constructs a printer object that is completely empty. 37 // Constructs a printer object that is completely empty.
36 Printer(); 38 Printer();
37 39
38 // Constructs a printer object with an id. 40 // Constructs a printer object with an id.
39 explicit Printer(const std::string& id); 41 explicit Printer(const std::string& id);
40 42
41 // Copy constructor and assignment. 43 // Copy constructor and assignment.
42 explicit Printer(const Printer& printer); 44 explicit Printer(const Printer& printer);
(...skipping 18 matching lines...) Expand all
61 void set_manufacturer(const std::string& manufacturer) { 63 void set_manufacturer(const std::string& manufacturer) {
62 manufacturer_ = manufacturer; 64 manufacturer_ = manufacturer;
63 } 65 }
64 66
65 const std::string& model() const { return model_; } 67 const std::string& model() const { return model_; }
66 void set_model(const std::string& model) { model_ = model; } 68 void set_model(const std::string& model) { model_ = model; }
67 69
68 const std::string& uri() const { return uri_; } 70 const std::string& uri() const { return uri_; }
69 void set_uri(const std::string& uri) { uri_ = uri; } 71 void set_uri(const std::string& uri) { uri_ = uri; }
70 72
71 const PPDFile& ppd() const { return ppd_; } 73 const PpdReference& ppd_reference() const { return ppd_reference_; }
72 void SetPPD(std::unique_ptr<PPDFile> ppd); 74 PpdReference* mutable_ppd_reference() { return &ppd_reference_; }
73 75
74 const std::string& uuid() const { return uuid_; } 76 const std::string& uuid() const { return uuid_; }
75 void set_uuid(const std::string& uuid) { uuid_ = uuid; } 77 void set_uuid(const std::string& uuid) { uuid_ = uuid; }
76 78
77 private: 79 private:
78 // Globally unique identifier. Empty indicates a new printer. 80 // Globally unique identifier. Empty indicates a new printer.
79 std::string id_; 81 std::string id_;
80 82
81 // User defined string for printer identification. 83 // User defined string for printer identification.
82 std::string display_name_; 84 std::string display_name_;
83 85
84 // User defined string for additional printer information. 86 // User defined string for additional printer information.
85 std::string description_; 87 std::string description_;
86 88
87 // The manufacturer of the printer, e.g. HP 89 // The manufacturer of the printer, e.g. HP
88 std::string manufacturer_; 90 std::string manufacturer_;
89 91
90 // The model of the printer, e.g. OfficeJet 415 92 // The model of the printer, e.g. OfficeJet 415
91 std::string model_; 93 std::string model_;
92 94
93 // The full path for the printer. Suitable for configuration in CUPS. 95 // The full path for the printer. Suitable for configuration in CUPS.
94 // Contains protocol, hostname, port, and queue. 96 // Contains protocol, hostname, port, and queue.
95 std::string uri_; 97 std::string uri_;
96 98
97 // The associated postscript printer description. 99 // How to find the associated postscript printer description.
98 PPDFile ppd_; 100 PpdReference ppd_reference_;
99 101
100 // The UUID from an autoconf protocol for deduplication. Could be empty. 102 // The UUID from an autoconf protocol for deduplication. Could be empty.
101 std::string uuid_; 103 std::string uuid_;
102 }; 104 };
103 105
104 } // namespace chromeos 106 } // namespace chromeos
105 107
106 #endif // CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_ 108 #endif // CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698