Chromium Code Reviews| 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 #include "printing/backend/print_backend_consts.h" | |
| 20 | |
| 21 namespace printing { | |
| 22 | |
| 23 namespace { | |
| 24 | |
| 25 // Store the name used in CUPS, Printer#id in printer_name, the description | |
|
Lei Zhang
2016/11/03 22:12:29
|printer_name|
skau
2016/11/03 22:30:08
Done.
| |
| 26 // as the system_driverinfo option value, and the Printer#display_name in | |
| 27 // the description field. This will match how OS X presents printer | |
| 28 // information. | |
| 29 printing::PrinterBasicInfo ToBasicInfo(const chromeos::Printer& printer) { | |
| 30 PrinterBasicInfo basic_info; | |
| 31 | |
| 32 // TODO(skau): Unify Mac with the other platforms for display name | |
| 33 // presentation so I can remove this strange code. | |
| 34 basic_info.options[kDriverInfoTagName] = printer.description(); | |
| 35 basic_info.printer_name = printer.id(); | |
| 36 basic_info.printer_description = printer.display_name(); | |
| 37 return basic_info; | |
| 38 } | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 42 std::string GetDefaultPrinterOnBlockingPoolThread() { | |
| 43 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | |
| 44 // TODO(crbug.com/660898): Add default printers to ChromeOS. | |
| 45 return ""; | |
| 46 } | |
| 47 | |
| 48 PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* profile) { | |
| 49 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | |
| 50 | |
| 51 PrinterList printer_list; | |
| 52 | |
| 53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 54 switches::kEnableNativeCups)) { | |
| 55 chromeos::PrinterPrefManager* prefs = | |
| 56 chromeos::PrinterPrefManagerFactory::GetForBrowserContext(profile); | |
| 57 std::vector<std::unique_ptr<chromeos::Printer>> printers = | |
| 58 prefs->GetPrinters(); | |
| 59 for (const std::unique_ptr<chromeos::Printer>& printer : printers) { | |
| 60 printer_list.push_back(ToBasicInfo(*printer)); | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 return printer_list; | |
| 65 } | |
| 66 | |
| 67 } // namespace printing | |
| OLD | NEW |