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

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

Issue 10905006: Get semantic capabilities from Print Backend. (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
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>
Lei Zhang 2012/09/05 00:32:32 nit: you can remove this as well as histogram.h, s
gene 2012/09/05 21:04:10 Done. histogram.h is needed below.
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" 17 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
18 #include "chrome/common/child_process_logging.h" 18 #include "chrome/common/child_process_logging.h"
19 #include "printing/backend/print_backend.h" 19 #include "printing/backend/print_backend.h"
20 #include "printing/print_job_constants.h" 20 #include "printing/print_job_constants.h"
21 #include "printing/print_settings.h" 21 #include "printing/print_settings.h"
22 22
23 #if defined(USE_CUPS) 23 #if defined(USE_CUPS)
24 #include <cups/cups.h> 24 #include <cups/cups.h>
25 #include <cups/ppd.h> 25 #include <cups/ppd.h>
26 26
27 #include "base/file_util.h" 27 #include "base/file_util.h"
28 #endif 28 #endif
29 29
30 #if defined(USE_CUPS) && !defined(OS_MACOSX)
31 namespace printing_internal {
32
33 void parse_lpoptions(const FilePath& filepath, const std::string& printer_name,
34 int* num_options, cups_option_t** options) {
35 std::string content;
36 if (!file_util::ReadFileToString(filepath, &content))
37 return;
38
39 const char kDest[] = "dest";
40 const char kDefault[] = "default";
41 size_t kDestLen = sizeof(kDest) - 1;
42 size_t kDefaultLen = sizeof(kDefault) - 1;
43 std::vector <std::string> lines;
44 base::SplitString(content, '\n', &lines);
45
46 for (size_t i = 0; i < lines.size(); ++i) {
47 std::string line = lines[i];
48 if (line.empty())
49 continue;
50
51 if (base::strncasecmp (line.c_str(), kDefault, kDefaultLen) == 0 &&
52 isspace(line[kDefaultLen])) {
53 line = line.substr(kDefaultLen);
54 } else if (base::strncasecmp (line.c_str(), kDest, kDestLen) == 0 &&
55 isspace(line[kDestLen])) {
56 line = line.substr(kDestLen);
57 } else {
58 continue;
59 }
60
61 TrimWhitespaceASCII(line, TRIM_ALL, &line);
62 if (line.empty())
63 continue;
64
65 size_t space_found = line.find(' ');
66 if (space_found == std::string::npos)
67 continue;
68
69 std::string name = line.substr(0, space_found);
70 if (name.empty())
71 continue;
72
73 if (base::strncasecmp(printer_name.c_str(), name.c_str(),
74 name.length()) != 0) {
75 continue; // This is not the required printer.
76 }
77
78 line = line.substr(space_found + 1);
79 TrimWhitespaceASCII(line, TRIM_ALL, &line); // Remove extra spaces.
80 if (line.empty())
81 continue;
82 // Parse the selected printer custom options.
83 *num_options = cupsParseOptions(line.c_str(), 0, options);
84 }
85 }
86
87 void mark_lpoptions(const std::string& printer_name, ppd_file_t** ppd) {
88 cups_option_t* options = NULL;
89 int num_options = 0;
90 ppdMarkDefaults(*ppd);
91
92 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions";
93 const char kUserLpOptionPath[] = ".cups/lpoptions";
94
95 std::vector<FilePath> file_locations;
96 file_locations.push_back(FilePath(kSystemLpOptionPath));
97 file_locations.push_back(FilePath(
98 file_util::GetHomeDir().Append(kUserLpOptionPath)));
99
100 for (std::vector<FilePath>::const_iterator it = file_locations.begin();
101 it != file_locations.end(); ++it) {
102 num_options = 0;
103 options = NULL;
104 parse_lpoptions(*it, printer_name, &num_options, &options);
105 if (num_options > 0 && options) {
106 cupsMarkOptions(*ppd, num_options, options);
107 cupsFreeOptions(num_options, options);
108 }
109 }
110 }
111
112 } // printing_internal namespace
113 #endif
114
115 using content::BrowserThread; 30 using content::BrowserThread;
116 31
117 namespace { 32 namespace {
118 33
119 const char kPrinterId[] = "printerId"; 34 const char kPrinterId[] = "printerId";
120 const char kDisableColorOption[] = "disableColorOption"; 35 const char kDisableColorOption[] = "disableColorOption";
121 const char kSetDuplexAsDefault[] = "setDuplexAsDefault"; 36 const char kSetDuplexAsDefault[] = "setDuplexAsDefault";
122 const char kPrinterColorModelForBlack[] = "printerColorModelForBlack"; 37 const char kPrinterColorModelForBlack[] = "printerColorModelForBlack";
123 const char kPrinterColorModelForColor[] = "printerColorModelForColor"; 38 const char kPrinterColorModelForColor[] = "printerColorModelForColor";
124 const char kPrinterDefaultDuplexValue[] = "printerDefaultDuplexValue"; 39 const char kPrinterDefaultDuplexValue[] = "printerDefaultDuplexValue";
125 40
126 #if defined(OS_WIN)
127 const char kPskColor[] = "psk:Color";
128 const char kPskGray[] = "psk:Grayscale";
129 const char kPskMonochrome[] = "psk:Monochrome";
130 const char kPskDuplexFeature[] = "psk:JobDuplexAllDocumentsContiguously";
131 const char kPskTwoSided[] = "psk:TwoSided";
132 #elif defined(USE_CUPS)
133 const char kColorDevice[] = "ColorDevice";
134 const char kColorModel[] = "ColorModel";
135 const char kColorMode[] = "ColorMode";
136 const char kProcessColorModel[] = "ProcessColorModel";
137 const char kPrintoutMode[] = "PrintoutMode";
138 const char kDraftGray[] = "Draft.Gray";
139 const char kHighGray[] = "High.Gray";
140
141 const char kDuplex[] = "Duplex";
142 const char kDuplexNone[] = "None";
143
144 bool getBasicColorModelSettings(
145 ppd_file_t* ppd, int* color_model_for_black, int* color_model_for_color,
146 bool* color_is_default) {
147 ppd_option_t* color_model = ppdFindOption(ppd, kColorModel);
148 if (!color_model)
149 return false;
150
151 if (ppdFindChoice(color_model, printing::kBlack))
152 *color_model_for_black = printing::BLACK;
153 else if (ppdFindChoice(color_model, printing::kGray))
154 *color_model_for_black = printing::GRAY;
155 else if (ppdFindChoice(color_model, printing::kGrayscale))
156 *color_model_for_black = printing::GRAYSCALE;
157
158 if (ppdFindChoice(color_model, printing::kColor))
159 *color_model_for_color = printing::COLOR;
160 else if (ppdFindChoice(color_model, printing::kCMYK))
161 *color_model_for_color = printing::CMYK;
162 else if (ppdFindChoice(color_model, printing::kRGB))
163 *color_model_for_color = printing::RGB;
164 else if (ppdFindChoice(color_model, printing::kRGBA))
165 *color_model_for_color = printing::RGBA;
166 else if (ppdFindChoice(color_model, printing::kRGB16))
167 *color_model_for_color = printing::RGB16;
168 else if (ppdFindChoice(color_model, printing::kCMY))
169 *color_model_for_color = printing::CMY;
170 else if (ppdFindChoice(color_model, printing::kKCMY))
171 *color_model_for_color = printing::KCMY;
172 else if (ppdFindChoice(color_model, printing::kCMY_K))
173 *color_model_for_color = printing::CMY_K;
174
175 ppd_choice_t* marked_choice = ppdFindMarkedChoice(ppd, kColorModel);
176 if (!marked_choice)
177 marked_choice = ppdFindChoice(color_model, color_model->defchoice);
178
179 if (marked_choice) {
180 *color_is_default =
181 (base::strcasecmp(marked_choice->choice, printing::kBlack) != 0) &&
182 (base::strcasecmp(marked_choice->choice, printing::kGray) != 0);
183 }
184 return true;
185 }
186
187 bool getPrintOutModeColorSettings(
188 ppd_file_t* ppd, int* color_model_for_black, int* color_model_for_color,
189 bool* color_is_default) {
190 ppd_option_t* printout_mode = ppdFindOption(ppd, kPrintoutMode);
191 if (!printout_mode)
192 return false;
193
194 *color_model_for_color = printing::PRINTOUTMODE_NORMAL;
195 *color_model_for_black = printing::PRINTOUTMODE_NORMAL;
196
197 // Check to see if NORMAL_GRAY value is supported by PrintoutMode.
198 // If NORMAL_GRAY is not supported, NORMAL value is used to
199 // represent grayscale. If NORMAL_GRAY is supported, NORMAL is used to
200 // represent color.
201 if (ppdFindChoice(printout_mode, printing::kNormalGray))
202 *color_model_for_black = printing::PRINTOUTMODE_NORMAL_GRAY;
203
204 // Get the default marked choice to identify the default color setting
205 // value.
206 ppd_choice_t* printout_mode_choice = ppdFindMarkedChoice(ppd, kPrintoutMode);
207 if (!printout_mode_choice) {
208 printout_mode_choice = ppdFindChoice(printout_mode,
209 printout_mode->defchoice);
210 }
211 if (printout_mode_choice) {
212 if ((base::strcasecmp(printout_mode_choice->choice,
213 printing::kNormalGray) == 0) ||
214 (base::strcasecmp(printout_mode_choice->choice, kHighGray) == 0) ||
215 (base::strcasecmp(printout_mode_choice->choice, kDraftGray) == 0)) {
216 *color_model_for_black = printing::PRINTOUTMODE_NORMAL_GRAY;
217 *color_is_default = false;
218 }
219 }
220 return true;
221 }
222
223 bool getColorModeSettings(
224 ppd_file_t* ppd, int* color_model_for_black, int* color_model_for_color,
225 bool* color_is_default) {
226 // Samsung printers use "ColorMode" attribute in their ppds.
227 ppd_option_t* color_mode_option = ppdFindOption(ppd, kColorMode);
228 if (!color_mode_option)
229 return false;
230
231 if (ppdFindChoice(color_mode_option, printing::kColor))
232 *color_model_for_color = printing::COLORMODE_COLOR;
233
234 if (ppdFindChoice(color_mode_option, printing::kMonochrome))
235 *color_model_for_black = printing::COLORMODE_MONOCHROME;
236
237 ppd_choice_t* mode_choice = ppdFindMarkedChoice(ppd, kColorMode);
238 if (!mode_choice) {
239 mode_choice = ppdFindChoice(color_mode_option,
240 color_mode_option->defchoice);
241 }
242
243 if (mode_choice) {
244 *color_is_default =
245 (base::strcasecmp(mode_choice->choice, printing::kColor) == 0);
246 }
247 return true;
248 }
249
250 bool getHPColorSettings(
251 ppd_file_t* ppd, int* color_model_for_black, int* color_model_for_color,
252 bool* color_is_default) {
253 // HP printers use "Color/Color Model" attribute in their ppds.
254 ppd_option_t* color_mode_option = ppdFindOption(ppd, printing::kColor);
255 if (!color_mode_option)
256 return false;
257
258 if (ppdFindChoice(color_mode_option, printing::kColor))
259 *color_model_for_color = printing::HP_COLOR_COLOR;
260 if (ppdFindChoice(color_mode_option, printing::kBlack))
261 *color_model_for_black = printing::HP_COLOR_BLACK;
262
263 ppd_choice_t* mode_choice = ppdFindMarkedChoice(ppd, kColorMode);
264 if (!mode_choice) {
265 mode_choice = ppdFindChoice(color_mode_option,
266 color_mode_option->defchoice);
267 }
268 if (mode_choice) {
269 *color_is_default =
270 (base::strcasecmp(mode_choice->choice, printing::kColor) == 0);
271 }
272 return true;
273 }
274
275 bool getProcessColorModelSettings(
276 ppd_file_t* ppd, int* color_model_for_black, int* color_model_for_color,
277 bool* color_is_default) {
278 // Canon printers use "ProcessColorModel" attribute in their ppds.
279 ppd_option_t* color_mode_option = ppdFindOption(ppd, kProcessColorModel);
280 if (!color_mode_option)
281 return false;
282
283 if (ppdFindChoice(color_mode_option, printing::kRGB))
284 *color_model_for_color = printing::PROCESSCOLORMODEL_RGB;
285 else if (ppdFindChoice(color_mode_option, printing::kCMYK))
286 *color_model_for_color = printing::PROCESSCOLORMODEL_CMYK;
287
288 if (ppdFindChoice(color_mode_option, printing::kGreyscale))
289 *color_model_for_black = printing::PROCESSCOLORMODEL_GREYSCALE;
290
291 ppd_choice_t* mode_choice = ppdFindMarkedChoice(ppd, kProcessColorModel);
292 if (!mode_choice) {
293 mode_choice = ppdFindChoice(color_mode_option,
294 color_mode_option->defchoice);
295 }
296
297 if (mode_choice) {
298 *color_is_default =
299 (base::strcasecmp(mode_choice->choice, printing::kGreyscale) != 0);
300 }
301 return true;
302 }
303 #endif
304
305 } // namespace 41 } // namespace
306 42
307 PrintSystemTaskProxy::PrintSystemTaskProxy( 43 PrintSystemTaskProxy::PrintSystemTaskProxy(
308 const base::WeakPtr<PrintPreviewHandler>& handler, 44 const base::WeakPtr<PrintPreviewHandler>& handler,
309 printing::PrintBackend* print_backend, 45 printing::PrintBackend* print_backend,
310 bool has_logged_printers_count) 46 bool has_logged_printers_count)
311 : handler_(handler), 47 : handler_(handler),
312 print_backend_(print_backend), 48 print_backend_(print_backend),
313 has_logged_printers_count_(has_logged_printers_count) { 49 has_logged_printers_count_(has_logged_printers_count) {
314 } 50 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 BrowserThread::UI, FROM_HERE, 107 BrowserThread::UI, FROM_HERE,
372 base::Bind(&PrintSystemTaskProxy::SetupPrinterList, this, printers)); 108 base::Bind(&PrintSystemTaskProxy::SetupPrinterList, this, printers));
373 } 109 }
374 110
375 void PrintSystemTaskProxy::SetupPrinterList(ListValue* printers) { 111 void PrintSystemTaskProxy::SetupPrinterList(ListValue* printers) {
376 if (handler_) 112 if (handler_)
377 handler_->SetupPrinterList(*printers); 113 handler_->SetupPrinterList(*printers);
378 delete printers; 114 delete printers;
379 } 115 }
380 116
381 bool PrintSystemTaskProxy::ParsePrinterCapabilities(
382 const printing::PrinterCapsAndDefaults& printer_info,
383 const std::string& printer_name,
384 bool* set_color_as_default,
385 int* printer_color_space_for_color,
386 int* printer_color_space_for_black,
387 bool* set_duplex_as_default,
388 int* default_duplex_setting_value) {
389 #if defined(USE_CUPS)
390 FilePath ppd_file_path;
391 if (!file_util::CreateTemporaryFile(&ppd_file_path))
392 return false;
393
394 int data_size = printer_info.printer_capabilities.length();
395 if (data_size != file_util::WriteFile(
396 ppd_file_path,
397 printer_info.printer_capabilities.data(),
398 data_size)) {
399 file_util::Delete(ppd_file_path, false);
400 return false;
401 }
402
403 ppd_file_t* ppd = ppdOpenFile(ppd_file_path.value().c_str());
404 if (ppd) {
405 #if !defined(OS_MACOSX)
406 printing_internal::mark_lpoptions(printer_name, &ppd);
407 #endif
408 ppd_choice_t* duplex_choice = ppdFindMarkedChoice(ppd, kDuplex);
409 if (!duplex_choice) {
410 ppd_option_t* option = ppdFindOption(ppd, kDuplex);
411 if (option)
412 duplex_choice = ppdFindChoice(option, option->defchoice);
413 }
414
415 if (duplex_choice) {
416 if (base::strcasecmp(duplex_choice->choice, kDuplexNone) != 0) {
417 *set_duplex_as_default = true;
418 *default_duplex_setting_value = printing::LONG_EDGE;
419 } else {
420 *default_duplex_setting_value = printing::SIMPLEX;
421 }
422 }
423
424 bool is_color_device = false;
425 ppd_attr_t* attr = ppdFindAttr(ppd, kColorDevice, NULL);
426 if (attr && attr->value)
427 is_color_device = ppd->color_device;
428 *set_color_as_default = is_color_device;
429
430 if (!((is_color_device && getBasicColorModelSettings(
431 ppd, printer_color_space_for_black,
432 printer_color_space_for_color, set_color_as_default)) ||
433 getPrintOutModeColorSettings(
434 ppd, printer_color_space_for_black,
435 printer_color_space_for_color, set_color_as_default) ||
436 getColorModeSettings(
437 ppd, printer_color_space_for_black,
438 printer_color_space_for_color, set_color_as_default) ||
439 getHPColorSettings(
440 ppd, printer_color_space_for_black,
441 printer_color_space_for_color, set_color_as_default) ||
442 getProcessColorModelSettings(
443 ppd, printer_color_space_for_black,
444 printer_color_space_for_color, set_color_as_default))) {
445 VLOG(1) << "Unknown printer color model";
446 }
447 ppdClose(ppd);
448 }
449 file_util::Delete(ppd_file_path, false);
450 return true;
451
452 #elif defined(OS_WIN)
453
454 // According to XPS 1.0 spec, only color printers have psk:Color.
455 // Therefore we don't need to parse the whole XML file, we just need to
456 // search the string. The spec can be found at:
457 // http://msdn.microsoft.com/en-us/windows/hardware/gg463431.
458 if (printer_info.printer_capabilities.find(kPskColor) != std::string::npos)
459 *printer_color_space_for_color = printing::COLOR;
460
461 if ((printer_info.printer_capabilities.find(kPskGray) !=
462 std::string::npos) ||
463 (printer_info.printer_capabilities.find(kPskMonochrome) !=
464 std::string::npos)) {
465 *printer_color_space_for_black = printing::GRAY;
466 }
467 *set_color_as_default =
468 (printer_info.printer_defaults.find(kPskColor) != std::string::npos);
469
470 *set_duplex_as_default =
471 (printer_info.printer_defaults.find(kPskDuplexFeature) !=
472 std::string::npos) &&
473 (printer_info.printer_defaults.find(kPskTwoSided) !=
474 std::string::npos);
475
476 if (printer_info.printer_defaults.find(kPskDuplexFeature) !=
477 std::string::npos) {
478 if (printer_info.printer_defaults.find(kPskTwoSided) !=
479 std::string::npos) {
480 *default_duplex_setting_value = printing::LONG_EDGE;
481 } else {
482 *default_duplex_setting_value = printing::SIMPLEX;
483 }
484 }
485 return true;
486
487 #else
488
489 NOTIMPLEMENTED();
490 return false;
491
492 #endif // defined(OS_WIN)
493 }
494
495
496 void PrintSystemTaskProxy::GetPrinterCapabilities( 117 void PrintSystemTaskProxy::GetPrinterCapabilities(
497 const std::string& printer_name) { 118 const std::string& printer_name) {
498 VLOG(1) << "Get printer capabilities start for " << printer_name; 119 VLOG(1) << "Get printer capabilities start for " << printer_name;
499 child_process_logging::ScopedPrinterInfoSetter prn_info( 120 child_process_logging::ScopedPrinterInfoSetter prn_info(
500 print_backend_->GetPrinterDriverInfo(printer_name)); 121 print_backend_->GetPrinterDriverInfo(printer_name));
501 122
502 if (!print_backend_->IsValidPrinter(printer_name)) { 123 if (!print_backend_->IsValidPrinter(printer_name)) {
124 // TODO(gene): Notify explicitly if printer is not valid, instead of
125 // failed to get capabilities.
503 BrowserThread::PostTask( 126 BrowserThread::PostTask(
504 BrowserThread::UI, FROM_HERE, 127 BrowserThread::UI, FROM_HERE,
505 base::Bind(&PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities, 128 base::Bind(&PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities,
506 this, printer_name)); 129 this, printer_name));
507 return; 130 return;
508 } 131 }
509 132
510 bool set_color_as_default = false; 133 printing::PrinterSemanticCapsAndDefaults info;
511 bool set_duplex_as_default = false; 134 if (!print_backend_->GetPrinterSemanticCapsAndDefaults(printer_name, &info)) {
512 int printer_color_space_for_color = printing::UNKNOWN_COLOR_MODEL;
513 int printer_color_space_for_black = printing::UNKNOWN_COLOR_MODEL;
514 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE;
515 bool disable_color_options = false;
516
517 printing::PrinterCapsAndDefaults info;
518 if (print_backend_->GetPrinterCapsAndDefaults(printer_name, &info) &&
519 ParsePrinterCapabilities(info,
520 printer_name,
521 &set_color_as_default,
522 &printer_color_space_for_color,
523 &printer_color_space_for_black,
524 &set_duplex_as_default,
525 &default_duplex_setting_value)) {
526 disable_color_options = (!printer_color_space_for_color ||
527 !printer_color_space_for_black ||
528 (printer_color_space_for_color ==
529 printer_color_space_for_black));
530 } else {
531 VLOG(1) << "Failed to get capabilities for " << printer_name; 135 VLOG(1) << "Failed to get capabilities for " << printer_name;
136 BrowserThread::PostTask(
137 BrowserThread::UI, FROM_HERE,
138 base::Bind(&PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities,
139 this, printer_name));
140 return;
532 } 141 }
533 142
534 DictionaryValue settings_info; 143 DictionaryValue settings_info;
535 settings_info.SetString(kPrinterId, printer_name); 144 settings_info.SetString(kPrinterId, printer_name);
536 settings_info.SetBoolean(kDisableColorOption, disable_color_options); 145 settings_info.SetBoolean(kDisableColorOption, !info.color_capable);
537 if (printer_color_space_for_color == printing::UNKNOWN_COLOR_MODEL) 146 settings_info.SetBoolean(printing::kSettingSetColorAsDefault,
538 printer_color_space_for_color = printing::COLOR; 147 info.color_default);
148 // Old API, ugly code :(
Lei Zhang 2012/09/05 00:32:32 Are we going to fix this in the future?
gene 2012/09/05 21:04:10 Yes. Plan is no make a cleaner JSON format between
149 if (info.duplex_capable) {
150 settings_info.SetBoolean(kSetDuplexAsDefault,
151 info.duplex_default != printing::SIMPLEX);
152 settings_info.SetInteger(kPrinterDefaultDuplexValue,
153 printing::LONG_EDGE);
154 } else {
155 settings_info.SetBoolean(kSetDuplexAsDefault, false);
156 settings_info.SetInteger(kPrinterDefaultDuplexValue,
157 printing::UNKNOWN_DUPLEX_MODE);
158 }
539 159
540 if (printer_color_space_for_black == printing::UNKNOWN_COLOR_MODEL)
541 printer_color_space_for_black = printing::GRAY;
542
543 settings_info.SetBoolean(printing::kSettingSetColorAsDefault,
544 set_color_as_default);
545 settings_info.SetBoolean(kSetDuplexAsDefault, set_duplex_as_default);
546 settings_info.SetInteger(kPrinterColorModelForColor,
547 printer_color_space_for_color);
548 settings_info.SetInteger(kPrinterColorModelForBlack,
549 printer_color_space_for_black);
550 settings_info.SetInteger(kPrinterDefaultDuplexValue,
551 default_duplex_setting_value);
552 BrowserThread::PostTask( 160 BrowserThread::PostTask(
553 BrowserThread::UI, FROM_HERE, 161 BrowserThread::UI, FROM_HERE,
554 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, 162 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this,
555 settings_info.DeepCopy())); 163 settings_info.DeepCopy()));
556 } 164 }
557 165
558 void PrintSystemTaskProxy::SendPrinterCapabilities( 166 void PrintSystemTaskProxy::SendPrinterCapabilities(
559 DictionaryValue* settings_info) { 167 DictionaryValue* settings_info) {
560 if (handler_) 168 if (handler_)
561 handler_->SendPrinterCapabilities(*settings_info); 169 handler_->SendPrinterCapabilities(*settings_info);
562 delete settings_info; 170 delete settings_info;
563 } 171 }
564 172
565 void PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities( 173 void PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities(
566 const std::string& printer_name) { 174 const std::string& printer_name) {
567 if (handler_) 175 if (handler_)
568 handler_->SendFailedToGetPrinterCapabilities(printer_name); 176 handler_->SendFailedToGetPrinterCapabilities(printer_name);
569 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698