| 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 }  // namespace |  | 
| 56 |  | 
| 57 std::string GetDefaultPrinterOnBlockingPoolThread() { | 55 std::string GetDefaultPrinterOnBlockingPoolThread() { | 
| 58   DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 56   DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 
| 59 | 57 | 
| 60   scoped_refptr<printing::PrintBackend> print_backend( | 58   scoped_refptr<printing::PrintBackend> print_backend( | 
| 61       PrintBackend::CreateInstance(nullptr)); | 59       PrintBackend::CreateInstance(nullptr)); | 
| 62 | 60 | 
| 63   std::string default_printer = print_backend->GetDefaultPrinterName(); | 61   std::string default_printer = print_backend->GetDefaultPrinterName(); | 
| 64   VLOG(1) << "Default Printer: " << default_printer; | 62   VLOG(1) << "Default Printer: " << default_printer; | 
| 65   return default_printer; | 63   return default_printer; | 
| 66 } | 64 } | 
| 67 | 65 | 
| 68 void EnumeratePrinters(Profile* /* profile */, | 66 // Default implementation of PrinterBackendProxy.  Makes calls directly to | 
| 69                        const EnumeratePrintersCallback& cb) { | 67 // the print backend on the appropriate thread. | 
| 70   base::PostTaskAndReplyWithResult( | 68 class PrinterBackendProxyDefault : public PrinterBackendProxy { | 
| 71       content::BrowserThread::GetBlockingPool(), FROM_HERE, | 69  public: | 
| 72       base::Bind(&EnumeratePrintersOnBlockingPoolThread), cb); | 70   PrinterBackendProxyDefault() {} | 
| 73 } |  | 
| 74 | 71 | 
| 75 void ConfigurePrinterAndFetchCapabilities(Profile* /* profile */, | 72   ~PrinterBackendProxyDefault() override { | 
| 76                                           const std::string& device_name, | 73     DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 
| 77                                           const PrinterSetupCallback& cb) { | 74   } | 
| 78   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |  | 
| 79 | 75 | 
| 80   base::PostTaskAndReplyWithResult( | 76   void GetDefaultPrinter(const DefaultPrinterCallback& cb) override { | 
| 81       content::BrowserThread::GetBlockingPool(), FROM_HERE, | 77     DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 
| 82       base::Bind(&FetchCapabilitiesOnBlockingPool, device_name), cb); | 78 | 
|  | 79     base::PostTaskAndReplyWithResult( | 
|  | 80         content::BrowserThread::GetBlockingPool(), FROM_HERE, | 
|  | 81         base::Bind(&GetDefaultPrinterOnBlockingPoolThread), cb); | 
|  | 82   } | 
|  | 83 | 
|  | 84   void EnumeratePrinters(const EnumeratePrintersCallback& cb) override { | 
|  | 85     DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 
|  | 86 | 
|  | 87     base::PostTaskAndReplyWithResult( | 
|  | 88         content::BrowserThread::GetBlockingPool(), FROM_HERE, | 
|  | 89         base::Bind(&EnumeratePrintersOnBlockingPoolThread), cb); | 
|  | 90   } | 
|  | 91 | 
|  | 92   void ConfigurePrinterAndFetchCapabilities( | 
|  | 93       const std::string& device_name, | 
|  | 94       const PrinterSetupCallback& cb) override { | 
|  | 95     DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 
|  | 96 | 
|  | 97     base::PostTaskAndReplyWithResult( | 
|  | 98         content::BrowserThread::GetBlockingPool(), FROM_HERE, | 
|  | 99         base::Bind(&FetchCapabilitiesOnBlockingPool, device_name), cb); | 
|  | 100   } | 
|  | 101 | 
|  | 102  private: | 
|  | 103   DISALLOW_COPY_AND_ASSIGN(PrinterBackendProxyDefault); | 
|  | 104 }; | 
|  | 105 | 
|  | 106 }  // namespace | 
|  | 107 | 
|  | 108 std::unique_ptr<PrinterBackendProxy> PrinterBackendProxy::Create() { | 
|  | 109   return base::MakeUnique<PrinterBackendProxyDefault>(); | 
| 83 } | 110 } | 
| 84 | 111 | 
| 85 }  // namespace printing | 112 }  // namespace printing | 
| OLD | NEW | 
|---|