OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/printing/print_system_task_proxy.h" | 5 #include "chrome/browser/printing/print_system_task_proxy.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } | 515 } |
516 } | 516 } |
517 } | 517 } |
518 #endif // defined(OS_WIN) | 518 #endif // defined(OS_WIN) |
519 | 519 |
520 void PrintSystemTaskProxy::GetPrinterCapabilities( | 520 void PrintSystemTaskProxy::GetPrinterCapabilities( |
521 const std::string& printer_name) { | 521 const std::string& printer_name) { |
522 VLOG(1) << "Get printer capabilities start for " << printer_name; | 522 VLOG(1) << "Get printer capabilities start for " << printer_name; |
523 child_process_logging::ScopedPrinterInfoSetter prn_info( | 523 child_process_logging::ScopedPrinterInfoSetter prn_info( |
524 print_backend_->GetPrinterDriverInfo(printer_name)); | 524 print_backend_->GetPrinterDriverInfo(printer_name)); |
525 printing::PrinterCapsAndDefaults printer_info; | |
526 if (!print_backend_->GetPrinterCapsAndDefaults(printer_name, | |
527 &printer_info)) { | |
528 return; | |
529 } | |
530 | 525 |
531 bool set_color_as_default = false; | 526 bool set_color_as_default = false; |
532 bool set_duplex_as_default = false; | 527 bool set_duplex_as_default = false; |
533 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL; | 528 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL; |
534 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL; | 529 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL; |
535 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE; | 530 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE; |
536 | 531 |
| 532 printing::PrinterCapsAndDefaults printer_info; |
| 533 if (print_backend_->GetPrinterCapsAndDefaults(printer_name, |
| 534 &printer_info)) { |
537 #if defined(USE_CUPS) | 535 #if defined(USE_CUPS) |
538 if (!GetPrinterCapabilitiesCUPS(printer_info, | 536 if (!GetPrinterCapabilitiesCUPS(printer_info, |
539 printer_name, | 537 printer_name, |
540 &set_color_as_default, | 538 &set_color_as_default, |
541 &printer_color_space_for_color, | 539 &printer_color_space_for_color, |
542 &printer_color_space_for_black, | 540 &printer_color_space_for_black, |
543 &set_duplex_as_default, | 541 &set_duplex_as_default, |
544 &default_duplex_setting_value)) { | 542 &default_duplex_setting_value)) { |
545 return; | 543 return; |
| 544 } |
| 545 #elif defined(OS_WIN) |
| 546 GetPrinterCapabilitiesWin(printer_info, |
| 547 &set_color_as_default, |
| 548 &printer_color_space_for_color, |
| 549 &printer_color_space_for_black, |
| 550 &set_duplex_as_default, |
| 551 &default_duplex_setting_value); |
| 552 #else |
| 553 NOTIMPLEMENTED(); |
| 554 #endif |
546 } | 555 } |
547 #elif defined(OS_WIN) | |
548 GetPrinterCapabilitiesWin(printer_info, | |
549 &set_color_as_default, | |
550 &printer_color_space_for_color, | |
551 &printer_color_space_for_black, | |
552 &set_duplex_as_default, | |
553 &default_duplex_setting_value); | |
554 #else | |
555 NOTIMPLEMENTED(); | |
556 #endif | |
557 bool disable_color_options = (!printer_color_space_for_color || | 556 bool disable_color_options = (!printer_color_space_for_color || |
558 !printer_color_space_for_black || | 557 !printer_color_space_for_black || |
559 (printer_color_space_for_color == | 558 (printer_color_space_for_color == |
560 printer_color_space_for_black)); | 559 printer_color_space_for_black)); |
561 | 560 |
562 DictionaryValue settings_info; | 561 DictionaryValue settings_info; |
563 settings_info.SetString(kPrinterId, printer_name); | 562 settings_info.SetString(kPrinterId, printer_name); |
564 settings_info.SetBoolean(kDisableColorOption, disable_color_options); | 563 settings_info.SetBoolean(kDisableColorOption, disable_color_options); |
565 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL) | 564 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL) |
566 printer_color_space_for_color = printing::COLOR; | 565 printer_color_space_for_color = printing::COLOR; |
(...skipping 24 matching lines...) Expand all Loading... |
591 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, | 590 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, |
592 settings_info.DeepCopy())); | 591 settings_info.DeepCopy())); |
593 } | 592 } |
594 | 593 |
595 void PrintSystemTaskProxy::SendPrinterCapabilities( | 594 void PrintSystemTaskProxy::SendPrinterCapabilities( |
596 DictionaryValue* settings_info) { | 595 DictionaryValue* settings_info) { |
597 if (handler_) | 596 if (handler_) |
598 handler_->SendPrinterCapabilities(*settings_info); | 597 handler_->SendPrinterCapabilities(*settings_info); |
599 delete settings_info; | 598 delete settings_info; |
600 } | 599 } |
OLD | NEW |