OLD | NEW |
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 "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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 HANDLE printer_handle = NULL; | 135 HANDLE printer_handle = NULL; |
136 OpenPrinter(const_cast<LPTSTR>(printer_name_wide.c_str()), &printer_handle, | 136 OpenPrinter(const_cast<LPTSTR>(printer_name_wide.c_str()), &printer_handle, |
137 NULL); | 137 NULL); |
138 DCHECK(printer_handle); | 138 DCHECK(printer_handle); |
139 if (printer_handle) { | 139 if (printer_handle) { |
140 LONG devmode_size = DocumentProperties( | 140 LONG devmode_size = DocumentProperties( |
141 NULL, printer_handle, const_cast<LPTSTR>(printer_name_wide.c_str()), | 141 NULL, printer_handle, const_cast<LPTSTR>(printer_name_wide.c_str()), |
142 NULL, NULL, 0); | 142 NULL, NULL, 0); |
143 if (devmode_size <= 0) | 143 if (devmode_size <= 0) |
144 return false; | 144 return false; |
145 scoped_ptr<BYTE> devmode_out_buffer(new BYTE[devmode_size]); | 145 scoped_array<BYTE> devmode_out_buffer(new BYTE[devmode_size]); |
146 DEVMODE* devmode_out = | 146 DEVMODE* devmode_out = |
147 reinterpret_cast<DEVMODE*>(devmode_out_buffer.get()); | 147 reinterpret_cast<DEVMODE*>(devmode_out_buffer.get()); |
148 DocumentProperties( | 148 DocumentProperties( |
149 NULL, printer_handle, const_cast<LPTSTR>(printer_name_wide.c_str()), | 149 NULL, printer_handle, const_cast<LPTSTR>(printer_name_wide.c_str()), |
150 devmode_out, NULL, DM_OUT_BUFFER); | 150 devmode_out, NULL, DM_OUT_BUFFER); |
151 base::win::ScopedComPtr<IStream> printer_defaults_stream; | 151 base::win::ScopedComPtr<IStream> printer_defaults_stream; |
152 hr = CreateStreamOnHGlobal(NULL, TRUE, | 152 hr = CreateStreamOnHGlobal(NULL, TRUE, |
153 printer_defaults_stream.Receive()); | 153 printer_defaults_stream.Receive()); |
154 DCHECK(SUCCEEDED(hr)); | 154 DCHECK(SUCCEEDED(hr)); |
155 if (printer_defaults_stream) { | 155 if (printer_defaults_stream) { |
(...skipping 29 matching lines...) Expand all Loading... |
185 } | 185 } |
186 return ret; | 186 return ret; |
187 } | 187 } |
188 | 188 |
189 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( | 189 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( |
190 const base::DictionaryValue* print_backend_settings) { | 190 const base::DictionaryValue* print_backend_settings) { |
191 return new PrintBackendWin; | 191 return new PrintBackendWin; |
192 } | 192 } |
193 | 193 |
194 } // namespace printing | 194 } // namespace printing |
OLD | NEW |