OLD | NEW |
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 "base/strings/string_number_conversions.h" |
7 #include "components/cloud_devices/common/printer_description.h" | 8 #include "components/cloud_devices/common/printer_description.h" |
8 #include "printing/backend/win_helper.h" | 9 #include "printing/backend/win_helper.h" |
9 | 10 |
10 namespace cloud_print { | 11 namespace cloud_print { |
11 | 12 |
12 bool IsValidCjt(const std::string& print_ticket_data) { | 13 bool IsValidCjt(const std::string& print_ticket_data) { |
13 cloud_devices::CloudDeviceDescription description; | 14 cloud_devices::CloudDeviceDescription description; |
14 return description.InitFromString(print_ticket_data); | 15 return description.InitFromString(print_ticket_data); |
15 } | 16 } |
16 | 17 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 105 |
105 if (collate.LoadFrom(description)) { | 106 if (collate.LoadFrom(description)) { |
106 dev_mode->dmFields |= DM_COLLATE; | 107 dev_mode->dmFields |= DM_COLLATE; |
107 dev_mode->dmCollate = (collate.value() ? DMCOLLATE_TRUE : DMCOLLATE_FALSE); | 108 dev_mode->dmCollate = (collate.value() ? DMCOLLATE_TRUE : DMCOLLATE_FALSE); |
108 } | 109 } |
109 | 110 |
110 if (media.LoadFrom(description)) { | 111 if (media.LoadFrom(description)) { |
111 static const size_t kFromUm = 100; // Windows uses 0.1mm. | 112 static const size_t kFromUm = 100; // Windows uses 0.1mm. |
112 int width = media.value().width_um / kFromUm; | 113 int width = media.value().width_um / kFromUm; |
113 int height = media.value().height_um / kFromUm; | 114 int height = media.value().height_um / kFromUm; |
114 if (width > 0) { | 115 unsigned id = 0; |
| 116 if (base::StringToUint(media.value().vendor_id, &id) && id) { |
| 117 dev_mode->dmFields |= DM_PAPERSIZE; |
| 118 dev_mode->dmPaperSize = static_cast<short>(id); |
| 119 } else if (width > 0 && height > 0) { |
115 dev_mode->dmFields |= DM_PAPERWIDTH; | 120 dev_mode->dmFields |= DM_PAPERWIDTH; |
116 dev_mode->dmPaperWidth = width; | 121 dev_mode->dmPaperWidth = width; |
117 } | |
118 if (height > 0) { | |
119 dev_mode->dmFields |= DM_PAPERLENGTH; | 122 dev_mode->dmFields |= DM_PAPERLENGTH; |
120 dev_mode->dmPaperLength = height; | 123 dev_mode->dmPaperLength = height; |
121 } | 124 } |
122 } | 125 } |
123 | 126 |
124 return printing::CreateDevMode(printer, dev_mode.get()); | 127 return printing::CreateDevMode(printer, dev_mode.get()); |
125 } | 128 } |
126 | 129 |
127 } // namespace cloud_print | 130 } // namespace cloud_print |
OLD | NEW |