| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extension_printer_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/extension_printer_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 | 145 |
| 146 print_job->content_type = kContentTypePWGRaster; | 146 print_job->content_type = kContentTypePWGRaster; |
| 147 ConvertToPWGRaster(print_data, printer_description, ticket, page_size, | 147 ConvertToPWGRaster(print_data, printer_description, ticket, page_size, |
| 148 print_job.Pass(), | 148 print_job.Pass(), |
| 149 base::Bind(&ExtensionPrinterHandler::DispatchPrintJob, | 149 base::Bind(&ExtensionPrinterHandler::DispatchPrintJob, |
| 150 weak_ptr_factory_.GetWeakPtr(), callback)); | 150 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void ExtensionPrinterHandler::StartGrantUsbPrinterAccess( |
| 154 const std::string& extension_id, |
| 155 int device_id, |
| 156 const GrantUsbPrinterAccessCallback& callback) { |
| 157 extensions::PrinterProviderAPIFactory::GetInstance() |
| 158 ->GetForBrowserContext(browser_context_) |
| 159 ->DispatchGrantUsbPrinterAccess( |
| 160 extension_id, device_id, |
| 161 base::Bind( |
| 162 &ExtensionPrinterHandler::WrapGrantUsbPrinterAccessCallback, |
| 163 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 164 } |
| 165 |
| 153 void ExtensionPrinterHandler::SetPwgRasterConverterForTesting( | 166 void ExtensionPrinterHandler::SetPwgRasterConverterForTesting( |
| 154 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter) { | 167 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter) { |
| 155 pwg_raster_converter_ = pwg_raster_converter.Pass(); | 168 pwg_raster_converter_ = pwg_raster_converter.Pass(); |
| 156 } | 169 } |
| 157 | 170 |
| 158 void ExtensionPrinterHandler::ConvertToPWGRaster( | 171 void ExtensionPrinterHandler::ConvertToPWGRaster( |
| 159 const scoped_refptr<base::RefCountedMemory>& data, | 172 const scoped_refptr<base::RefCountedMemory>& data, |
| 160 const cloud_devices::CloudDeviceDescription& printer_description, | 173 const cloud_devices::CloudDeviceDescription& printer_description, |
| 161 const cloud_devices::CloudDeviceDescription& ticket, | 174 const cloud_devices::CloudDeviceDescription& ticket, |
| 162 const gfx::Size& page_size, | 175 const gfx::Size& page_size, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 const base::DictionaryValue& capability) { | 214 const base::DictionaryValue& capability) { |
| 202 callback.Run(destination_id, capability); | 215 callback.Run(destination_id, capability); |
| 203 } | 216 } |
| 204 | 217 |
| 205 void ExtensionPrinterHandler::WrapPrintCallback( | 218 void ExtensionPrinterHandler::WrapPrintCallback( |
| 206 const PrinterHandler::PrintCallback& callback, | 219 const PrinterHandler::PrintCallback& callback, |
| 207 bool success, | 220 bool success, |
| 208 const std::string& status) { | 221 const std::string& status) { |
| 209 callback.Run(success, status); | 222 callback.Run(success, status); |
| 210 } | 223 } |
| 224 |
| 225 void ExtensionPrinterHandler::WrapGrantUsbPrinterAccessCallback( |
| 226 const GrantUsbPrinterAccessCallback& callback, |
| 227 const base::DictionaryValue& printer_info) { |
| 228 callback.Run(printer_info); |
| 229 } |
| OLD | NEW |