Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: chrome/browser/printing/print_system_task_proxy.cc

Issue 10868097: Return error only if local printer is missing and default caps othervise. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 #endif // defined(OS_WIN) 492 #endif // defined(OS_WIN)
493 } 493 }
494 494
495 495
496 void PrintSystemTaskProxy::GetPrinterCapabilities( 496 void PrintSystemTaskProxy::GetPrinterCapabilities(
497 const std::string& printer_name) { 497 const std::string& printer_name) {
498 VLOG(1) << "Get printer capabilities start for " << printer_name; 498 VLOG(1) << "Get printer capabilities start for " << printer_name;
499 child_process_logging::ScopedPrinterInfoSetter prn_info( 499 child_process_logging::ScopedPrinterInfoSetter prn_info(
500 print_backend_->GetPrinterDriverInfo(printer_name)); 500 print_backend_->GetPrinterDriverInfo(printer_name));
501 501
502 if (!print_backend_->IsValidPrinter(printer_name)) {
503 BrowserThread::PostTask(
504 BrowserThread::UI, FROM_HERE,
505 base::Bind(&PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities,
506 this, printer_name));
507 return;
508 }
509
502 bool set_color_as_default = false; 510 bool set_color_as_default = false;
503 bool set_duplex_as_default = false; 511 bool set_duplex_as_default = false;
504 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL; 512 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL;
505 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL; 513 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL;
506 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE; 514 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE;
515 bool disable_color_options = false;
507 516
508 printing::PrinterCapsAndDefaults printer_info; 517 printing::PrinterCapsAndDefaults info;
509 if (!print_backend_->GetPrinterCapsAndDefaults(printer_name, 518 if (print_backend_->GetPrinterCapsAndDefaults(printer_name, &info) &&
510 &printer_info) || 519 ParsePrinterCapabilities(info,
511 !ParsePrinterCapabilities(printer_info, 520 printer_name,
512 printer_name, 521 &set_color_as_default,
513 &set_color_as_default, 522 &printer_color_space_for_color,
514 &printer_color_space_for_color, 523 &printer_color_space_for_black,
515 &printer_color_space_for_black, 524 &set_duplex_as_default,
516 &set_duplex_as_default, 525 &default_duplex_setting_value)) {
517 &default_duplex_setting_value)) { 526 disable_color_options = (!printer_color_space_for_color ||
518 BrowserThread::PostTask( 527 !printer_color_space_for_black ||
519 BrowserThread::UI, FROM_HERE, 528 (printer_color_space_for_color ==
520 base::Bind(&PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities, 529 printer_color_space_for_black));
521 this, printer_name)); 530 } else {
522 return; 531 VLOG(1) << "Failed to get capabilities for " << printer_name;
523 } 532 }
524 bool disable_color_options = (!printer_color_space_for_color ||
525 !printer_color_space_for_black ||
526 (printer_color_space_for_color ==
527 printer_color_space_for_black));
528 533
529 DictionaryValue settings_info; 534 DictionaryValue settings_info;
530 settings_info.SetString(kPrinterId, printer_name); 535 settings_info.SetString(kPrinterId, printer_name);
531 settings_info.SetBoolean(kDisableColorOption, disable_color_options); 536 settings_info.SetBoolean(kDisableColorOption, disable_color_options);
532 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL) 537 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL)
533 printer_color_space_for_color = printing::COLOR; 538 printer_color_space_for_color = printing::COLOR;
534 539
535 if (printer_color_space_for_black == printing::UNKNOWN_COLOR_MODEL) 540 if (printer_color_space_for_black == printing::UNKNOWN_COLOR_MODEL)
536 printer_color_space_for_black = printing::GRAY; 541 printer_color_space_for_black = printing::GRAY;
537 542
(...skipping 17 matching lines...) Expand all
555 if (handler_) 560 if (handler_)
556 handler_->SendPrinterCapabilities(*settings_info); 561 handler_->SendPrinterCapabilities(*settings_info);
557 delete settings_info; 562 delete settings_info;
558 } 563 }
559 564
560 void PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities( 565 void PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities(
561 const std::string& printer_name) { 566 const std::string& printer_name) {
562 if (handler_) 567 if (handler_)
563 handler_->SendFailedToGetPrinterCapabilities(printer_name); 568 handler_->SendFailedToGetPrinterCapabilities(printer_name);
564 } 569 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698