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

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

Issue 7741003: Printing Backend: Check the results from a DocumentProperties() call. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | « no previous file | 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) 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 &printer_info->printer_capabilities); 130 &printer_info->printer_capabilities);
131 DCHECK(SUCCEEDED(hr)); 131 DCHECK(SUCCEEDED(hr));
132 printer_info->caps_mime_type = "text/xml"; 132 printer_info->caps_mime_type = "text/xml";
133 } 133 }
134 // TODO(sanjeevr): Add ScopedPrinterHandle 134 // TODO(sanjeevr): Add ScopedPrinterHandle
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 DWORD 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 DCHECK_NE(0U, devmode_size); 143 if (devmode_size <= 0)
144 return false;
144 scoped_ptr<BYTE> devmode_out_buffer(new BYTE[devmode_size]); 145 scoped_ptr<BYTE> devmode_out_buffer(new BYTE[devmode_size]);
145 DEVMODE* devmode_out = 146 DEVMODE* devmode_out =
146 reinterpret_cast<DEVMODE*>(devmode_out_buffer.get()); 147 reinterpret_cast<DEVMODE*>(devmode_out_buffer.get());
147 DocumentProperties( 148 DocumentProperties(
148 NULL, printer_handle, const_cast<LPTSTR>(printer_name_wide.c_str()), 149 NULL, printer_handle, const_cast<LPTSTR>(printer_name_wide.c_str()),
149 devmode_out, NULL, DM_OUT_BUFFER); 150 devmode_out, NULL, DM_OUT_BUFFER);
150 base::win::ScopedComPtr<IStream> printer_defaults_stream; 151 base::win::ScopedComPtr<IStream> printer_defaults_stream;
151 hr = CreateStreamOnHGlobal(NULL, TRUE, 152 hr = CreateStreamOnHGlobal(NULL, TRUE,
152 printer_defaults_stream.Receive()); 153 printer_defaults_stream.Receive());
153 DCHECK(SUCCEEDED(hr)); 154 DCHECK(SUCCEEDED(hr));
(...skipping 30 matching lines...) Expand all
184 } 185 }
185 return ret; 186 return ret;
186 } 187 }
187 188
188 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( 189 scoped_refptr<PrintBackend> PrintBackend::CreateInstance(
189 const base::DictionaryValue* print_backend_settings) { 190 const base::DictionaryValue* print_backend_settings) {
190 return new PrintBackendWin; 191 return new PrintBackendWin;
191 } 192 }
192 193
193 } // namespace printing 194 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698