| Index: chrome/browser/chromeos/printing/specifics_translation.cc
|
| diff --git a/chrome/browser/chromeos/printing/specifics_translation.cc b/chrome/browser/chromeos/printing/specifics_translation.cc
|
| index 4719092f42219221ea3a5c14088d49f8ac1bcb41..bbbb300d87f248f220f89d63052929a0d56a2263 100644
|
| --- a/chrome/browser/chromeos/printing/specifics_translation.cc
|
| +++ b/chrome/browser/chromeos/printing/specifics_translation.cc
|
| @@ -8,6 +8,8 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/strings/string_piece.h"
|
| +#include "base/strings/string_util.h"
|
| #include "base/time/time.h"
|
| #include "chrome/browser/chromeos/printing/specifics_translation.h"
|
| #include "chromeos/printing/printer_configuration.h"
|
| @@ -49,6 +51,14 @@ void MergeReferenceToSpecifics(sync_pb::PrinterPPDReference* specifics,
|
| }
|
| }
|
|
|
| +// Combines |make| and |model| with a space to generate a make and model string.
|
| +// If |model| already represents the make and model, the string is just |model|.
|
| +// This is to prevent strings of the form '<make> <make> <model>'.
|
| +std::string MakeAndModel(base::StringPiece make, base::StringPiece model) {
|
| + return model.starts_with(make) ? model.as_string()
|
| + : base::JoinString({make, model}, " ");
|
| +}
|
| +
|
| } // namespace
|
|
|
| std::unique_ptr<Printer> SpecificsToPrinter(
|
| @@ -61,6 +71,12 @@ std::unique_ptr<Printer> SpecificsToPrinter(
|
| printer->set_description(specifics.description());
|
| printer->set_manufacturer(specifics.manufacturer());
|
| printer->set_model(specifics.model());
|
| + if (!specifics.make_and_model().empty()) {
|
| + printer->set_make_and_model(specifics.make_and_model());
|
| + } else {
|
| + printer->set_make_and_model(
|
| + MakeAndModel(specifics.manufacturer(), specifics.model()));
|
| + }
|
| printer->set_uri(specifics.uri());
|
| printer->set_uuid(specifics.uuid());
|
|
|
| @@ -96,6 +112,9 @@ void MergePrinterToSpecifics(const Printer& printer,
|
| if (!printer.model().empty())
|
| specifics->set_model(printer.model());
|
|
|
| + if (!printer.make_and_model().empty())
|
| + specifics->set_make_and_model(printer.make_and_model());
|
| +
|
| if (!printer.uri().empty())
|
| specifics->set_uri(printer.uri());
|
|
|
|
|