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

Unified Diff: chrome/browser/chromeos/printing/specifics_translation.cc

Issue 2956173002: Introduce the field make_and_model for synced printers. (Closed)
Patch Set: done Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/printing/specifics_translation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « no previous file | chrome/browser/chromeos/printing/specifics_translation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698