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

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

Issue 2408293002: Update PPDFile to PpdReference. Change the fields to a sufficient set to implement QuirksServer lo… (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | chromeos/printing/printer_configuration.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 struct PpdReference {
20 struct PPDFile { 20 // If non-empty, this is the url of a specific ppd the user has specified
Lei Zhang 2016/10/11 23:13:28 nit: Can we consistently refer to "PPD" as "PPD" ?
Carlson 2016/10/11 23:28:02 Done. (I think I got them all? There are a few i
Lei Zhang 2016/10/11 23:36:24 No worries if you didn't.
21 // Identifier from the quirks server. -1 otherwise. 21 // for use with this printer.
22 int id = -1; 22 std::string user_supplied_ppd_url;
23 23
24 std::string file_name; 24 // The *effective* manufacturer and model of this printer, in other words,
25 25 // 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 26 // doesn’t have to (but can) be the actual manufacturer/model of the
27 // should be used. The default value is 0. 27 // printer.  We should always try to fill these fields in, even if we don’t
28 int version_number = 0; 28 // think they’ll be needed, as they provide a fallback mechanism for
29 29 // finding a ppd.
30 // This will be true if the file was retrived from the quirks server. 30 std::string effective_manufacturer;
31 // Otherwise, the file was saved to disk by the user. 31 std::string effective_model;
32 bool from_quirks_server = false;
33 }; 32 };
34 33
35 // Constructs a printer object that is completely empty. 34 // Constructs a printer object that is completely empty.
36 Printer(); 35 Printer();
37 36
38 // Constructs a printer object with an id. 37 // Constructs a printer object with an id.
39 explicit Printer(const std::string& id); 38 explicit Printer(const std::string& id);
40 39
41 // Copy constructor and assignment. 40 // Copy constructor and assignment.
42 explicit Printer(const Printer& printer); 41 explicit Printer(const Printer& printer);
(...skipping 18 matching lines...) Expand all
61 void set_manufacturer(const std::string& manufacturer) { 60 void set_manufacturer(const std::string& manufacturer) {
62 manufacturer_ = manufacturer; 61 manufacturer_ = manufacturer;
63 } 62 }
64 63
65 const std::string& model() const { return model_; } 64 const std::string& model() const { return model_; }
66 void set_model(const std::string& model) { model_ = model; } 65 void set_model(const std::string& model) { model_ = model; }
67 66
68 const std::string& uri() const { return uri_; } 67 const std::string& uri() const { return uri_; }
69 void set_uri(const std::string& uri) { uri_ = uri; } 68 void set_uri(const std::string& uri) { uri_ = uri; }
70 69
71 const PPDFile& ppd() const { return ppd_; } 70 const PpdReference& ppd_reference() const { return ppd_reference_; }
Lei Zhang 2016/10/11 23:13:28 Some places do: const Foo* foo() const; Foo* foo()
Carlson 2016/10/11 23:28:02 I understand the appeal of that approach, but I pr
Lei Zhang 2016/10/11 23:36:24 Alrighty.
72 void SetPPD(std::unique_ptr<PPDFile> ppd); 71 PpdReference* mutable_ppd_reference() { return &ppd_reference_; }
72 void set_ppd_reference(const PpdReference& ppd_reference) {
Lei Zhang 2016/10/11 23:13:28 If you already have mutable_ppd_reference(), can't
Carlson 2016/10/11 23:28:02 Done.
73 ppd_reference_ = ppd_reference;
74 }
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
« no previous file with comments | « no previous file | chromeos/printing/printer_configuration.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698