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

Unified Diff: printing/backend/print_backend_win.cc

Issue 7087011: Printing: Add ability to get the default printer from the print backend. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address comments Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « printing/backend/print_backend_cups.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/backend/print_backend_win.cc
===================================================================
--- printing/backend/print_backend_win.cc (revision 87186)
+++ printing/backend/print_backend_win.cc (working copy)
@@ -42,6 +42,8 @@
virtual bool EnumeratePrinters(PrinterList* printer_list);
+ virtual std::string GetDefaultPrinterName();
+
virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name,
PrinterCapsAndDefaults* printer_info);
@@ -64,19 +66,13 @@
if (!ret)
return false;
- // Getting the name of the default printer.
- DWORD size = MAX_PATH;
- TCHAR default_printer_name[MAX_PATH];
- BOOL default_printer_exists = ::GetDefaultPrinter(
- default_printer_name, &size);
-
+ std::string default_printer = GetDefaultPrinterName();
PRINTER_INFO_2* printer_info =
reinterpret_cast<PRINTER_INFO_2*>(printer_info_buffer.get());
for (DWORD index = 0; index < count_returned; index++) {
PrinterBasicInfo info;
info.printer_name = WideToUTF8(printer_info[index].pPrinterName);
- if (default_printer_exists)
- info.is_default = (info.printer_name == WideToUTF8(default_printer_name));
+ info.is_default = (info.printer_name == default_printer);
if (printer_info[index].pComment)
info.printer_description = WideToUTF8(printer_info[index].pComment);
info.printer_status = printer_info[index].Status;
@@ -91,6 +87,14 @@
return true;
}
+std::string PrintBackendWin::GetDefaultPrinterName() {
+ DWORD size = MAX_PATH;
+ TCHAR default_printer_name[MAX_PATH];
+ if (!::GetDefaultPrinter(default_printer_name, &size))
+ return std::string();
+ return WideToUTF8(default_printer_name);
+}
+
bool PrintBackendWin::GetPrinterCapsAndDefaults(
const std::string& printer_name,
PrinterCapsAndDefaults* printer_info) {
« no previous file with comments | « printing/backend/print_backend_cups.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698