| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h" |
| 6 |
| 7 #include <memory> |
| 8 #include <vector> |
| 9 |
| 10 #include "base/command_line.h" |
| 11 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/printing/printer_pref_manager.h" |
| 13 #include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chromeos/printing/printer_configuration.h" |
| 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "printing/backend/print_backend.h" |
| 19 |
| 20 namespace printing { |
| 21 |
| 22 namespace { |
| 23 |
| 24 printing::PrinterBasicInfo ToBasicInfo(const chromeos::Printer& printer) { |
| 25 PrinterBasicInfo basic_info; |
| 26 basic_info.printer_display_name = printer.display_name(); |
| 27 basic_info.printer_name = printer.id(); |
| 28 basic_info.printer_description = printer.description(); |
| 29 return basic_info; |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
| 34 std::string GetDefaultPrinterOnBlockingPoolThread() { |
| 35 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 36 // TODO(crbug.com/660898): Add default printers to ChromeOS. |
| 37 return ""; |
| 38 } |
| 39 |
| 40 PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* profile) { |
| 41 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 42 |
| 43 PrinterList printer_list; |
| 44 |
| 45 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 46 switches::kEnableNativeCups)) { |
| 47 chromeos::PrinterPrefManager* prefs = |
| 48 chromeos::PrinterPrefManagerFactory::GetForBrowserContext(profile); |
| 49 std::vector<std::unique_ptr<chromeos::Printer>> printers = |
| 50 prefs->GetPrinters(); |
| 51 for (const std::unique_ptr<chromeos::Printer>& printer : printers) { |
| 52 printer_list.push_back(ToBasicInfo(*printer)); |
| 53 } |
| 54 } |
| 55 |
| 56 return printer_list; |
| 57 } |
| 58 |
| 59 } // namespace printing |
| OLD | NEW |