Index: chromeos/printing/printer_translator.cc |
diff --git a/chromeos/printing/printer_translator.cc b/chromeos/printing/printer_translator.cc |
index 017d5e435404430c43d20c9c26d8d870aec0f8e9..1277e12f36d7e3f48de11390427c038039e01c34 100644 |
--- a/chromeos/printing/printer_translator.cc |
+++ b/chromeos/printing/printer_translator.cc |
@@ -34,22 +34,14 @@ const char kPpdResource[] = "ppd_resource"; |
// Converts |value| into a Printer object for the fields that are shared |
// between pref printers and policy printers. |
-std::unique_ptr<Printer> DictionaryToPrinter(const DictionaryValue& value) { |
- std::string id; |
- if (!value.GetString(printing::kPrinterId, &id)) { |
- LOG(WARNING) << "Record id required"; |
- return nullptr; |
- } |
- |
- std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(id); |
- |
+bool DictionaryToPrinter(const DictionaryValue& value, Printer* printer) { |
Carlson
2017/05/05 23:59:16
I don't really understand why you wanted to make t
skau
2017/05/08 18:38:02
I thought it was clearer to instantiate the printe
|
// Mandatory fields |
std::string display_name; |
if (value.GetString(kDisplayName, &display_name)) { |
printer->set_display_name(display_name); |
} else { |
LOG(WARNING) << "Display name required"; |
- return nullptr; |
+ return false; |
} |
std::string uri; |
@@ -57,7 +49,7 @@ std::unique_ptr<Printer> DictionaryToPrinter(const DictionaryValue& value) { |
printer->set_uri(uri); |
} else { |
LOG(WARNING) << "Uri required"; |
- return nullptr; |
+ return false; |
} |
// Optional fields |
@@ -87,9 +79,18 @@ namespace printing { |
const char kPrinterId[] = "id"; |
std::unique_ptr<Printer> RecommendedPrinterToPrinter( |
- const base::DictionaryValue& pref) { |
- std::unique_ptr<Printer> printer = DictionaryToPrinter(pref); |
- if (!printer) { |
+ const base::DictionaryValue& pref, |
+ int64_t timestamp) { |
+ DCHECK_GT(timestamp, 0); |
+ |
+ std::string id; |
+ if (!pref.GetString(printing::kPrinterId, &id)) { |
+ LOG(WARNING) << "Record id required"; |
+ return nullptr; |
+ } |
+ |
+ std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(id, timestamp); |
+ if (!DictionaryToPrinter(pref, printer.get())) { |
LOG(WARNING) << "Failed to parse policy printer."; |
return nullptr; |
} |