 Chromium Code Reviews
 Chromium Code Reviews Issue 2542363002:
  Interrogate PpdProvider from PrintPreview.  (Closed)
    
  
    Issue 2542363002:
  Interrogate PpdProvider from PrintPreview.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h" | 5 #include "chrome/browser/ui/webui/print_preview/printer_backend_proxy.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 } | 45 } | 
| 46 | 46 | 
| 47 PrinterBasicInfo basic_info; | 47 PrinterBasicInfo basic_info; | 
| 48 if (!print_backend->GetPrinterBasicInfo(device_name, &basic_info)) { | 48 if (!print_backend->GetPrinterBasicInfo(device_name, &basic_info)) { | 
| 49 return nullptr; | 49 return nullptr; | 
| 50 } | 50 } | 
| 51 | 51 | 
| 52 return GetSettingsOnBlockingPool(device_name, basic_info); | 52 return GetSettingsOnBlockingPool(device_name, basic_info); | 
| 53 } | 53 } | 
| 54 | 54 | 
| 55 class PrinterBackendProxyImpl : public PrinterBackendProxy { | |
| 
Carlson
2016/12/02 19:10:22
Maybe a better suffix here would be Chrome instead
 
skau
2016/12/05 23:13:34
Renamed to 'Default'.  Chrome seems odd since Chro
 | |
| 56 public: | |
| 57 std::string GetDefaultPrinterOnBlockingPoolThread() override { | |
| 58 DCHECK( | |
| 59 content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | |
| 60 | |
| 61 scoped_refptr<printing::PrintBackend> print_backend( | |
| 62 PrintBackend::CreateInstance(nullptr)); | |
| 63 | |
| 64 std::string default_printer = print_backend->GetDefaultPrinterName(); | |
| 65 VLOG(1) << "Default Printer: " << default_printer; | |
| 66 return default_printer; | |
| 67 } | |
| 68 | |
| 69 void EnumeratePrinters(const EnumeratePrintersCallback& cb) override { | |
| 70 base::PostTaskAndReplyWithResult( | |
| 71 content::BrowserThread::GetBlockingPool(), FROM_HERE, | |
| 72 base::Bind(&EnumeratePrintersOnBlockingPoolThread), cb); | |
| 73 } | |
| 74 | |
| 75 void ConfigurePrinterAndFetchCapabilities( | |
| 76 const std::string& device_name, | |
| 77 const PrinterSetupCallback& cb) override { | |
| 78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 79 | |
| 80 base::PostTaskAndReplyWithResult( | |
| 81 content::BrowserThread::GetBlockingPool(), FROM_HERE, | |
| 82 base::Bind(&FetchCapabilitiesOnBlockingPool, device_name), cb); | |
| 83 } | |
| 84 }; | |
| 85 | |
| 55 } // namespace | 86 } // namespace | 
| 56 | 87 | 
| 57 std::string GetDefaultPrinterOnBlockingPoolThread() { | 88 std::unique_ptr<PrinterBackendProxy> PrinterBackendProxy::Create() { | 
| 58 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 89 return base::MakeUnique<PrinterBackendProxyImpl>(); | 
| 59 | |
| 60 scoped_refptr<printing::PrintBackend> print_backend( | |
| 61 PrintBackend::CreateInstance(nullptr)); | |
| 62 | |
| 63 std::string default_printer = print_backend->GetDefaultPrinterName(); | |
| 64 VLOG(1) << "Default Printer: " << default_printer; | |
| 65 return default_printer; | |
| 66 } | |
| 67 | |
| 68 void EnumeratePrinters(Profile* /* profile */, | |
| 69 const EnumeratePrintersCallback& cb) { | |
| 70 base::PostTaskAndReplyWithResult( | |
| 71 content::BrowserThread::GetBlockingPool(), FROM_HERE, | |
| 72 base::Bind(&EnumeratePrintersOnBlockingPoolThread), cb); | |
| 73 } | |
| 74 | |
| 75 void ConfigurePrinterAndFetchCapabilities(Profile* /* profile */, | |
| 76 const std::string& device_name, | |
| 77 const PrinterSetupCallback& cb) { | |
| 78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 79 | |
| 80 base::PostTaskAndReplyWithResult( | |
| 81 content::BrowserThread::GetBlockingPool(), FROM_HERE, | |
| 82 base::Bind(&FetchCapabilitiesOnBlockingPool, device_name), cb); | |
| 83 } | 90 } | 
| 84 | 91 | 
| 85 } // namespace printing | 92 } // namespace printing | 
| OLD | NEW |