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

Side by Side Diff: chrome/service/cloud_print/cdd_conversion_win.cc

Issue 191913002: scoped_ptr<DEVMODE[]> replaced with scoped_ptr<DEVMODE, base::FreeDeleter>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service/cloud_print/cdd_conversion_win.h" 5 #include "chrome/service/cloud_print/cdd_conversion_win.h"
6 6
7 #include "components/cloud_devices/printer_description.h" 7 #include "components/cloud_devices/printer_description.h"
8 #include "printing/backend/print_backend.h" 8 #include "printing/backend/print_backend.h"
9 #include "printing/backend/win_helper.h" 9 #include "printing/backend/win_helper.h"
10 10
11 namespace cloud_print { 11 namespace cloud_print {
12 12
13 bool IsValidCjt(const std::string& print_ticket_data) { 13 bool IsValidCjt(const std::string& print_ticket_data) {
14 cloud_devices::CloudDeviceDescription description; 14 cloud_devices::CloudDeviceDescription description;
15 return description.InitFromString(print_ticket_data); 15 return description.InitFromString(print_ticket_data);
16 } 16 }
17 17
18 scoped_ptr<DEVMODE[]> CjtToDevMode(const base::string16& printer_name, 18 scoped_ptr<DEVMODE, base::FreeDeleter> CjtToDevMode(
19 const std::string& print_ticket) { 19 const base::string16& printer_name,
20 using namespace cloud_devices::printer; 20 const std::string& print_ticket) {
21 scoped_ptr<DEVMODE, base::FreeDeleter> dev_mode;
22
21 cloud_devices::CloudDeviceDescription description; 23 cloud_devices::CloudDeviceDescription description;
22 if (!description.InitFromString(print_ticket)) 24 if (!description.InitFromString(print_ticket))
23 return scoped_ptr<DEVMODE[]>(); 25 return dev_mode.Pass();
24 26
27 using namespace cloud_devices::printer;
25 printing::ScopedPrinterHandle printer; 28 printing::ScopedPrinterHandle printer;
26 if (!printer.OpenPrinter(printer_name.c_str())) 29 if (!printer.OpenPrinter(printer_name.c_str()))
27 return scoped_ptr<DEVMODE[]>(); 30 return dev_mode.Pass();
28 31
29 scoped_ptr<DEVMODE[]> scoped_dev_mode;
30 { 32 {
31 ColorTicketItem color; 33 ColorTicketItem color;
32 if (color.LoadFrom(description)) { 34 if (color.LoadFrom(description)) {
33 bool is_color = color.value().type == STANDARD_COLOR; 35 bool is_color = color.value().type == STANDARD_COLOR;
34 scoped_dev_mode = CreateDevModeWithColor(printer, printer_name, is_color); 36 dev_mode = CreateDevModeWithColor(printer, printer_name, is_color);
35 } else { 37 } else {
36 scoped_dev_mode = printing::CreateDevMode(printer, NULL); 38 dev_mode = printing::CreateDevMode(printer, NULL);
37 } 39 }
38 } 40 }
39 41
40 if (!scoped_dev_mode) 42 if (!dev_mode)
41 return scoped_ptr<DEVMODE[]>(); 43 return dev_mode.Pass();
42
43 DEVMODE* dev_mode = scoped_dev_mode.get();
44 44
45 ColorTicketItem color; 45 ColorTicketItem color;
46 DuplexTicketItem duplex; 46 DuplexTicketItem duplex;
47 OrientationTicketItem orientation; 47 OrientationTicketItem orientation;
48 MarginsTicketItem margins; 48 MarginsTicketItem margins;
49 DpiTicketItem dpi; 49 DpiTicketItem dpi;
50 FitToPageTicketItem fit_to_page; 50 FitToPageTicketItem fit_to_page;
51 MediaTicketItem media; 51 MediaTicketItem media;
52 CopiesTicketItem copies; 52 CopiesTicketItem copies;
53 PageRangeTicketItem page_range; 53 PageRangeTicketItem page_range;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (width > 0) { 115 if (width > 0) {
116 dev_mode->dmFields |= DM_PAPERWIDTH; 116 dev_mode->dmFields |= DM_PAPERWIDTH;
117 dev_mode->dmPaperWidth = width; 117 dev_mode->dmPaperWidth = width;
118 } 118 }
119 if (height > 0) { 119 if (height > 0) {
120 dev_mode->dmFields |= DM_PAPERLENGTH; 120 dev_mode->dmFields |= DM_PAPERLENGTH;
121 dev_mode->dmPaperLength = height; 121 dev_mode->dmPaperLength = height;
122 } 122 }
123 } 123 }
124 124
125 return printing::CreateDevMode(printer, dev_mode); 125 return printing::CreateDevMode(printer, dev_mode.get());
126 } 126 }
127 127
128 std::string CapabilitiesToCdd( 128 std::string CapabilitiesToCdd(
129 const printing::PrinterSemanticCapsAndDefaults& semantic_info) { 129 const printing::PrinterSemanticCapsAndDefaults& semantic_info) {
130 using namespace cloud_devices::printer; 130 using namespace cloud_devices::printer;
131 cloud_devices::CloudDeviceDescription description; 131 cloud_devices::CloudDeviceDescription description;
132 132
133 ContentTypesCapability content_types; 133 ContentTypesCapability content_types;
134 content_types.AddOption("application/pdf"); 134 content_types.AddOption("application/pdf");
135 content_types.SaveTo(&description); 135 content_types.SaveTo(&description);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 OrientationCapability orientation; 226 OrientationCapability orientation;
227 orientation.AddDefaultOption(PORTRAIT, true); 227 orientation.AddDefaultOption(PORTRAIT, true);
228 orientation.AddOption(LANDSCAPE); 228 orientation.AddOption(LANDSCAPE);
229 orientation.AddOption(AUTO_ORIENTATION); 229 orientation.AddOption(AUTO_ORIENTATION);
230 orientation.SaveTo(&description); 230 orientation.SaveTo(&description);
231 231
232 return description.ToString(); 232 return description.ToString();
233 } 233 }
234 234
235 } // namespace cloud_print 235 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cdd_conversion_win.h ('k') | chrome/service/cloud_print/print_system_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698