Chromium Code Reviews| Index: chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc |
| diff --git a/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc b/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0fd483030dc8bafd48c86d9d12e01d4e7d505ad2 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy_chromeos.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h" |
| + |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/command_line.h" |
| +#include "base/values.h" |
| +#include "chrome/browser/chromeos/printing/printer_pref_manager.h" |
| +#include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chromeos/printing/printer_configuration.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "printing/backend/print_backend.h" |
| +#include "printing/backend/print_backend_consts.h" |
| + |
| +namespace printing { |
| + |
| +namespace { |
| + |
| +// 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.
|
| +// as the system_driverinfo option value, and the Printer#display_name in |
| +// the description field. This will match how OS X presents printer |
| +// information. |
| +printing::PrinterBasicInfo ToBasicInfo(const chromeos::Printer& printer) { |
| + PrinterBasicInfo basic_info; |
| + |
| + // TODO(skau): Unify Mac with the other platforms for display name |
| + // presentation so I can remove this strange code. |
| + basic_info.options[kDriverInfoTagName] = printer.description(); |
| + basic_info.printer_name = printer.id(); |
| + basic_info.printer_description = printer.display_name(); |
| + return basic_info; |
| +} |
| + |
| +} // namespace |
| + |
| +std::string GetDefaultPrinterOnBlockingPoolThread() { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + // TODO(crbug.com/660898): Add default printers to ChromeOS. |
| + return ""; |
| +} |
| + |
| +PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* profile) { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + |
| + PrinterList printer_list; |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableNativeCups)) { |
| + chromeos::PrinterPrefManager* prefs = |
| + chromeos::PrinterPrefManagerFactory::GetForBrowserContext(profile); |
| + std::vector<std::unique_ptr<chromeos::Printer>> printers = |
| + prefs->GetPrinters(); |
| + for (const std::unique_ptr<chromeos::Printer>& printer : printers) { |
| + printer_list.push_back(ToBasicInfo(*printer)); |
| + } |
| + } |
| + |
| + return printer_list; |
| +} |
| + |
| +} // namespace printing |