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 "extensions/browser/api/printer_provider/printer_provider_api.h" | 5 #include "extensions/browser/api/printer_provider/printer_provider_api.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 if (!event_router->ExtensionHasEventListener( | 464 if (!event_router->ExtensionHasEventListener( |
465 extension_id, | 465 extension_id, |
466 core_api::printer_provider::OnPrintRequested::kEventName)) { | 466 core_api::printer_provider::OnPrintRequested::kEventName)) { |
467 callback.Run(false, PrinterProviderAPI::GetDefaultPrintError()); | 467 callback.Run(false, PrinterProviderAPI::GetDefaultPrintError()); |
468 return; | 468 return; |
469 } | 469 } |
470 | 470 |
471 core_api::printer_provider::PrintJob print_job; | 471 core_api::printer_provider::PrintJob print_job; |
472 print_job.printer_id = internal_printer_id; | 472 print_job.printer_id = internal_printer_id; |
473 | 473 |
474 JSONStringValueSerializer serializer(job.ticket_json); | 474 JSONStringValueDeserializer deserializer(job.ticket_json); |
475 scoped_ptr<base::Value> ticket_value(serializer.Deserialize(NULL, NULL)); | 475 scoped_ptr<base::Value> ticket_value(deserializer.Deserialize(NULL, NULL)); |
476 if (!ticket_value || | 476 if (!ticket_value || |
477 !core_api::printer_provider::PrintJob::Ticket::Populate( | 477 !core_api::printer_provider::PrintJob::Ticket::Populate( |
478 *ticket_value, &print_job.ticket)) { | 478 *ticket_value, &print_job.ticket)) { |
479 callback.Run(false, | 479 callback.Run(false, |
480 core_api::printer_provider::ToString( | 480 core_api::printer_provider::ToString( |
481 core_api::printer_provider::PRINT_ERROR_INVALID_TICKET)); | 481 core_api::printer_provider::PRINT_ERROR_INVALID_TICKET)); |
482 return; | 482 return; |
483 } | 483 } |
484 | 484 |
485 // TODO(tbarzic): Figure out how to support huge documents. | 485 // TODO(tbarzic): Figure out how to support huge documents. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 return new PrinterProviderAPIImpl(context); | 595 return new PrinterProviderAPIImpl(context); |
596 } | 596 } |
597 | 597 |
598 // static | 598 // static |
599 std::string PrinterProviderAPI::GetDefaultPrintError() { | 599 std::string PrinterProviderAPI::GetDefaultPrintError() { |
600 return core_api::printer_provider_internal::ToString( | 600 return core_api::printer_provider_internal::ToString( |
601 core_api::printer_provider_internal::PRINT_ERROR_FAILED); | 601 core_api::printer_provider_internal::PRINT_ERROR_FAILED); |
602 } | 602 } |
603 | 603 |
604 } // namespace extensions | 604 } // namespace extensions |
OLD | NEW |