Chromium Code Reviews| Index: chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc |
| diff --git a/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc b/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9f42b5cfbb7c737a7958d7c6887b35796c1b8ebf |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc |
| @@ -0,0 +1,39 @@ |
| +// 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 <string> |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "printing/backend/print_backend.h" |
| + |
| +namespace printing { |
| + |
| +std::string GetDefaultPrinterOnBlockingPoolThread() { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + |
| + scoped_refptr<printing::PrintBackend> print_backend( |
| + printing::PrintBackend::CreateInstance(nullptr)); |
|
Lei Zhang
2016/10/28 21:55:51
nit: you can omit printing:: in namespace printing
skau
2016/11/02 22:00:03
Done.
|
| + |
| + std::string default_printer = print_backend->GetDefaultPrinterName(); |
| + VLOG(1) << "Default Printer: " << default_printer; |
| + return default_printer; |
| +} |
| + |
| +PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* /* profile */) { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + PrinterList printer_list; |
| + |
| + scoped_refptr<printing::PrintBackend> print_backend( |
| + printing::PrintBackend::CreateInstance(nullptr)); |
| + |
| + print_backend->EnumeratePrinters(&printer_list); |
| + |
| + return printer_list; |
| +} |
| + |
| +} // namespace printing |