| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ExtensionPrinterHandler::StartGetCapability( | 168 void ExtensionPrinterHandler::StartGetCapability( |
| 169 const std::string& destination_id, | 169 const std::string& destination_id, |
| 170 const PrinterHandler::GetCapabilityCallback& callback) { | 170 const PrinterHandler::GetCapabilityCallback& callback) { |
| 171 extensions::PrinterProviderAPIFactory::GetInstance() | 171 extensions::PrinterProviderAPIFactory::GetInstance() |
| 172 ->GetForBrowserContext(browser_context_) | 172 ->GetForBrowserContext(browser_context_) |
| 173 ->DispatchGetCapabilityRequested( | 173 ->DispatchGetCapabilityRequested( |
| 174 destination_id, | 174 destination_id, |
| 175 base::Bind(&ExtensionPrinterHandler::WrapGetCapabilityCallback, | 175 base::Bind(&ExtensionPrinterHandler::WrapGetCapabilityCallback, |
| 176 weak_ptr_factory_.GetWeakPtr(), callback, destination_id)); | 176 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ExtensionPrinterHandler::StartPrint( | 179 void ExtensionPrinterHandler::StartPrint( |
| 180 const std::string& destination_id, | 180 const std::string& destination_id, |
| 181 const std::string& capability, | 181 const std::string& capability, |
| 182 const base::string16& job_title, | 182 const base::string16& job_title, |
| 183 const std::string& ticket_json, | 183 const std::string& ticket_json, |
| 184 const gfx::Size& page_size, | 184 const gfx::Size& page_size, |
| 185 const scoped_refptr<base::RefCountedMemory>& print_data, | 185 const scoped_refptr<base::RefCountedMemory>& print_data, |
| 186 const PrinterHandler::PrintCallback& callback) { | 186 const PrinterHandler::PrintCallback& callback) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 bool done) { | 293 bool done) { |
| 294 DCHECK_GT(pending_enumeration_count_, 0); | 294 DCHECK_GT(pending_enumeration_count_, 0); |
| 295 if (done) | 295 if (done) |
| 296 pending_enumeration_count_--; | 296 pending_enumeration_count_--; |
| 297 | 297 |
| 298 callback.Run(printers, pending_enumeration_count_ == 0); | 298 callback.Run(printers, pending_enumeration_count_ == 0); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void ExtensionPrinterHandler::WrapGetCapabilityCallback( | 301 void ExtensionPrinterHandler::WrapGetCapabilityCallback( |
| 302 const PrinterHandler::GetCapabilityCallback& callback, | 302 const PrinterHandler::GetCapabilityCallback& callback, |
| 303 const std::string& destination_id, | |
| 304 const base::DictionaryValue& capability) { | 303 const base::DictionaryValue& capability) { |
| 305 callback.Run(destination_id, capability); | 304 callback.Run(capability); |
| 306 } | 305 } |
| 307 | 306 |
| 308 void ExtensionPrinterHandler::WrapPrintCallback( | 307 void ExtensionPrinterHandler::WrapPrintCallback( |
| 309 const PrinterHandler::PrintCallback& callback, | 308 const PrinterHandler::PrintCallback& callback, |
| 310 bool success, | 309 bool success, |
| 311 const std::string& status) { | 310 const std::string& status) { |
| 312 callback.Run(success, status); | 311 callback.Run(success, status); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void ExtensionPrinterHandler::WrapGetPrinterInfoCallback( | 314 void ExtensionPrinterHandler::WrapGetPrinterInfoCallback( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 .Set("provisional", true) | 360 .Set("provisional", true) |
| 362 .Build()); | 361 .Build()); |
| 363 } | 362 } |
| 364 } | 363 } |
| 365 } | 364 } |
| 366 | 365 |
| 367 DCHECK_GT(pending_enumeration_count_, 0); | 366 DCHECK_GT(pending_enumeration_count_, 0); |
| 368 pending_enumeration_count_--; | 367 pending_enumeration_count_--; |
| 369 callback.Run(*printer_list.Build().get(), pending_enumeration_count_ == 0); | 368 callback.Run(*printer_list.Build().get(), pending_enumeration_count_ == 0); |
| 370 } | 369 } |
| OLD | NEW |