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

Side by Side Diff: chrome/browser/chromeos/printing/printer_pref_manager.cc

Issue 2618313004: [CUPS] Implement the enterprise icon for printers in Print Preview Dialog. (Closed)
Patch Set: Add the missing image. Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/chromeos/printing/printer_pref_manager.h" 5 #include "chrome/browser/chromeos/printing/printer_pref_manager.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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 auto found = policy_printers.find(printer_id); 132 auto found = policy_printers.find(printer_id);
133 if (found != policy_printers.end()) 133 if (found != policy_printers.end())
134 return printing::RecommendedPrinterToPrinter(*(found->second)); 134 return printing::RecommendedPrinterToPrinter(*(found->second));
135 135
136 const base::ListValue* values = GetPrinterList(profile_); 136 const base::ListValue* values = GetPrinterList(profile_);
137 const base::DictionaryValue* printer = FindPrinterPref(values, printer_id); 137 const base::DictionaryValue* printer = FindPrinterPref(values, printer_id);
138 138
139 return printer ? printing::PrefToPrinter(*printer) : nullptr; 139 return printer ? printing::PrefToPrinter(*printer) : nullptr;
140 } 140 }
141 141
142 bool PrinterPrefManager::IsEnterprisePrinter(
143 const std::string& printer_id) const {
144 return std::find(recommended_printer_ids_.begin(),
skau 2017/01/10 19:55:52 Use base::ContainsValue(), it's more straightforwa
145 recommended_printer_ids_.end(),
146 printer_id) != recommended_printer_ids_.end();
147 }
148
142 void PrinterPrefManager::RegisterPrinter(std::unique_ptr<Printer> printer) { 149 void PrinterPrefManager::RegisterPrinter(std::unique_ptr<Printer> printer) {
143 if (printer->id().empty()) 150 if (printer->id().empty())
144 printer->set_id(base::GenerateGUID()); 151 printer->set_id(base::GenerateGUID());
145 152
146 DCHECK_EQ(Printer::SRC_USER_PREFS, printer->source()); 153 DCHECK_EQ(Printer::SRC_USER_PREFS, printer->source());
147 std::unique_ptr<base::DictionaryValue> updated_printer = 154 std::unique_ptr<base::DictionaryValue> updated_printer =
148 printing::PrinterToPref(*printer); 155 printing::PrinterToPref(*printer);
149 UpdatePrinterPref(profile_, printer->id(), std::move(updated_printer)); 156 UpdatePrinterPref(profile_, printer->id(), std::move(updated_printer));
150 } 157 }
151 158
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // generated for user entries. 197 // generated for user entries.
191 std::string id = base::MD5String(printer_json); 198 std::string id = base::MD5String(printer_json);
192 printer_dictionary->SetString(printing::kPrinterId, id); 199 printer_dictionary->SetString(printing::kPrinterId, id);
193 200
194 recommended_printer_ids_.push_back(id); 201 recommended_printer_ids_.push_back(id);
195 recommended_printers_[id] = std::move(printer_dictionary); 202 recommended_printers_[id] = std::move(printer_dictionary);
196 } 203 }
197 } 204 }
198 205
199 } // namespace chromeos 206 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698