| 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 130fc486527f5a37b8724f6592f61e4f9d9a3eb1..d2e7580e5679d32f2823d6ef829bc58c76988663 100644
|
| --- a/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
|
| +++ b/chrome/browser/ui/webui/print_preview/printer_backend_proxy.cc
|
| @@ -5,14 +5,28 @@
|
| #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"
|
|
|
| namespace printing {
|
|
|
| +namespace {
|
| +
|
| +void PostCallbackOnUIThread(const PrinterSetupCallback& cb,
|
| + std::unique_ptr<base::DictionaryValue> result) {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::UI, FROM_HERE,
|
| + base::Bind(cb, base::Passed(std::move(result))));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| std::string GetDefaultPrinterOnBlockingPoolThread() {
|
| DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
|
|
| @@ -36,4 +50,30 @@ PrinterList EnumeratePrintersOnBlockingPoolThread(Profile* /* profile */) {
|
| return printer_list;
|
| }
|
|
|
| +void ConfigurePrinterAndFetchCapabilities(Profile* /* profile */,
|
| + const std::string& device_name,
|
| + const PrinterSetupCallback& cb) {
|
| + 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;
|
| + PostCallbackOnUIThread(cb, nullptr);
|
| + return;
|
| + }
|
| +
|
| + PrinterBasicInfo basic_info;
|
| + if (!print_backend->GetPrinterBasicInfo(device_name, &basic_info)) {
|
| + PostCallbackOnUIThread(cb, nullptr);
|
| + return;
|
| + }
|
| +
|
| + PostCallbackOnUIThread(cb, GetSettingsDictionary(device_name, basic_info));
|
| +}
|
| +
|
| } // namespace printing
|
|
|