Chromium Code Reviews

Side by Side Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 8138020: PrintPreview: Fix printer color settings issues based on printer ppd/schema information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview_handler.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 133 matching lines...)
144 } 144 }
145 145
146 } // printing_internal namespace 146 } // printing_internal namespace
147 #endif 147 #endif
148 148
149 namespace { 149 namespace {
150 150
151 const char kDisableColorOption[] = "disableColorOption"; 151 const char kDisableColorOption[] = "disableColorOption";
152 const char kSetColorAsDefault[] = "setColorAsDefault"; 152 const char kSetColorAsDefault[] = "setColorAsDefault";
153 const char kSetDuplexAsDefault[] = "setDuplexAsDefault"; 153 const char kSetDuplexAsDefault[] = "setDuplexAsDefault";
154 const char kPrinterColorModelForBlack[] = "printerColorModelForBlack";
154 const char kPrinterColorModelForColor[] = "printerColorModelForColor"; 155 const char kPrinterColorModelForColor[] = "printerColorModelForColor";
155 const char kPrinterDefaultDuplexValue[] = "printerDefaultDuplexValue"; 156 const char kPrinterDefaultDuplexValue[] = "printerDefaultDuplexValue";
156 157
157 #if defined(USE_CUPS) 158 #if defined(USE_CUPS)
158 const char kColorDevice[] = "ColorDevice"; 159 const char kColorDevice[] = "ColorDevice";
159 const char kColorModel[] = "ColorModel"; 160 const char kColorModel[] = "ColorModel";
160 const char kColorModelForColor[] = "Color"; 161 const char kColorMode[] = "ColorMode";
161 const char kCMYK[] = "CMYK"; 162 const char kProcessColorModel[] = "ProcessColorModel";
163
162 const char kDuplex[] = "Duplex"; 164 const char kDuplex[] = "Duplex";
163 const char kDuplexNone[] = "None"; 165 const char kDuplexNone[] = "None";
166
167 // Foomatic ppd attributes and values.
168 const char kFoomaticId[] = "FoomaticIDs";
169 const char kPrintoutMode[] = "PrintoutMode";
170 const char kDraftGray[] = "Draft.Gray";
171 const char kHighGray[] = "High.Gray";
164 #elif defined(OS_WIN) 172 #elif defined(OS_WIN)
165 const char kPskColor[] = "psk:Color"; 173 const char kPskColor[] = "psk:Color";
174 const char kPskGray[] = "psk:Grayscale";
175 const char kPskMonochrome[] = "psk:Monochrome";
166 const char kPskDuplexFeature[] = "psk:JobDuplexAllDocumentsContiguously"; 176 const char kPskDuplexFeature[] = "psk:JobDuplexAllDocumentsContiguously";
167 const char kPskTwoSided[] = "psk:TwoSided"; 177 const char kPskTwoSided[] = "psk:TwoSided";
168 #endif 178 #endif
169 179
170 enum UserActionBuckets { 180 enum UserActionBuckets {
171 PRINT_TO_PRINTER, 181 PRINT_TO_PRINTER,
172 PRINT_TO_PDF, 182 PRINT_TO_PDF,
173 CANCEL, 183 CANCEL,
174 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG, 184 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
175 PREVIEW_FAILED, 185 PREVIEW_FAILED,
(...skipping 65 matching lines...)
241 if (!dict->GetInteger(printing::kSettingPageRangeFrom, &range.from) || 251 if (!dict->GetInteger(printing::kSettingPageRangeFrom, &range.from) ||
242 !dict->GetInteger(printing::kSettingPageRangeTo, &range.to)) { 252 !dict->GetInteger(printing::kSettingPageRangeTo, &range.to)) {
243 continue; 253 continue;
244 } 254 }
245 count += (range.to - range.from) + 1; 255 count += (range.to - range.from) + 1;
246 } 256 }
247 } 257 }
248 return count; 258 return count;
249 } 259 }
250 260
261 // Returns true if |color_mode| is a valid color model.
262 bool isColorModeSelected(int color_mode) {
263 return (color_mode != printing::GRAY &&
264 color_mode != printing::BLACK &&
265 color_mode != printing::PRINTOUTMODE_NORMAL_GRAY &&
266 color_mode != printing::COLORMODE_MONOCHROME &&
267 color_mode != printing::PROCESSCOLORMODEL_GREYSCALE);
268 }
269
251 // Track the popularity of print settings and report the stats. 270 // Track the popularity of print settings and report the stats.
252 void ReportPrintSettingsStats(const DictionaryValue& settings) { 271 void ReportPrintSettingsStats(const DictionaryValue& settings) {
253 bool landscape; 272 bool landscape;
254 if (settings.GetBoolean(printing::kSettingLandscape, &landscape)) 273 if (settings.GetBoolean(printing::kSettingLandscape, &landscape))
255 ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT); 274 ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT);
256 275
257 bool collate; 276 bool collate;
258 if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate) 277 if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate)
259 ReportPrintSettingHistogram(COLLATE); 278 ReportPrintSettingHistogram(COLLATE);
260 279
261 int duplex_mode; 280 int duplex_mode;
262 if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode)) 281 if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))
263 ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX); 282 ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX);
264 283
265 int color_mode; 284 int color_mode;
266 if (settings.GetInteger(printing::kSettingColor, &color_mode)) { 285 if (settings.GetInteger(printing::kSettingColor, &color_mode)) {
267 ReportPrintSettingHistogram(color_mode == printing::GRAY ? BLACK_AND_WHITE : 286 ReportPrintSettingHistogram(
268 COLOR); 287 isColorModeSelected(color_mode) ? COLOR : BLACK_AND_WHITE);
269 } 288 }
270 } 289 }
271 290
272 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { 291 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() {
273 return g_browser_process->background_printing_manager(); 292 return g_browser_process->background_printing_manager();
274 } 293 }
275 294
276 } // namespace 295 } // namespace
277 296
278 class PrintSystemTaskProxy 297 class PrintSystemTaskProxy
vandebo (ex-Chrome) 2011/10/07 18:23:30 Maybe this class should get moved out of webui?
kmadhusu 2011/10/10 23:34:26 Done.
279 : public base::RefCountedThreadSafe<PrintSystemTaskProxy, 298 : public base::RefCountedThreadSafe<PrintSystemTaskProxy,
280 BrowserThread::DeleteOnUIThread> { 299 BrowserThread::DeleteOnUIThread> {
281 public: 300 public:
282 PrintSystemTaskProxy(const base::WeakPtr<PrintPreviewHandler>& handler, 301 PrintSystemTaskProxy(const base::WeakPtr<PrintPreviewHandler>& handler,
283 printing::PrintBackend* print_backend, 302 printing::PrintBackend* print_backend,
284 bool has_logged_printers_count) 303 bool has_logged_printers_count)
285 : handler_(handler), 304 : handler_(handler),
286 print_backend_(print_backend), 305 print_backend_(print_backend),
287 has_logged_printers_count_(has_logged_printers_count) { 306 has_logged_printers_count_(has_logged_printers_count) {
288 } 307 }
(...skipping 77 matching lines...)
366 void SetupPrinterList(ListValue* printers) { 385 void SetupPrinterList(ListValue* printers) {
367 if (handler_) { 386 if (handler_) {
368 handler_->SetupPrinterList(*printers); 387 handler_->SetupPrinterList(*printers);
369 } 388 }
370 delete printers; 389 delete printers;
371 } 390 }
372 391
373 void GetPrinterCapabilities(const std::string& printer_name) { 392 void GetPrinterCapabilities(const std::string& printer_name) {
374 VLOG(1) << "Get printer capabilities start for " << printer_name; 393 VLOG(1) << "Get printer capabilities start for " << printer_name;
375 printing::PrinterCapsAndDefaults printer_info; 394 printing::PrinterCapsAndDefaults printer_info;
376 bool supports_color = true; 395
396 bool set_color_as_default = false;
397 bool disable_color_options = false;
377 bool set_duplex_as_default = false; 398 bool set_duplex_as_default = false;
378 int printer_color_space = printing::GRAY; 399 int printer_color_space_for_color = printing::COLOR;
vandebo (ex-Chrome) 2011/10/07 18:23:30 Move both of these down to line 448 - just before
kmadhusu 2011/10/10 23:34:26 This is also used by windows code.
400 int printer_color_space_for_black = printing::GRAY;
379 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE; 401 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE;
380 if (!print_backend_->GetPrinterCapsAndDefaults(printer_name, 402 if (!print_backend_->GetPrinterCapsAndDefaults(printer_name,
381 &printer_info)) { 403 &printer_info)) {
382 return; 404 return;
383 } 405 }
384 406
385 #if defined(USE_CUPS) 407 #if defined(USE_CUPS)
386 FilePath ppd_file_path; 408 FilePath ppd_file_path;
387 if (!file_util::CreateTemporaryFile(&ppd_file_path)) 409 if (!file_util::CreateTemporaryFile(&ppd_file_path))
388 return; 410 return;
389 411
390 int data_size = printer_info.printer_capabilities.length(); 412 int data_size = printer_info.printer_capabilities.length();
391 if (data_size != file_util::WriteFile( 413 if (data_size != file_util::WriteFile(
392 ppd_file_path, 414 ppd_file_path,
393 printer_info.printer_capabilities.data(), 415 printer_info.printer_capabilities.data(),
394 data_size)) { 416 data_size)) {
395 file_util::Delete(ppd_file_path, false); 417 file_util::Delete(ppd_file_path, false);
396 return; 418 return;
397 } 419 }
398 420
399 ppd_file_t* ppd = ppdOpenFile(ppd_file_path.value().c_str()); 421 ppd_file_t* ppd = ppdOpenFile(ppd_file_path.value().c_str());
400 if (ppd) { 422 if (ppd) {
401 #if !defined(OS_MACOSX) 423 #if !defined(OS_MACOSX)
402 printing_internal::mark_lpoptions(printer_name, &ppd); 424 printing_internal::mark_lpoptions(printer_name, &ppd);
403 #endif 425 #endif
426 bool is_color_device = false;
404 ppd_attr_t* attr = ppdFindAttr(ppd, kColorDevice, NULL); 427 ppd_attr_t* attr = ppdFindAttr(ppd, kColorDevice, NULL);
405 if (attr && attr->value) 428 if (attr && attr->value)
406 supports_color = ppd->color_device; 429 is_color_device = ppd->color_device;
430 disable_color_options = !is_color_device;
407 431
408 ppd_choice_t* duplex_choice = ppdFindMarkedChoice(ppd, kDuplex); 432 ppd_choice_t* duplex_choice = ppdFindMarkedChoice(ppd, kDuplex);
409 if (duplex_choice) { 433 if (duplex_choice) {
410 ppd_option_t* option = ppdFindOption(ppd, kDuplex); 434 ppd_option_t* option = ppdFindOption(ppd, kDuplex);
411 if (option) 435 if (option)
412 duplex_choice = ppdFindChoice(option, option->defchoice); 436 duplex_choice = ppdFindChoice(option, option->defchoice);
413 } 437 }
414 438
415 if (duplex_choice) { 439 if (duplex_choice) {
416 if (base::strcasecmp(duplex_choice->choice, kDuplexNone) != 0) { 440 if (base::strcasecmp(duplex_choice->choice, kDuplexNone) != 0) {
417 set_duplex_as_default = true; 441 set_duplex_as_default = true;
418 default_duplex_setting_value = printing::LONG_EDGE; 442 default_duplex_setting_value = printing::LONG_EDGE;
419 } else { 443 } else {
420 default_duplex_setting_value = printing::SIMPLEX; 444 default_duplex_setting_value = printing::SIMPLEX;
421 } 445 }
422 } 446 }
423 447
424 if (supports_color) { 448 set_color_as_default = is_color_device;
449 if (is_color_device) {
425 // Identify the color space (COLOR/CMYK) for this printer. 450 // Identify the color space (COLOR/CMYK) for this printer.
426 ppd_option_t* color_model = ppdFindOption(ppd, kColorModel); 451 ppd_option_t* color_model = ppdFindOption(ppd, kColorModel);
427 if (color_model) { 452 if (color_model) {
vandebo (ex-Chrome) 2011/10/07 18:23:30 I would pull each of these blocks into a method...
kmadhusu 2011/10/10 23:34:26 Done.
428 if (ppdFindChoice(color_model, kColorModelForColor)) 453 if (ppdFindChoice(color_model, printing::kBlack))
vandebo (ex-Chrome) 2011/10/07 18:23:30 Does this need to happen even if it's not a color
kmadhusu 2011/10/10 23:34:26 No. I have seen Black and Gray only as ColorModel
429 printer_color_space = printing::COLOR; 454 printer_color_space_for_black = printing::BLACK;
430 else if (ppdFindChoice(color_model, kCMYK)) 455 else if (!ppdFindChoice(color_model, printing::kGray)) {
431 printer_color_space = printing::CMYK; 456 disable_color_options = true;
457 }
458
459 if (ppdFindChoice(color_model, printing::kColor))
460 printer_color_space_for_color = printing::COLOR;
461 else if (ppdFindChoice(color_model, printing::kCMYK))
462 printer_color_space_for_color = printing::CMYK;
463 else if (ppdFindChoice(color_model, printing::kRGB))
464 printer_color_space_for_color = printing::RGB;
465 else if (ppdFindChoice(color_model, printing::kRGBA))
466 printer_color_space_for_color = printing::RGBA;
467 else if (ppdFindChoice(color_model, printing::kRGB16))
468 printer_color_space_for_color = printing::RGB16;
469 else if (ppdFindChoice(color_model, printing::kCMY))
470 printer_color_space_for_color = printing::CMY;
471 else if (ppdFindChoice(color_model, printing::kKCMY))
472 printer_color_space_for_color = printing::KCMY;
473 else if (ppdFindChoice(color_model, printing::kCMY_K))
474 printer_color_space_for_color = printing::CMY_K;
475 } else {
476 disable_color_options = true;
477 }
478 }
479
480 // If this is a foomatic ppd, color values are present in
481 // PrintoutMode attribute.
482 ppd_attr_t* foomatic_id_attr = ppdFindAttr(ppd, kFoomaticId, NULL);
483 if (foomatic_id_attr && foomatic_id_attr->value) {
484 ppd_option_t* printout_mode = ppdFindOption(ppd, kPrintoutMode);
485 if (printout_mode) {
486 disable_color_options = false;
487 printer_color_space_for_color = printing::PRINTOUTMODE_NORMAL;
488 printer_color_space_for_black = printing::PRINTOUTMODE_NORMAL;
489
490 // Check to see if NORMAL_GRAY value is supported by PrintoutMode.
491 // If NORMAL_GRAY is not supported, NORMAL value is used to
492 // represent grayscale. If NORMAL_GRAY is supported, NORMAL is used to
493 // represent color.
494 if (ppdFindChoice(printout_mode, printing::kNormalGray))
495 printer_color_space_for_black = printing::PRINTOUTMODE_NORMAL_GRAY;
496
497 // Get the default marked choice to identify the default color setting
498 // value.
499 ppd_choice_t* printout_mode_choice =
500 ppdFindMarkedChoice(ppd, kPrintoutMode);
501 if (!printout_mode_choice) {
502 printout_mode_choice = ppdFindChoice(printout_mode,
503 printout_mode->defchoice);
504 }
505
506 if (printout_mode_choice) {
507 if ((base::strcasecmp(printout_mode_choice->choice,
508 printing::kNormalGray) == 0) ||
509 (base::strcasecmp(printout_mode_choice->choice,
510 kHighGray) == 0) ||
511 (base::strcasecmp(printout_mode_choice->choice,
512 kDraftGray) == 0)) {
513 printer_color_space_for_black =
514 printing::PRINTOUTMODE_NORMAL_GRAY;
515 set_color_as_default = false;
516 }
517 }
518 disable_color_options = printer_color_space_for_black ==
519 printing::PRINTOUTMODE_NORMAL;
520 }
521 }
522
523 // Samsung printers use "ColorMode" attribute in their ppds.
524 ppd_option_t* color_mode_option = ppdFindOption(ppd, kColorMode);
525 if (color_mode_option) {
526 disable_color_options = false;
527 printer_color_space_for_color = printing::COLORMODE_COLOR;
528 printer_color_space_for_black = printing::COLORMODE_MONOCHROME;
529 if (!(ppdFindChoice(color_mode_option, printing::kColor) &&
530 ppdFindChoice(color_mode_option, printing::kMonochrome))) {
531 disable_color_options = true;
532 }
533
534 ppd_choice_t* mode_choice = ppdFindMarkedChoice(ppd, kColorMode);
535 if (!mode_choice) {
536 mode_choice = ppdFindChoice(color_mode_option,
537 color_mode_option->defchoice);
538 }
539
540 if (mode_choice) {
541 set_color_as_default =
542 (base::strcasecmp(mode_choice->choice, printing::kColor) == 0);
543 }
544 }
545
546 // HP printers use "Color/Color Model" attribute in their ppds.
547 color_mode_option = ppdFindOption(ppd, printing::kColor);
548 if (color_mode_option) {
549 disable_color_options = false;
550 printer_color_space_for_color = printing::HP_COLOR_COLOR;
551 printer_color_space_for_black = printing::HP_COLOR_BLACK;
552 if (!(ppdFindChoice(color_mode_option, printing::kColor) &&
553 ppdFindChoice(color_mode_option, printing::kBlack))) {
554 disable_color_options = true;
555 }
556
557 ppd_choice_t* mode_choice = ppdFindMarkedChoice(ppd, kColorMode);
558 if (!mode_choice) {
559 mode_choice = ppdFindChoice(color_mode_option,
560 color_mode_option->defchoice);
561 }
562
563 if (mode_choice) {
564 set_color_as_default =
565 (base::strcasecmp(mode_choice->choice, printing::kColor) == 0);
566 }
567 }
568
569 // Canon printers use "ProcessColorModel" attribute in their ppds.
570 color_mode_option = ppdFindOption(ppd, kProcessColorModel);
571 if (color_mode_option) {
572 disable_color_options = false;
573 if (ppdFindChoice(color_mode_option, printing::kRGB))
574 printer_color_space_for_color = printing::PROCESSCOLORMODEL_RGB;
575 else if (ppdFindChoice(color_mode_option, printing::kCMYK))
576 printer_color_space_for_color = printing::PROCESSCOLORMODEL_CMYK;
577 else
578 disable_color_options = true;
579
580 if (ppdFindChoice(color_mode_option, printing::kGreyscale))
581 printer_color_space_for_black = printing::PROCESSCOLORMODEL_GREYSCALE;
582 else
583 disable_color_options = true;
584
585 ppd_choice_t* mode_choice = ppdFindMarkedChoice(ppd,
586 kProcessColorModel);
587 if (!mode_choice) {
588 mode_choice = ppdFindChoice(color_mode_option,
589 color_mode_option->defchoice);
590 }
591
592 if (mode_choice) {
593 set_color_as_default =
594 (base::strcasecmp(mode_choice->choice,
595 printing::kGreyscale) != 0);
432 } 596 }
433 } 597 }
434 ppdClose(ppd); 598 ppdClose(ppd);
435 } 599 }
436 file_util::Delete(ppd_file_path, false); 600 file_util::Delete(ppd_file_path, false);
437 #elif defined(OS_WIN) 601 #elif defined(OS_WIN)
438 // According to XPS 1.0 spec, only color printers have psk:Color. 602 // According to XPS 1.0 spec, only color printers have psk:Color.
439 // Therefore we don't need to parse the whole XML file, we just need to 603 // Therefore we don't need to parse the whole XML file, we just need to
440 // search the string. The spec can be found at: 604 // search the string. The spec can be found at:
441 // http://msdn.microsoft.com/en-us/windows/hardware/gg463431. 605 // http://msdn.microsoft.com/en-us/windows/hardware/gg463431.
606 bool supports_color = false;
607 bool supports_grayscale = true;
442 supports_color = (printer_info.printer_capabilities.find(kPskColor) != 608 supports_color = (printer_info.printer_capabilities.find(kPskColor) !=
443 std::string::npos); 609 std::string::npos);
444 if (supports_color) 610
445 printer_color_space = printing::COLOR; 611 supports_grayscale =
612 (printer_info.printer_capabilities.find(kPskGray) !=
613 std::string::npos) ||
614 (printer_info.printer_capabilities.find(kPskMonochrome) !=
615 std::string::npos);
446 616
447 set_duplex_as_default = 617 set_duplex_as_default =
448 (printer_info.printer_defaults.find(kPskDuplexFeature) != 618 (printer_info.printer_defaults.find(kPskDuplexFeature) !=
449 std::string::npos) && 619 std::string::npos) &&
450 (printer_info.printer_defaults.find(kPskTwoSided) != 620 (printer_info.printer_defaults.find(kPskTwoSided) !=
451 std::string::npos); 621 std::string::npos);
452 622
453 if (printer_info.printer_defaults.find(kPskDuplexFeature) != 623 if (printer_info.printer_defaults.find(kPskDuplexFeature) !=
454 std::string::npos) { 624 std::string::npos) {
455 if (printer_info.printer_defaults.find(kPskTwoSided) != 625 if (printer_info.printer_defaults.find(kPskTwoSided) !=
456 std::string::npos) { 626 std::string::npos) {
457 default_duplex_setting_value = printing::LONG_EDGE; 627 default_duplex_setting_value = printing::LONG_EDGE;
458 } else { 628 } else {
459 default_duplex_setting_value = printing::SIMPLEX; 629 default_duplex_setting_value = printing::SIMPLEX;
460 } 630 }
461 } 631 }
632 disable_color_options = !supports_color || !supports_grayscale;
vandebo (ex-Chrome) 2011/10/07 18:23:30 Can you use this logic above?
kmadhusu 2011/10/10 23:34:26 Done.
633 set_color_as_default = supports_color;
462 #else 634 #else
463 NOTIMPLEMENTED(); 635 NOTIMPLEMENTED();
464 #endif 636 #endif
465
466 DictionaryValue settings_info; 637 DictionaryValue settings_info;
467 settings_info.SetBoolean(kDisableColorOption, !supports_color); 638 settings_info.SetBoolean(kDisableColorOption, disable_color_options);
468 if (!supports_color) { 639 if (disable_color_options) {
469 settings_info.SetBoolean(kSetColorAsDefault, false); 640 settings_info.SetBoolean(kSetColorAsDefault, set_color_as_default);
470 } else { 641 } else {
471 settings_info.SetBoolean(kSetColorAsDefault, 642 settings_info.SetBoolean(kSetColorAsDefault,
472 PrintPreviewHandler::last_used_color_setting_); 643 PrintPreviewHandler::last_used_color_setting_);
473 } 644 }
474 settings_info.SetBoolean(kSetDuplexAsDefault, set_duplex_as_default); 645 settings_info.SetBoolean(kSetDuplexAsDefault, set_duplex_as_default);
475 settings_info.SetInteger(kPrinterColorModelForColor, printer_color_space); 646 settings_info.SetInteger(kPrinterColorModelForColor,
647 printer_color_space_for_color);
648 settings_info.SetInteger(kPrinterColorModelForBlack,
649 printer_color_space_for_black);
476 settings_info.SetInteger(kPrinterDefaultDuplexValue, 650 settings_info.SetInteger(kPrinterDefaultDuplexValue,
477 default_duplex_setting_value); 651 default_duplex_setting_value);
478 BrowserThread::PostTask( 652 BrowserThread::PostTask(
479 BrowserThread::UI, FROM_HERE, 653 BrowserThread::UI, FROM_HERE,
480 NewRunnableMethod(this, 654 NewRunnableMethod(this,
481 &PrintSystemTaskProxy::SendPrinterCapabilities, 655 &PrintSystemTaskProxy::SendPrinterCapabilities,
482 settings_info.DeepCopy())); 656 settings_info.DeepCopy()));
483 } 657 }
484 658
485 void SendPrinterCapabilities(DictionaryValue* settings_info) { 659 void SendPrinterCapabilities(DictionaryValue* settings_info) {
(...skipping 229 matching lines...)
715 } 889 }
716 890
717 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 891 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
718 if (!settings.get()) 892 if (!settings.get())
719 return; 893 return;
720 894
721 // Storing last used color setting. 895 // Storing last used color setting.
722 int color_mode; 896 int color_mode;
723 if (!settings->GetInteger(printing::kSettingColor, &color_mode)) 897 if (!settings->GetInteger(printing::kSettingColor, &color_mode))
724 color_mode = printing::GRAY; 898 color_mode = printing::GRAY;
725 last_used_color_setting_ = (color_mode != printing::GRAY); 899 last_used_color_setting_ = isColorModeSelected(color_mode);
726 900
727 bool print_to_pdf = false; 901 bool print_to_pdf = false;
728 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); 902 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
729 903
730 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); 904 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
731 905
732 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId); 906 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId);
733 bool is_cloud_dialog = false; 907 bool is_cloud_dialog = false;
734 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog); 908 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog);
735 if (is_cloud_printer) { 909 if (is_cloud_printer) {
(...skipping 437 matching lines...)
1173 return; 1347 return;
1174 1348
1175 // We no longer require the initiator tab details. Remove those details 1349 // We no longer require the initiator tab details. Remove those details
1176 // associated with the preview tab to allow the initiator tab to create 1350 // associated with the preview tab to allow the initiator tab to create
1177 // another preview tab. 1351 // another preview tab.
1178 printing::PrintPreviewTabController* tab_controller = 1352 printing::PrintPreviewTabController* tab_controller =
1179 printing::PrintPreviewTabController::GetInstance(); 1353 printing::PrintPreviewTabController::GetInstance();
1180 if (tab_controller) 1354 if (tab_controller)
1181 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); 1355 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper());
1182 } 1356 }
OLDNEW

Powered by Google App Engine