OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "chromeos/printing/printer_configuration.h" | 10 #include "chromeos/printing/printer_configuration.h" |
11 #include "components/sync/protocol/printer_specifics.pb.h" | 11 #include "components/sync/protocol/printer_specifics.pb.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 namespace printing { | 14 namespace printing { |
15 | 15 |
| 16 // Convert |printer| into its local representation. Enforces that only one |
| 17 // field in PpdReference is filled in. In order of preference, we populate |
| 18 // autoconf, user_supplied_ppd_url, or effective_make_and_model. |
16 std::unique_ptr<Printer> SpecificsToPrinter( | 19 std::unique_ptr<Printer> SpecificsToPrinter( |
17 const sync_pb::PrinterSpecifics& printer); | 20 const sync_pb::PrinterSpecifics& printer); |
18 | 21 |
| 22 // Convert |printer| into its proto representation. |
19 std::unique_ptr<sync_pb::PrinterSpecifics> PrinterToSpecifics( | 23 std::unique_ptr<sync_pb::PrinterSpecifics> PrinterToSpecifics( |
20 const Printer& printer); | 24 const Printer& printer); |
21 | 25 |
22 // Merge fields from |printer| into |specifics|. | 26 // Merge fields from |printer| into |specifics|. Merge strategy is to only |
| 27 // write non-default fields from |printer| into the appropriate field in |
| 28 // |specifics|. Default fields are skipped to prevent accidentally clearing |
| 29 // |specifics|. Enforces field exclusivity in PpdReference as described in |
| 30 // SpecificsToPrinter. |
23 void MergePrinterToSpecifics(const Printer& printer, | 31 void MergePrinterToSpecifics(const Printer& printer, |
24 sync_pb::PrinterSpecifics* specifics); | 32 sync_pb::PrinterSpecifics* specifics); |
25 | 33 |
26 } // namespace printing | 34 } // namespace printing |
27 } // namespace chromeos | 35 } // namespace chromeos |
28 | 36 |
29 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ | 37 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ |
OLD | NEW |