Chromium Code Reviews| Index: chrome/browser/chromeos/printing/printer_pref_manager.cc |
| diff --git a/chrome/browser/chromeos/printing/printer_pref_manager.cc b/chrome/browser/chromeos/printing/printer_pref_manager.cc |
| index 1ea5226880c65f077845760f006c6ad8d16627ad..611c00df0b2598237b9e07b78325f033e2c7835a 100644 |
| --- a/chrome/browser/chromeos/printing/printer_pref_manager.cc |
| +++ b/chrome/browser/chromeos/printing/printer_pref_manager.cc |
| @@ -31,7 +31,7 @@ const base::ListValue* GetPrinterList(Profile* profile) { |
| // Returns the printer with the matching |id| from the list |values|. The |
| // returned value is mutable and |values| could be modified. |
| -base::DictionaryValue* FindPrinterPref(base::ListValue* values, |
| +base::DictionaryValue* FindPrinterPref(const base::ListValue* values, |
| const std::string& id) { |
| for (const auto& value : *values) { |
| base::DictionaryValue* printer_dictionary; |
| @@ -96,6 +96,17 @@ std::vector<std::unique_ptr<Printer>> PrinterPrefManager::GetPrinters() const { |
| return printers; |
| } |
| +std::unique_ptr<Printer> PrinterPrefManager::GetPrinter( |
| + const std::string& printer_id) const { |
| + const base::ListValue* values = GetPrinterList(profile_); |
| + if (!values) |
|
Lei Zhang
2016/11/02 23:09:22
So either line 83 needs this check, or this isn't
skau
2016/11/03 22:38:08
It's not needed.
|
| + return nullptr; |
| + |
| + const base::DictionaryValue* printer = FindPrinterPref(values, printer_id); |
| + |
| + return printer ? printing::PrefToPrinter(*printer) : nullptr; |
| +} |
| + |
| void PrinterPrefManager::RegisterPrinter(std::unique_ptr<Printer> printer) { |
| if (printer->id().empty()) |
| printer->set_id(base::GenerateGUID()); |