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

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.
Lei Zhang 2016/10/17 17:54:07 Why is this still here? Didn't these changes land
Carlson 2016/10/18 19:05:01 Done.
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.
22 int id = -1; 22 //
23 // At resolution time, we look for a cached PPD that used the same
24 // PpdReference before.
25 //
26 // If one is not found and user_supplied_ppd_url is set, we'll fail
27 // out with NOT FOUND
28 //
29 // Otherwise, we'll hit QuirksServer to see if we can resolve a Ppd
30 // using manufacturer/model
31 struct PpdReference {
32 // If non-empty, this is the url of a specific PPD the user has specified
33 // for use with this printer.
34 std::string user_supplied_ppd_url;
23 35
24 std::string file_name; 36 // The *effective* manufacturer and model of this printer, in other words,
25 37 // 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 38 // doesn’t have to (but can) be the actual manufacturer/model of the
27 // should be used. The default value is 0. 39 // printer.  We should always try to fill these fields in, even if we don’t
28 int version_number = 0; 40 // think they’ll be needed, as they provide a fallback mechanism for
29 41 // finding a PPD.
30 // This will be true if the file was retrived from the quirks server. 42 std::string effective_manufacturer;
31 // Otherwise, the file was saved to disk by the user. 43 std::string effective_model;
32 bool from_quirks_server = false;
33 }; 44 };
34 45
35 // Constructs a printer object that is completely empty. 46 // Constructs a printer object that is completely empty.
36 Printer(); 47 Printer();
37 48
38 // Constructs a printer object with an id. 49 // Constructs a printer object with an id.
39 explicit Printer(const std::string& id); 50 explicit Printer(const std::string& id);
40 51
41 // Copy constructor and assignment. 52 // Copy constructor and assignment.
42 explicit Printer(const Printer& printer); 53 explicit Printer(const Printer& printer);
(...skipping 18 matching lines...) Expand all
61 void set_manufacturer(const std::string& manufacturer) { 72 void set_manufacturer(const std::string& manufacturer) {
62 manufacturer_ = manufacturer; 73 manufacturer_ = manufacturer;
63 } 74 }
64 75
65 const std::string& model() const { return model_; } 76 const std::string& model() const { return model_; }
66 void set_model(const std::string& model) { model_ = model; } 77 void set_model(const std::string& model) { model_ = model; }
67 78
68 const std::string& uri() const { return uri_; } 79 const std::string& uri() const { return uri_; }
69 void set_uri(const std::string& uri) { uri_ = uri; } 80 void set_uri(const std::string& uri) { uri_ = uri; }
70 81
71 const PPDFile& ppd() const { return ppd_; } 82 const PpdReference& ppd_reference() const { return ppd_reference_; }
72 void SetPPD(std::unique_ptr<PPDFile> ppd); 83 PpdReference* mutable_ppd_reference() { return &ppd_reference_; }
73 84
74 const std::string& uuid() const { return uuid_; } 85 const std::string& uuid() const { return uuid_; }
75 void set_uuid(const std::string& uuid) { uuid_ = uuid; } 86 void set_uuid(const std::string& uuid) { uuid_ = uuid; }
76 87
77 private: 88 private:
78 // Globally unique identifier. Empty indicates a new printer. 89 // Globally unique identifier. Empty indicates a new printer.
79 std::string id_; 90 std::string id_;
80 91
81 // User defined string for printer identification. 92 // User defined string for printer identification.
82 std::string display_name_; 93 std::string display_name_;
83 94
84 // User defined string for additional printer information. 95 // User defined string for additional printer information.
85 std::string description_; 96 std::string description_;
86 97
87 // The manufacturer of the printer, e.g. HP 98 // The manufacturer of the printer, e.g. HP
88 std::string manufacturer_; 99 std::string manufacturer_;
89 100
90 // The model of the printer, e.g. OfficeJet 415 101 // The model of the printer, e.g. OfficeJet 415
91 std::string model_; 102 std::string model_;
92 103
93 // The full path for the printer. Suitable for configuration in CUPS. 104 // The full path for the printer. Suitable for configuration in CUPS.
94 // Contains protocol, hostname, port, and queue. 105 // Contains protocol, hostname, port, and queue.
95 std::string uri_; 106 std::string uri_;
96 107
97 // The associated postscript printer description. 108 // How to find the associated postscript printer description.
98 PPDFile ppd_; 109 PpdReference ppd_reference_;
99 110
100 // The UUID from an autoconf protocol for deduplication. Could be empty. 111 // The UUID from an autoconf protocol for deduplication. Could be empty.
101 std::string uuid_; 112 std::string uuid_;
102 }; 113 };
103 114
104 } // namespace chromeos 115 } // namespace chromeos
105 116
106 #endif // CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_ 117 #endif // CHROMEOS_PRINTING_PRINTER_CONFIGURATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698