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

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: Addressed review comments Created 9 years, 2 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) 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>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/i18n/file_util_icu.h" 15 #include "base/i18n/file_util_icu.h"
16 #include "base/json/json_reader.h" 16 #include "base/json/json_reader.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/string_split.h"
21 #include "base/string_util.h"
22 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
23 #include "base/threading/thread_restrictions.h" 21 #include "base/threading/thread_restrictions.h"
24 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
25 #include "base/values.h" 23 #include "base/values.h"
26 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
27 #include "chrome/browser/platform_util.h" 25 #include "chrome/browser/platform_util.h"
28 #include "chrome/browser/printing/background_printing_manager.h" 26 #include "chrome/browser/printing/background_printing_manager.h"
29 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" 27 #include "chrome/browser/printing/cloud_print/cloud_print_url.h"
30 #include "chrome/browser/printing/print_dialog_cloud.h" 28 #include "chrome/browser/printing/print_dialog_cloud.h"
31 #include "chrome/browser/printing/print_job_manager.h" 29 #include "chrome/browser/printing/print_job_manager.h"
32 #include "chrome/browser/printing/print_preview_tab_controller.h" 30 #include "chrome/browser/printing/print_preview_tab_controller.h"
31 #include "chrome/browser/printing/print_system_task_proxy.h"
33 #include "chrome/browser/printing/print_view_manager.h" 32 #include "chrome/browser/printing/print_view_manager.h"
34 #include "chrome/browser/printing/printer_manager_dialog.h" 33 #include "chrome/browser/printing/printer_manager_dialog.h"
35 #include "chrome/browser/sessions/restore_tab_helper.h" 34 #include "chrome/browser/sessions/restore_tab_helper.h"
36 #include "chrome/browser/tabs/tab_strip_model.h" 35 #include "chrome/browser/tabs/tab_strip_model.h"
37 #include "chrome/browser/ui/browser_list.h" 36 #include "chrome/browser/ui/browser_list.h"
38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
39 #include "chrome/browser/ui/webui/cloud_print_signin_dialog.h" 38 #include "chrome/browser/ui/webui/cloud_print_signin_dialog.h"
40 #include "chrome/browser/ui/webui/print_preview_ui.h" 39 #include "chrome/browser/ui/webui/print_preview_ui.h"
41 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
42 #include "chrome/common/print_messages.h" 41 #include "chrome/common/print_messages.h"
43 #include "content/browser/browser_thread.h" 42 #include "content/browser/browser_thread.h"
44 #include "content/browser/renderer_host/render_view_host.h" 43 #include "content/browser/renderer_host/render_view_host.h"
45 #include "content/browser/tab_contents/tab_contents.h" 44 #include "content/browser/tab_contents/tab_contents.h"
46 #include "printing/backend/print_backend.h" 45 #include "printing/backend/print_backend.h"
47 #include "printing/metafile.h" 46 #include "printing/metafile.h"
48 #include "printing/metafile_impl.h" 47 #include "printing/metafile_impl.h"
49 #include "printing/page_range.h" 48 #include "printing/page_range.h"
50 #include "printing/print_job_constants.h" 49 #include "printing/print_settings.h"
51
52 #if defined(USE_CUPS)
53 #include <cups/cups.h>
54 #include <cups/ppd.h>
55
56 #include "base/file_util.h"
57 #endif
58 50
59 #if !defined(OS_CHROMEOS) 51 #if !defined(OS_CHROMEOS)
60 #include "base/command_line.h" 52 #include "base/command_line.h"
61 #include "chrome/common/chrome_switches.h" 53 #include "chrome/common/chrome_switches.h"
62 #endif 54 #endif
63 55
64 #if defined(USE_CUPS) && !defined(OS_MACOSX)
65 namespace printing_internal {
66
67 void parse_lpoptions(const FilePath& filepath, const std::string& printer_name,
68 int* num_options, cups_option_t** options) {
69 std::string content;
70 if (!file_util::ReadFileToString(filepath, &content))
71 return;
72
73 const char kDest[] = "dest";
74 const char kDefault[] = "default";
75 size_t kDestLen = sizeof(kDest) - 1;
76 size_t kDefaultLen = sizeof(kDefault) - 1;
77 std::vector <std::string> lines;
78 base::SplitString(content, '\n', &lines);
79
80 for (size_t i = 0; i < lines.size(); ++i) {
81 std::string line = lines[i];
82 if (line.empty())
83 continue;
84
85 if (base::strncasecmp (line.c_str(), kDefault, kDefaultLen) == 0 &&
86 isspace(line[kDefaultLen])) {
87 line = line.substr(kDefaultLen);
88 } else if (base::strncasecmp (line.c_str(), kDest, kDestLen) == 0 &&
89 isspace(line[kDestLen])) {
90 line = line.substr(kDestLen);
91 } else {
92 continue;
93 }
94
95 TrimWhitespaceASCII(line, TRIM_ALL, &line);
96 if (line.empty())
97 continue;
98
99 size_t space_found = line.find(' ');
100 if (space_found == std::string::npos)
101 continue;
102
103 std::string name = line.substr(0, space_found);
104 if (name.empty())
105 continue;
106
107 if (base::strncasecmp(printer_name.c_str(), name.c_str(),
108 name.length()) != 0) {
109 continue; // This is not the required printer.
110 }
111
112 line = line.substr(space_found + 1);
113 TrimWhitespaceASCII(line, TRIM_ALL, &line); // Remove extra spaces.
114 if (line.empty())
115 continue;
116 // Parse the selected printer custom options.
117 *num_options = cupsParseOptions(line.c_str(), 0, options);
118 }
119 }
120
121 void mark_lpoptions(const std::string& printer_name, ppd_file_t** ppd) {
122 cups_option_t* options = NULL;
123 int num_options = 0;
124 ppdMarkDefaults(*ppd);
125
126 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions";
127 const char kUserLpOptionPath[] = ".cups/lpoptions";
128
129 std::vector<FilePath> file_locations;
130 file_locations.push_back(FilePath(kSystemLpOptionPath));
131 file_locations.push_back(file_util::GetHomeDir().Append(kUserLpOptionPath));
132
133 for (std::vector<FilePath>::const_iterator it = file_locations.begin();
134 it != file_locations.end(); ++it) {
135 num_options = 0;
136 options = NULL;
137 parse_lpoptions(*it, printer_name, &num_options, &options);
138 if (num_options > 0 && options) {
139 cupsMarkOptions(*ppd, num_options, options);
140 cupsFreeOptions(num_options, options);
141 }
142 }
143 }
144
145 } // printing_internal namespace
146 #endif
147
148 namespace { 56 namespace {
149 57
150 const char kDisableColorOption[] = "disableColorOption";
151 const char kSetColorAsDefault[] = "setColorAsDefault";
152 const char kSetDuplexAsDefault[] = "setDuplexAsDefault";
153 const char kPrinterColorModelForColor[] = "printerColorModelForColor";
154 const char kPrinterDefaultDuplexValue[] = "printerDefaultDuplexValue";
155
156 #if defined(USE_CUPS)
157 const char kColorDevice[] = "ColorDevice";
158 const char kColorModel[] = "ColorModel";
159 const char kColorModelForColor[] = "Color";
160 const char kCMYK[] = "CMYK";
161 const char kDuplex[] = "Duplex";
162 const char kDuplexNone[] = "None";
163 #elif defined(OS_WIN)
164 const char kPskColor[] = "psk:Color";
165 const char kPskDuplexFeature[] = "psk:JobDuplexAllDocumentsContiguously";
166 const char kPskTwoSided[] = "psk:TwoSided";
167 #endif
168
169 enum UserActionBuckets { 58 enum UserActionBuckets {
170 PRINT_TO_PRINTER, 59 PRINT_TO_PRINTER,
171 PRINT_TO_PDF, 60 PRINT_TO_PDF,
172 CANCEL, 61 CANCEL,
173 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG, 62 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
174 PREVIEW_FAILED, 63 PREVIEW_FAILED,
175 PREVIEW_STARTED, 64 PREVIEW_STARTED,
176 INITIATOR_TAB_CRASHED, 65 INITIATOR_TAB_CRASHED,
177 INITIATOR_TAB_CLOSED, 66 INITIATOR_TAB_CLOSED,
178 PRINT_WITH_CLOUD_PRINT, 67 PRINT_WITH_CLOUD_PRINT,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 bool collate; 145 bool collate;
257 if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate) 146 if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate)
258 ReportPrintSettingHistogram(COLLATE); 147 ReportPrintSettingHistogram(COLLATE);
259 148
260 int duplex_mode; 149 int duplex_mode;
261 if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode)) 150 if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))
262 ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX); 151 ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX);
263 152
264 int color_mode; 153 int color_mode;
265 if (settings.GetInteger(printing::kSettingColor, &color_mode)) { 154 if (settings.GetInteger(printing::kSettingColor, &color_mode)) {
266 ReportPrintSettingHistogram(color_mode == printing::GRAY ? BLACK_AND_WHITE : 155 ReportPrintSettingHistogram(
267 COLOR); 156 printing::isColorModelSelected(color_mode) ? COLOR : BLACK_AND_WHITE);
268 } 157 }
269 } 158 }
270 159
271 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { 160 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() {
272 return g_browser_process->background_printing_manager(); 161 return g_browser_process->background_printing_manager();
273 } 162 }
274 163
275 } // namespace 164 } // namespace
276 165
277 class PrintSystemTaskProxy
278 : public base::RefCountedThreadSafe<PrintSystemTaskProxy,
279 BrowserThread::DeleteOnUIThread> {
280 public:
281 PrintSystemTaskProxy(const base::WeakPtr<PrintPreviewHandler>& handler,
282 printing::PrintBackend* print_backend,
283 bool has_logged_printers_count)
284 : handler_(handler),
285 print_backend_(print_backend),
286 has_logged_printers_count_(has_logged_printers_count) {
287 }
288
289 void GetDefaultPrinter() {
290 VLOG(1) << "Get default printer start";
291 StringValue* default_printer = NULL;
292 if (PrintPreviewHandler::last_used_printer_name_ == NULL) {
293 default_printer = new StringValue(
294 print_backend_->GetDefaultPrinterName());
295 } else {
296 default_printer = new StringValue(
297 *PrintPreviewHandler::last_used_printer_name_);
298 }
299 std::string default_printer_string;
300 default_printer->GetAsString(&default_printer_string);
301 VLOG(1) << "Get default printer finished, found: "
302 << default_printer_string;
303
304 StringValue* cloud_print_data = NULL;
305 if (PrintPreviewHandler::last_used_printer_cloud_print_data_ != NULL) {
306 cloud_print_data = new StringValue(
307 *PrintPreviewHandler::last_used_printer_cloud_print_data_);
308 } else {
309 cloud_print_data = new StringValue("");
310 }
311
312 BrowserThread::PostTask(
313 BrowserThread::UI, FROM_HERE,
314 base::Bind(&PrintSystemTaskProxy::SendDefaultPrinter, this,
315 default_printer, cloud_print_data));
316 }
317
318 void SendDefaultPrinter(const StringValue* default_printer,
319 const StringValue* cloud_print_data) {
320 if (handler_)
321 handler_->SendDefaultPrinter(*default_printer, *cloud_print_data);
322 delete default_printer;
323 }
324
325 void EnumeratePrinters() {
326 VLOG(1) << "Enumerate printers start";
327 ListValue* printers = new ListValue;
328
329 printing::PrinterList printer_list;
330 print_backend_->EnumeratePrinters(&printer_list);
331
332 if (!has_logged_printers_count_) {
333 // Record the total number of printers.
334 UMA_HISTOGRAM_COUNTS("PrintPreview.NumberOfPrinters",
335 printer_list.size());
336 }
337
338 int i = 0;
339 for (printing::PrinterList::iterator iter = printer_list.begin();
340 iter != printer_list.end(); ++iter, ++i) {
341 DictionaryValue* printer_info = new DictionaryValue;
342 std::string printerName;
343 #if defined(OS_MACOSX)
344 // On Mac, |iter->printer_description| specifies the printer name and
345 // |iter->printer_name| specifies the device name / printer queue name.
346 printerName = iter->printer_description;
347 #else
348 printerName = iter->printer_name;
349 #endif
350 printer_info->SetString(printing::kSettingPrinterName, printerName);
351 printer_info->SetString(printing::kSettingDeviceName, iter->printer_name);
352 printers->Append(printer_info);
353 }
354 VLOG(1) << "Enumerate printers finished, found " << i << " printers";
355
356 BrowserThread::PostTask(
357 BrowserThread::UI, FROM_HERE,
358 base::Bind(&PrintSystemTaskProxy::SetupPrinterList, this, printers));
359 }
360
361 void SetupPrinterList(ListValue* printers) {
362 if (handler_) {
363 handler_->SetupPrinterList(*printers);
364 }
365 delete printers;
366 }
367
368 void GetPrinterCapabilities(const std::string& printer_name) {
369 VLOG(1) << "Get printer capabilities start for " << printer_name;
370 printing::PrinterCapsAndDefaults printer_info;
371 bool supports_color = true;
372 bool set_duplex_as_default = false;
373 int printer_color_space = printing::GRAY;
374 int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE;
375 if (!print_backend_->GetPrinterCapsAndDefaults(printer_name,
376 &printer_info)) {
377 return;
378 }
379
380 #if defined(USE_CUPS)
381 FilePath ppd_file_path;
382 if (!file_util::CreateTemporaryFile(&ppd_file_path))
383 return;
384
385 int data_size = printer_info.printer_capabilities.length();
386 if (data_size != file_util::WriteFile(
387 ppd_file_path,
388 printer_info.printer_capabilities.data(),
389 data_size)) {
390 file_util::Delete(ppd_file_path, false);
391 return;
392 }
393
394 ppd_file_t* ppd = ppdOpenFile(ppd_file_path.value().c_str());
395 if (ppd) {
396 #if !defined(OS_MACOSX)
397 printing_internal::mark_lpoptions(printer_name, &ppd);
398 #endif
399 ppd_attr_t* attr = ppdFindAttr(ppd, kColorDevice, NULL);
400 if (attr && attr->value)
401 supports_color = ppd->color_device;
402
403 ppd_choice_t* duplex_choice = ppdFindMarkedChoice(ppd, kDuplex);
404 if (duplex_choice) {
405 ppd_option_t* option = ppdFindOption(ppd, kDuplex);
406 if (option)
407 duplex_choice = ppdFindChoice(option, option->defchoice);
408 }
409
410 if (duplex_choice) {
411 if (base::strcasecmp(duplex_choice->choice, kDuplexNone) != 0) {
412 set_duplex_as_default = true;
413 default_duplex_setting_value = printing::LONG_EDGE;
414 } else {
415 default_duplex_setting_value = printing::SIMPLEX;
416 }
417 }
418
419 if (supports_color) {
420 // Identify the color space (COLOR/CMYK) for this printer.
421 ppd_option_t* color_model = ppdFindOption(ppd, kColorModel);
422 if (color_model) {
423 if (ppdFindChoice(color_model, kColorModelForColor))
424 printer_color_space = printing::COLOR;
425 else if (ppdFindChoice(color_model, kCMYK))
426 printer_color_space = printing::CMYK;
427 }
428 }
429 ppdClose(ppd);
430 }
431 file_util::Delete(ppd_file_path, false);
432 #elif defined(OS_WIN)
433 // According to XPS 1.0 spec, only color printers have psk:Color.
434 // Therefore we don't need to parse the whole XML file, we just need to
435 // search the string. The spec can be found at:
436 // http://msdn.microsoft.com/en-us/windows/hardware/gg463431.
437 supports_color = (printer_info.printer_capabilities.find(kPskColor) !=
438 std::string::npos);
439 if (supports_color)
440 printer_color_space = printing::COLOR;
441
442 set_duplex_as_default =
443 (printer_info.printer_defaults.find(kPskDuplexFeature) !=
444 std::string::npos) &&
445 (printer_info.printer_defaults.find(kPskTwoSided) !=
446 std::string::npos);
447
448 if (printer_info.printer_defaults.find(kPskDuplexFeature) !=
449 std::string::npos) {
450 if (printer_info.printer_defaults.find(kPskTwoSided) !=
451 std::string::npos) {
452 default_duplex_setting_value = printing::LONG_EDGE;
453 } else {
454 default_duplex_setting_value = printing::SIMPLEX;
455 }
456 }
457 #else
458 NOTIMPLEMENTED();
459 #endif
460
461 DictionaryValue settings_info;
462 settings_info.SetBoolean(kDisableColorOption, !supports_color);
463 if (!supports_color) {
464 settings_info.SetBoolean(kSetColorAsDefault, false);
465 } else {
466 settings_info.SetBoolean(kSetColorAsDefault,
467 PrintPreviewHandler::last_used_color_setting_);
468 }
469 settings_info.SetBoolean(kSetDuplexAsDefault, set_duplex_as_default);
470 settings_info.SetInteger(kPrinterColorModelForColor, printer_color_space);
471 settings_info.SetInteger(kPrinterDefaultDuplexValue,
472 default_duplex_setting_value);
473 BrowserThread::PostTask(
474 BrowserThread::UI, FROM_HERE,
475 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this,
476 settings_info.DeepCopy()));
477 }
478
479 void SendPrinterCapabilities(DictionaryValue* settings_info) {
480 if (handler_)
481 handler_->SendPrinterCapabilities(*settings_info);
482 delete settings_info;
483 }
484
485 private:
486 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
487 friend class DeleteTask<PrintSystemTaskProxy>;
488
489 ~PrintSystemTaskProxy() {}
490
491 base::WeakPtr<PrintPreviewHandler> handler_;
492
493 scoped_refptr<printing::PrintBackend> print_backend_;
494
495 bool has_logged_printers_count_;
496
497 DISALLOW_COPY_AND_ASSIGN(PrintSystemTaskProxy);
498 };
499
500 // A Task implementation that stores a PDF file on disk. 166 // A Task implementation that stores a PDF file on disk.
501 class PrintToPdfTask : public Task { 167 class PrintToPdfTask : public Task {
502 public: 168 public:
503 // Takes ownership of |metafile|. 169 // Takes ownership of |metafile|.
504 PrintToPdfTask(printing::Metafile* metafile, const FilePath& path) 170 PrintToPdfTask(printing::Metafile* metafile, const FilePath& path)
505 : metafile_(metafile), path_(path) { 171 : metafile_(metafile), path_(path) {
506 DCHECK(metafile); 172 DCHECK(metafile);
507 } 173 }
508 174
509 ~PrintToPdfTask() { 175 ~PrintToPdfTask() {
(...skipping 12 matching lines...) Expand all
522 scoped_ptr<printing::Metafile> metafile_; 188 scoped_ptr<printing::Metafile> metafile_;
523 189
524 // The absolute path where the file will be saved. 190 // The absolute path where the file will be saved.
525 FilePath path_; 191 FilePath path_;
526 }; 192 };
527 193
528 // static 194 // static
529 FilePath* PrintPreviewHandler::last_saved_path_ = NULL; 195 FilePath* PrintPreviewHandler::last_saved_path_ = NULL;
530 std::string* PrintPreviewHandler::last_used_printer_cloud_print_data_ = NULL; 196 std::string* PrintPreviewHandler::last_used_printer_cloud_print_data_ = NULL;
531 std::string* PrintPreviewHandler::last_used_printer_name_ = NULL; 197 std::string* PrintPreviewHandler::last_used_printer_name_ = NULL;
532 bool PrintPreviewHandler::last_used_color_setting_ = false; 198 printing::ColorModels PrintPreviewHandler::last_used_color_model_ =
199 printing::UNKNOWN_COLOR_MODEL;
533 200
534 PrintPreviewHandler::PrintPreviewHandler() 201 PrintPreviewHandler::PrintPreviewHandler()
535 : print_backend_(printing::PrintBackend::CreateInstance(NULL)), 202 : print_backend_(printing::PrintBackend::CreateInstance(NULL)),
536 regenerate_preview_request_count_(0), 203 regenerate_preview_request_count_(0),
537 manage_printers_dialog_request_count_(0), 204 manage_printers_dialog_request_count_(0),
538 reported_failed_preview_(false), 205 reported_failed_preview_(false),
539 has_logged_printers_count_(false) { 206 has_logged_printers_count_(false) {
540 ReportUserActionHistogram(PREVIEW_STARTED); 207 ReportUserActionHistogram(PREVIEW_STARTED);
541 } 208 }
542 209
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 TabContentsWrapper* initiator_tab = GetInitiatorTab(); 370 TabContentsWrapper* initiator_tab = GetInitiatorTab();
704 if (initiator_tab) { 371 if (initiator_tab) {
705 RenderViewHost* rvh = initiator_tab->render_view_host(); 372 RenderViewHost* rvh = initiator_tab->render_view_host();
706 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id())); 373 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id()));
707 } 374 }
708 375
709 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 376 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
710 if (!settings.get()) 377 if (!settings.get())
711 return; 378 return;
712 379
713 // Storing last used color setting. 380 // Storing last used color model.
714 int color_mode; 381 int color_model;
715 if (!settings->GetInteger(printing::kSettingColor, &color_mode)) 382 if (!settings->GetInteger(printing::kSettingColor, &color_model))
716 color_mode = printing::GRAY; 383 color_model = printing::GRAY;
717 last_used_color_setting_ = (color_mode != printing::GRAY); 384 last_used_color_model_ = static_cast<printing::ColorModels>(color_model);
718 385
719 bool print_to_pdf = false; 386 bool print_to_pdf = false;
720 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); 387 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
721 388
722 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); 389 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
723 390
724 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId); 391 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId);
725 bool is_cloud_dialog = false; 392 bool is_cloud_dialog = false;
726 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog); 393 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog);
727 if (is_cloud_printer) { 394 if (is_cloud_printer) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 return; 829 return;
1163 830
1164 // We no longer require the initiator tab details. Remove those details 831 // We no longer require the initiator tab details. Remove those details
1165 // associated with the preview tab to allow the initiator tab to create 832 // associated with the preview tab to allow the initiator tab to create
1166 // another preview tab. 833 // another preview tab.
1167 printing::PrintPreviewTabController* tab_controller = 834 printing::PrintPreviewTabController* tab_controller =
1168 printing::PrintPreviewTabController::GetInstance(); 835 printing::PrintPreviewTabController::GetInstance();
1169 if (tab_controller) 836 if (tab_controller)
1170 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); 837 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper());
1171 } 838 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/browser/ui/webui/print_preview_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698