| 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 <string> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "printing/backend/print_backend.h" |
| 13 |
| 14 namespace printing { |
| 15 |
| 16 namespace { |
| 17 |
| 18 PrinterList EnumeratePrintersOnBlockingPoolThread() { |
| 19 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 20 |
| 21 scoped_refptr<PrintBackend> print_backend( |
| 22 PrintBackend::CreateInstance(nullptr)); |
| 23 |
| 24 PrinterList printer_list; |
| 25 print_backend->EnumeratePrinters(&printer_list); |
| 26 |
| 27 return printer_list; |
| 28 } |
| 29 |
| 30 } // namespace |
| 31 |
| 32 std::string GetDefaultPrinterOnBlockingPoolThread() { |
| 33 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 34 |
| 35 scoped_refptr<printing::PrintBackend> print_backend( |
| 36 PrintBackend::CreateInstance(nullptr)); |
| 37 |
| 38 std::string default_printer = print_backend->GetDefaultPrinterName(); |
| 39 VLOG(1) << "Default Printer: " << default_printer; |
| 40 return default_printer; |
| 41 } |
| 42 |
| 43 void EnumeratePrinters(Profile* /* profile */, |
| 44 const EnumeratePrintersCallback& cb) { |
| 45 base::PostTaskAndReplyWithResult( |
| 46 content::BrowserThread::GetBlockingPool(), FROM_HERE, |
| 47 base::Bind(&EnumeratePrintersOnBlockingPoolThread), cb); |
| 48 } |
| 49 |
| 50 } // namespace printing |
| OLD | NEW |