| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 #endif // defined(OS_WIN) | 499 #endif // defined(OS_WIN) |
| 500 | 500 |
| 501 void PrintSystemTaskProxy::GetPrinterCapabilities( | 501 void PrintSystemTaskProxy::GetPrinterCapabilities( |
| 502 const std::string& printer_name) { | 502 const std::string& printer_name) { |
| 503 VLOG(1) << "Get printer capabilities start for " << printer_name; | 503 VLOG(1) << "Get printer capabilities start for " << printer_name; |
| 504 child_process_logging::ScopedPrinterInfoSetter prn_info( | 504 child_process_logging::ScopedPrinterInfoSetter prn_info( |
| 505 print_backend_->GetPrinterDriverInfo(printer_name)); | 505 print_backend_->GetPrinterDriverInfo(printer_name)); |
| 506 printing::PrinterCapsAndDefaults printer_info; | |
| 507 if (!print_backend_->GetPrinterCapsAndDefaults(printer_name, | |
| 508 &printer_info)) { | |
| 509 return; | |
| 510 } | |
| 511 | 506 |
| 512 bool set_color_as_default = false; | 507 bool set_color_as_default = false; |
| 513 bool set_duplex_as_default = false; | 508 bool set_duplex_as_default = false; |
| 514 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL; | 509 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL; |
| 515 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL; | 510 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL; |
| 516 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE; | 511 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE; |
| 517 | 512 |
| 513 printing::PrinterCapsAndDefaults printer_info; |
| 514 if (print_backend_->GetPrinterCapsAndDefaults(printer_name, |
| 515 &printer_info)) { |
| 518 #if defined(USE_CUPS) | 516 #if defined(USE_CUPS) |
| 519 if (!GetPrinterCapabilitiesCUPS(printer_info, | 517 if (!GetPrinterCapabilitiesCUPS(printer_info, |
| 520 printer_name, | 518 printer_name, |
| 521 &set_color_as_default, | 519 &set_color_as_default, |
| 522 &printer_color_space_for_color, | 520 &printer_color_space_for_color, |
| 523 &printer_color_space_for_black, | 521 &printer_color_space_for_black, |
| 524 &set_duplex_as_default, | 522 &set_duplex_as_default, |
| 525 &default_duplex_setting_value)) { | 523 &default_duplex_setting_value)) { |
| 526 return; | 524 return; |
| 525 } |
| 526 #elif defined(OS_WIN) |
| 527 GetPrinterCapabilitiesWin(printer_info, |
| 528 &set_color_as_default, |
| 529 &printer_color_space_for_color, |
| 530 &printer_color_space_for_black, |
| 531 &set_duplex_as_default, |
| 532 &default_duplex_setting_value); |
| 533 #else |
| 534 NOTIMPLEMENTED(); |
| 535 #endif |
| 527 } | 536 } |
| 528 #elif defined(OS_WIN) | |
| 529 GetPrinterCapabilitiesWin(printer_info, | |
| 530 &set_color_as_default, | |
| 531 &printer_color_space_for_color, | |
| 532 &printer_color_space_for_black, | |
| 533 &set_duplex_as_default, | |
| 534 &default_duplex_setting_value); | |
| 535 #else | |
| 536 NOTIMPLEMENTED(); | |
| 537 #endif | |
| 538 bool disable_color_options = (!printer_color_space_for_color || | 537 bool disable_color_options = (!printer_color_space_for_color || |
| 539 !printer_color_space_for_black || | 538 !printer_color_space_for_black || |
| 540 (printer_color_space_for_color == | 539 (printer_color_space_for_color == |
| 541 printer_color_space_for_black)); | 540 printer_color_space_for_black)); |
| 542 | 541 |
| 543 DictionaryValue settings_info; | 542 DictionaryValue settings_info; |
| 544 settings_info.SetString(kPrinterId, printer_name); | 543 settings_info.SetString(kPrinterId, printer_name); |
| 545 settings_info.SetBoolean(kDisableColorOption, disable_color_options); | 544 settings_info.SetBoolean(kDisableColorOption, disable_color_options); |
| 546 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL) | 545 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL) |
| 547 printer_color_space_for_color = printing::COLOR; | 546 printer_color_space_for_color = printing::COLOR; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 563 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, | 562 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, |
| 564 settings_info.DeepCopy())); | 563 settings_info.DeepCopy())); |
| 565 } | 564 } |
| 566 | 565 |
| 567 void PrintSystemTaskProxy::SendPrinterCapabilities( | 566 void PrintSystemTaskProxy::SendPrinterCapabilities( |
| 568 DictionaryValue* settings_info) { | 567 DictionaryValue* settings_info) { |
| 569 if (handler_) | 568 if (handler_) |
| 570 handler_->SendPrinterCapabilities(*settings_info); | 569 handler_->SendPrinterCapabilities(*settings_info); |
| 571 delete settings_info; | 570 delete settings_info; |
| 572 } | 571 } |
| OLD | NEW |