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

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

Issue 9720029: Fixed invalid return value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« 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) 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 <algorithm> 7 #include <algorithm>
8 #include <objidl.h> 8 #include <objidl.h>
9 #include <winspool.h> 9 #include <winspool.h>
10 10
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return true; 176 return true;
177 } 177 }
178 178
179 // Gets the information about driver for a specific printer. 179 // Gets the information about driver for a specific printer.
180 std::string PrintBackendWin::GetPrinterDriverInfo( 180 std::string PrintBackendWin::GetPrinterDriverInfo(
181 const std::string& printer_name) { 181 const std::string& printer_name) {
182 std::string driver_info; 182 std::string driver_info;
183 ScopedPrinterHandle printer_handle; 183 ScopedPrinterHandle printer_handle;
184 if (!::OpenPrinter(const_cast<LPTSTR>(UTF8ToWide(printer_name).c_str()), 184 if (!::OpenPrinter(const_cast<LPTSTR>(UTF8ToWide(printer_name).c_str()),
185 printer_handle.Receive(), NULL)) { 185 printer_handle.Receive(), NULL)) {
186 return false; 186 return driver_info;
187 } 187 }
188 DCHECK(printer_handle.IsValid()); 188 DCHECK(printer_handle.IsValid());
189 DWORD bytes_needed = 0; 189 DWORD bytes_needed = 0;
190 ::GetPrinterDriver(printer_handle, NULL, 6, NULL, 0, &bytes_needed); 190 ::GetPrinterDriver(printer_handle, NULL, 6, NULL, 0, &bytes_needed);
191 scoped_array<BYTE> driver_info_buffer(new BYTE[bytes_needed]); 191 scoped_array<BYTE> driver_info_buffer(new BYTE[bytes_needed]);
192 if (!bytes_needed || !driver_info_buffer.get()) 192 if (!bytes_needed || !driver_info_buffer.get())
193 return false; 193 return driver_info;
194 if (!::GetPrinterDriver(printer_handle, NULL, 6, driver_info_buffer.get(), 194 if (!::GetPrinterDriver(printer_handle, NULL, 6, driver_info_buffer.get(),
195 bytes_needed, &bytes_needed)) { 195 bytes_needed, &bytes_needed)) {
196 return false; 196 return driver_info;
197 } 197 }
198 if (!bytes_needed) 198 if (!bytes_needed)
199 return false; 199 return driver_info;
200 const DRIVER_INFO_6* driver_info_6 = 200 const DRIVER_INFO_6* driver_info_6 =
201 reinterpret_cast<DRIVER_INFO_6*>(driver_info_buffer.get()); 201 reinterpret_cast<DRIVER_INFO_6*>(driver_info_buffer.get());
202 202
203 std::string info[4]; 203 std::string info[4];
204 204
205 if (driver_info_6->pName) 205 if (driver_info_6->pName)
206 info[0] = WideToUTF8(driver_info_6->pName); 206 info[0] = WideToUTF8(driver_info_6->pName);
207 207
208 if (driver_info_6->pDriverPath) { 208 if (driver_info_6->pDriverPath) {
209 scoped_ptr<FileVersionInfo> version_info( 209 scoped_ptr<FileVersionInfo> version_info(
(...skipping 19 matching lines...) Expand all
229 printer_handle.Receive(), NULL); 229 printer_handle.Receive(), NULL);
230 return printer_handle.IsValid(); 230 return printer_handle.IsValid();
231 } 231 }
232 232
233 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( 233 scoped_refptr<PrintBackend> PrintBackend::CreateInstance(
234 const base::DictionaryValue* print_backend_settings) { 234 const base::DictionaryValue* print_backend_settings) {
235 return new PrintBackendWin; 235 return new PrintBackendWin;
236 } 236 }
237 237
238 } // namespace printing 238 } // 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