| 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 #include <memory> |    5 #include <memory> | 
|    6 #include <string> |    6 #include <string> | 
|    7 #include <vector> |    7 #include <vector> | 
|    8  |    8  | 
|    9 #include "base/logging.h" |    9 #include "base/logging.h" | 
|   10 #include "base/memory/ptr_util.h" |   10 #include "base/memory/ptr_util.h" | 
|   11 #include "chrome/browser/chromeos/printing/specifics_translation.h" |   11 #include "chrome/browser/chromeos/printing/specifics_translation.h" | 
|   12 #include "chromeos/printing/printer_configuration.h" |   12 #include "chromeos/printing/printer_configuration.h" | 
|   13 #include "components/sync/protocol/printer_specifics.pb.h" |   13 #include "components/sync/protocol/printer_specifics.pb.h" | 
|   14  |   14  | 
|   15 namespace chromeos { |   15 namespace chromeos { | 
|   16 namespace printing { |   16 namespace printing { | 
|   17  |   17  | 
|   18 namespace { |   18 namespace { | 
|   19  |   19  | 
|   20 Printer::PpdReference SpecificsToPpd( |   20 Printer::PpdReference SpecificsToPpd( | 
|   21     const sync_pb::PrinterPPDReference& specifics) { |   21     const sync_pb::PrinterPPDReference& specifics) { | 
|   22   Printer::PpdReference ref; |   22   Printer::PpdReference ref; | 
|   23   if (specifics.has_user_supplied_ppd_url()) { |   23   if (specifics.has_user_supplied_ppd_url()) { | 
|   24     ref.user_supplied_ppd_url = specifics.user_supplied_ppd_url(); |   24     ref.user_supplied_ppd_url = specifics.user_supplied_ppd_url(); | 
|   25   } |   25   } | 
|   26  |   26  | 
|   27   if (specifics.has_effective_model()) { |   27   if (specifics.has_effective_make_and_model()) { | 
|   28     ref.effective_model = specifics.effective_model(); |   28     ref.effective_make_and_model = specifics.effective_make_and_model(); | 
|   29  |  | 
|   30     if (specifics.has_effective_manufacturer()) |  | 
|   31       ref.effective_manufacturer = specifics.effective_manufacturer(); |  | 
|   32   } |   29   } | 
|   33  |   30  | 
|   34   return ref; |   31   return ref; | 
|   35 } |   32 } | 
|   36  |   33  | 
|   37 sync_pb::PrinterPPDReference ReferenceToSpecifics( |   34 sync_pb::PrinterPPDReference ReferenceToSpecifics( | 
|   38     const Printer::PpdReference& ref) { |   35     const Printer::PpdReference& ref) { | 
|   39   sync_pb::PrinterPPDReference specifics; |   36   sync_pb::PrinterPPDReference specifics; | 
|   40   if (!ref.user_supplied_ppd_url.empty()) { |   37   if (!ref.user_supplied_ppd_url.empty()) { | 
|   41     specifics.set_user_supplied_ppd_url(ref.user_supplied_ppd_url); |   38     specifics.set_user_supplied_ppd_url(ref.user_supplied_ppd_url); | 
|   42   } |   39   } | 
|   43  |   40  | 
|   44   if (!ref.effective_model.empty()) { |   41   if (!ref.effective_make_and_model.empty()) { | 
|   45     specifics.set_effective_model(ref.effective_model); |   42     specifics.set_effective_make_and_model(ref.effective_make_and_model); | 
|   46  |  | 
|   47     if (!ref.effective_manufacturer.empty()) |  | 
|   48       specifics.set_effective_manufacturer(ref.effective_manufacturer); |  | 
|   49   } |   43   } | 
|   50  |   44  | 
|   51   return specifics; |   45   return specifics; | 
|   52 } |   46 } | 
|   53  |   47  | 
|   54 }  // namespace |   48 }  // namespace | 
|   55  |   49  | 
|   56 std::unique_ptr<Printer> SpecificsToPrinter( |   50 std::unique_ptr<Printer> SpecificsToPrinter( | 
|   57     const sync_pb::PrinterSpecifics& specifics) { |   51     const sync_pb::PrinterSpecifics& specifics) { | 
|   58   DCHECK(!specifics.id().empty()); |   52   DCHECK(!specifics.id().empty()); | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   96     specifics->set_uuid(printer.uuid()); |   90     specifics->set_uuid(printer.uuid()); | 
|   97  |   91  | 
|   98   *specifics->mutable_ppd_reference() = |   92   *specifics->mutable_ppd_reference() = | 
|   99       ReferenceToSpecifics(printer.ppd_reference()); |   93       ReferenceToSpecifics(printer.ppd_reference()); | 
|  100  |   94  | 
|  101   return specifics; |   95   return specifics; | 
|  102 } |   96 } | 
|  103  |   97  | 
|  104 }  // namespace printing |   98 }  // namespace printing | 
|  105 }  // namespace chromeos |   99 }  // namespace chromeos | 
| OLD | NEW |