| 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
|
| index 3a92bc0cf555891dbd7a91d8737280ba8155fcd5..effbb06c0d45e3532ef7a9dc6ff37666ed58006a 100644
|
| --- a/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
|
| +++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
|
| @@ -5,9 +5,12 @@
|
| #include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h"
|
|
|
| #include <string>
|
| +#include <utility>
|
|
|
| #include "base/logging.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "chrome/browser/ui/webui/print_preview/printer_capabilities.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "printing/backend/print_backend.h"
|
|
|
| @@ -27,6 +30,28 @@ PrinterList EnumeratePrintersOnBlockingPoolThread() {
|
| return printer_list;
|
| }
|
|
|
| +std::unique_ptr<base::DictionaryValue> FetchCapabilitiesOnBlockingPool(
|
| + const std::string& device_name) {
|
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| + scoped_refptr<printing::PrintBackend> print_backend(
|
| + printing::PrintBackend::CreateInstance(nullptr));
|
| +
|
| + VLOG(1) << "Get printer capabilities start for " << device_name;
|
| +
|
| + std::unique_ptr<base::DictionaryValue> printer_info;
|
| + if (!print_backend->IsValidPrinter(device_name)) {
|
| + LOG(WARNING) << "Invalid printer " << device_name;
|
| + return nullptr;
|
| + }
|
| +
|
| + PrinterBasicInfo basic_info;
|
| + if (!print_backend->GetPrinterBasicInfo(device_name, &basic_info)) {
|
| + return nullptr;
|
| + }
|
| +
|
| + return GetSettingsOnBlockingPool(device_name, basic_info);
|
| +}
|
| +
|
| } // namespace
|
|
|
| std::string GetDefaultPrinterOnBlockingPoolThread() {
|
| @@ -47,4 +72,14 @@ void EnumeratePrinters(Profile* /* profile */,
|
| base::Bind(&EnumeratePrintersOnBlockingPoolThread), cb);
|
| }
|
|
|
| +void ConfigurePrinterAndFetchCapabilities(Profile* /* profile */,
|
| + const std::string& device_name,
|
| + const PrinterSetupCallback& cb) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| + base::PostTaskAndReplyWithResult(
|
| + content::BrowserThread::GetBlockingPool(), FROM_HERE,
|
| + base::Bind(&FetchCapabilitiesOnBlockingPool, device_name), cb);
|
| +}
|
| +
|
| } // namespace printing
|
|
|