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

Side by Side Diff: printing/backend/print_backend_win.cc

Issue 334763002: Add paper size reporting for CUPS printers (to let user to select one in the Print Preview). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test for PPD page size extraction, log error on PPD file opening, address other cl comment… Created 6 years, 6 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 | « printing/backend/print_backend.h ('k') | 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 "printing/backend/print_backend.h" 5 #include "printing/backend/print_backend.h"
6 6
7 #include <objidl.h> 7 #include <objidl.h>
8 #include <winspool.h> 8 #include <winspool.h>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 names.clear(); 86 names.clear();
87 87
88 for (size_t i = 0; i < sizes.size(); ++i) { 88 for (size_t i = 0; i < sizes.size(); ++i) {
89 PrinterSemanticCapsAndDefaults::Paper paper; 89 PrinterSemanticCapsAndDefaults::Paper paper;
90 paper.size_um.SetSize(sizes[i].x * kToUm, sizes[i].y * kToUm); 90 paper.size_um.SetSize(sizes[i].x * kToUm, sizes[i].y * kToUm);
91 if (!names.empty()) { 91 if (!names.empty()) {
92 const wchar_t* name_start = names[i].chars; 92 const wchar_t* name_start = names[i].chars;
93 base::string16 tmp_name(name_start, kMaxPaperName); 93 base::string16 tmp_name(name_start, kMaxPaperName);
94 // Trim trailing zeros. 94 // Trim trailing zeros.
95 tmp_name = tmp_name.c_str(); 95 tmp_name = tmp_name.c_str();
96 paper.name = base::WideToUTF8(tmp_name); 96 paper.display_name = base::WideToUTF8(tmp_name);
97 } 97 }
98 caps->papers.push_back(paper); 98 caps->papers.push_back(paper);
99 } 99 }
100 100
101 if (devmode) { 101 if (devmode) {
102 short default_id = 0; 102 short default_id = 0;
103 gfx::Size default_size; 103 gfx::Size default_size;
104 104
105 if (devmode->dmFields & DM_PAPERSIZE) 105 if (devmode->dmFields & DM_PAPERSIZE)
106 default_id = devmode->dmPaperSize; 106 default_id = devmode->dmPaperSize;
107 if (devmode->dmFields & DM_PAPERWIDTH) 107 if (devmode->dmFields & DM_PAPERWIDTH)
108 default_size.set_width(devmode->dmPaperWidth * kToUm); 108 default_size.set_width(devmode->dmPaperWidth * kToUm);
109 if (devmode->dmFields & DM_PAPERLENGTH) 109 if (devmode->dmFields & DM_PAPERLENGTH)
110 default_size.set_height(devmode->dmPaperLength * kToUm); 110 default_size.set_height(devmode->dmPaperLength * kToUm);
111 111
112 if (default_size.IsEmpty()) { 112 if (default_size.IsEmpty()) {
113 for (size_t i = 0; i < ids.size(); ++i) { 113 for (size_t i = 0; i < ids.size(); ++i) {
114 if (ids[i] == default_id) { 114 if (ids[i] == default_id) {
115 PrinterSemanticCapsAndDefaults::Paper paper; 115 PrinterSemanticCapsAndDefaults::Paper paper;
116 paper.size_um.SetSize(sizes[i].x * kToUm, sizes[i].y * kToUm); 116 paper.size_um.SetSize(sizes[i].x * kToUm, sizes[i].y * kToUm);
117 if (!names.empty()) { 117 if (!names.empty()) {
118 const wchar_t* name_start = names[i].chars; 118 const wchar_t* name_start = names[i].chars;
119 base::string16 tmp_name(name_start, kMaxPaperName); 119 base::string16 tmp_name(name_start, kMaxPaperName);
120 // Trim trailing zeros. 120 // Trim trailing zeros.
121 tmp_name = tmp_name.c_str(); 121 tmp_name = tmp_name.c_str();
122 paper.name = base::WideToUTF8(tmp_name); 122 paper.display_name = base::WideToUTF8(tmp_name);
123 } 123 }
124 caps->default_paper = paper; 124 caps->default_paper = paper;
125 break; 125 break;
126 } 126 }
127 } 127 }
128 } else { 128 } else {
129 caps->default_paper.size_um = default_size; 129 caps->default_paper.size_um = default_size;
130 } 130 }
131 } 131 }
132 } 132 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ScopedPrinterHandle printer_handle; 363 ScopedPrinterHandle printer_handle;
364 return printer_handle.OpenPrinter(base::UTF8ToWide(printer_name).c_str()); 364 return printer_handle.OpenPrinter(base::UTF8ToWide(printer_name).c_str());
365 } 365 }
366 366
367 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( 367 scoped_refptr<PrintBackend> PrintBackend::CreateInstance(
368 const base::DictionaryValue* print_backend_settings) { 368 const base::DictionaryValue* print_backend_settings) {
369 return new PrintBackendWin; 369 return new PrintBackendWin;
370 } 370 }
371 371
372 } // namespace printing 372 } // namespace printing
OLDNEW
« no previous file with comments | « printing/backend/print_backend.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698