OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromeos/printing/printer_translator.h" | 5 #include "chromeos/printing/printer_translator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 std::string uuid; | 74 std::string uuid; |
75 if (value.GetString(kUUID, &uuid)) | 75 if (value.GetString(kUUID, &uuid)) |
76 printer->set_uuid(uuid); | 76 printer->set_uuid(uuid); |
77 | 77 |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 } // namespace | 81 } // namespace |
82 | 82 |
83 namespace printing { | |
84 | |
85 const char kPrinterId[] = "id"; | 83 const char kPrinterId[] = "id"; |
86 | 84 |
87 std::unique_ptr<Printer> RecommendedPrinterToPrinter( | 85 std::unique_ptr<Printer> RecommendedPrinterToPrinter( |
88 const base::DictionaryValue& pref, | 86 const base::DictionaryValue& pref, |
89 const base::Time& timestamp) { | 87 const base::Time& timestamp) { |
90 DCHECK(!timestamp.is_null()); | 88 DCHECK(!timestamp.is_null()); |
91 | 89 |
92 std::string id; | 90 std::string id; |
93 if (!pref.GetString(printing::kPrinterId, &id)) { | 91 if (!pref.GetString(kPrinterId, &id)) { |
94 LOG(WARNING) << "Record id required"; | 92 LOG(WARNING) << "Record id required"; |
95 return nullptr; | 93 return nullptr; |
96 } | 94 } |
97 | 95 |
98 std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(id, timestamp); | 96 std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(id, timestamp); |
99 if (!DictionaryToPrinter(pref, printer.get())) { | 97 if (!DictionaryToPrinter(pref, printer.get())) { |
100 LOG(WARNING) << "Failed to parse policy printer."; | 98 LOG(WARNING) << "Failed to parse policy printer."; |
101 return nullptr; | 99 return nullptr; |
102 } | 100 } |
103 | 101 |
104 printer->set_source(Printer::SRC_POLICY); | 102 printer->set_source(Printer::SRC_POLICY); |
105 | 103 |
106 const DictionaryValue* ppd; | 104 const DictionaryValue* ppd; |
107 std::string make_and_model; | 105 std::string make_and_model; |
108 if (pref.GetDictionary(kPpdResource, &ppd) && | 106 if (pref.GetDictionary(kPpdResource, &ppd) && |
109 ppd->GetString(kEffectiveModel, &make_and_model)) { | 107 ppd->GetString(kEffectiveModel, &make_and_model)) { |
110 printer->mutable_ppd_reference()->effective_make_and_model = make_and_model; | 108 printer->mutable_ppd_reference()->effective_make_and_model = make_and_model; |
111 } else { | 109 } else { |
112 // Make and model is mandatory | 110 // Make and model is mandatory |
113 LOG(WARNING) << "Missing model information for policy printer."; | 111 LOG(WARNING) << "Missing model information for policy printer."; |
114 return nullptr; | 112 return nullptr; |
115 } | 113 } |
116 | 114 |
117 return printer; | 115 return printer; |
118 } | 116 } |
119 | 117 |
120 } // namespace printing | |
121 } // namespace chromeos | 118 } // namespace chromeos |
OLD | NEW |