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 "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 printer_copy, | 239 printer_copy, |
240 base::Bind(&CupsPrintersHandler::OnAddedPrinter, | 240 base::Bind(&CupsPrintersHandler::OnAddedPrinter, |
241 weak_factory_.GetWeakPtr(), base::Passed(&printer))); | 241 weak_factory_.GetWeakPtr(), base::Passed(&printer))); |
242 } | 242 } |
243 | 243 |
244 void CupsPrintersHandler::OnAddedPrinter( | 244 void CupsPrintersHandler::OnAddedPrinter( |
245 std::unique_ptr<Printer> printer, | 245 std::unique_ptr<Printer> printer, |
246 chromeos::PrinterSetupResult result_code) { | 246 chromeos::PrinterSetupResult result_code) { |
247 std::string printer_name = printer->display_name(); | 247 std::string printer_name = printer->display_name(); |
248 switch (result_code) { | 248 switch (result_code) { |
249 case chromeos::PrinterSetupResult::SUCCESS: | 249 case chromeos::PrinterSetupResult::SUCCESS: { |
250 PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter( | 250 auto* manager = PrintersManagerFactory::GetForBrowserContext(profile_); |
251 std::move(printer)); | 251 manager->PrinterInstalled(*printer); |
| 252 manager->RegisterPrinter(std::move(printer)); |
252 break; | 253 break; |
| 254 } |
253 case chromeos::PrinterSetupResult::PPD_NOT_FOUND: | 255 case chromeos::PrinterSetupResult::PPD_NOT_FOUND: |
254 LOG(WARNING) << "Could not locate requested PPD"; | 256 LOG(WARNING) << "Could not locate requested PPD"; |
255 break; | 257 break; |
256 case chromeos::PrinterSetupResult::PPD_TOO_LARGE: | 258 case chromeos::PrinterSetupResult::PPD_TOO_LARGE: |
257 LOG(WARNING) << "PPD is too large"; | 259 LOG(WARNING) << "PPD is too large"; |
258 break; | 260 break; |
259 case chromeos::PrinterSetupResult::PPD_UNRETRIEVABLE: | 261 case chromeos::PrinterSetupResult::PPD_UNRETRIEVABLE: |
260 LOG(WARNING) << "Could not retrieve PPD from server"; | 262 LOG(WARNING) << "Could not retrieve PPD from server"; |
261 break; | 263 break; |
262 case chromeos::PrinterSetupResult::INVALID_PPD: | 264 case chromeos::PrinterSetupResult::INVALID_PPD: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 base::Value("on-printer-discovered"), *printers_list); | 403 base::Value("on-printer-discovered"), *printers_list); |
402 } | 404 } |
403 | 405 |
404 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { | 406 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { |
405 CallJavascriptFunction("cr.webUIListenerCallback", | 407 CallJavascriptFunction("cr.webUIListenerCallback", |
406 base::Value("on-printer-discovery-done")); | 408 base::Value("on-printer-discovery-done")); |
407 } | 409 } |
408 | 410 |
409 } // namespace settings | 411 } // namespace settings |
410 } // namespace chromeos | 412 } // namespace chromeos |
OLD | NEW |