| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 if (!event_router->ExtensionHasEventListener( | 587 if (!event_router->ExtensionHasEventListener( |
| 588 extension_id, api::printer_provider::OnPrintRequested::kEventName)) { | 588 extension_id, api::printer_provider::OnPrintRequested::kEventName)) { |
| 589 callback.Run(false, PrinterProviderAPI::GetDefaultPrintError()); | 589 callback.Run(false, PrinterProviderAPI::GetDefaultPrintError()); |
| 590 return; | 590 return; |
| 591 } | 591 } |
| 592 | 592 |
| 593 api::printer_provider::PrintJob print_job; | 593 api::printer_provider::PrintJob print_job; |
| 594 print_job.printer_id = internal_printer_id; | 594 print_job.printer_id = internal_printer_id; |
| 595 | 595 |
| 596 JSONStringValueDeserializer deserializer(job.ticket_json); | 596 JSONStringValueDeserializer deserializer(job.ticket_json); |
| 597 scoped_ptr<base::Value> ticket_value(deserializer.Deserialize(NULL, NULL)); | 597 scoped_ptr<base::Value> ticket_value = deserializer.Deserialize(NULL, NULL); |
| 598 if (!ticket_value || | 598 if (!ticket_value || |
| 599 !api::printer_provider::PrintJob::Ticket::Populate(*ticket_value, | 599 !api::printer_provider::PrintJob::Ticket::Populate(*ticket_value, |
| 600 &print_job.ticket)) { | 600 &print_job.ticket)) { |
| 601 callback.Run(false, api::printer_provider::ToString( | 601 callback.Run(false, api::printer_provider::ToString( |
| 602 api::printer_provider::PRINT_ERROR_INVALID_TICKET)); | 602 api::printer_provider::PRINT_ERROR_INVALID_TICKET)); |
| 603 return; | 603 return; |
| 604 } | 604 } |
| 605 | 605 |
| 606 print_job.content_type = job.content_type; | 606 print_job.content_type = job.content_type; |
| 607 print_job.title = base::UTF16ToUTF8(job.job_title); | 607 print_job.title = base::UTF16ToUTF8(job.job_title); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 return new PrinterProviderAPIImpl(context); | 761 return new PrinterProviderAPIImpl(context); |
| 762 } | 762 } |
| 763 | 763 |
| 764 // static | 764 // static |
| 765 std::string PrinterProviderAPI::GetDefaultPrintError() { | 765 std::string PrinterProviderAPI::GetDefaultPrintError() { |
| 766 return api::printer_provider_internal::ToString( | 766 return api::printer_provider_internal::ToString( |
| 767 api::printer_provider_internal::PRINT_ERROR_FAILED); | 767 api::printer_provider_internal::PRINT_ERROR_FAILED); |
| 768 } | 768 } |
| 769 | 769 |
| 770 } // namespace extensions | 770 } // namespace extensions |
| OLD | NEW |