diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 00:43:47 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 00:43:47 +0000 |
commit | 07dacf1a6702797daf14acceeb1340aa22afb9ad (patch) | |
tree | d88971214f745f60041d69ecdc347e551704f295 /printing/backend | |
parent | ede52734454fe8513c43ebe11cf95c192d13d488 (diff) | |
download | chromium_src-07dacf1a6702797daf14acceeb1340aa22afb9ad.zip chromium_src-07dacf1a6702797daf14acceeb1340aa22afb9ad.tar.gz chromium_src-07dacf1a6702797daf14acceeb1340aa22afb9ad.tar.bz2 |
Preselecting default printer in print preview tab drop down list in Linux, Mac, Win.
BUG=76290
TEST=Set default printer. Open chrome with --enable-print-preview, hit ctrl+p, the default printer should appear selected in the drop-down list. Close the print preview tab. Change default printer and hit ctrl+p again. The new default printer should be selected.
Review URL: http://codereview.chromium.org/6670099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/backend')
-rw-r--r-- | printing/backend/print_backend.h | 1 | ||||
-rw-r--r-- | printing/backend/print_backend_cups.cc | 1 | ||||
-rw-r--r-- | printing/backend/print_backend_win.cc | 8 |
3 files changed, 10 insertions, 0 deletions
diff --git a/printing/backend/print_backend.h b/printing/backend/print_backend.h index 5147871..a6caa51 100644 --- a/printing/backend/print_backend.h +++ b/printing/backend/print_backend.h @@ -24,6 +24,7 @@ struct PrinterBasicInfo { std::string printer_name; std::string printer_description; int printer_status; + int is_default; std::map<std::string, std::string> options; }; diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc index ee8907e..2e63145 100644 --- a/printing/backend/print_backend_cups.cc +++ b/printing/backend/print_backend_cups.cc @@ -126,6 +126,7 @@ bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) { PrinterBasicInfo printer_info; printer_info.printer_name = printer.name; + printer_info.is_default = printer.is_default; const char* info = cupsGetOption(kCUPSPrinterInfoOpt, printer.num_options, printer.options); diff --git a/printing/backend/print_backend_win.cc b/printing/backend/print_backend_win.cc index f2df9b1..4a82207 100644 --- a/printing/backend/print_backend_win.cc +++ b/printing/backend/print_backend_win.cc @@ -67,11 +67,19 @@ bool PrintBackendWin::EnumeratePrinters(PrinterList* printer_list) { 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); + 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)); if (printer_info[index].pComment) info.printer_description = WideToUTF8(printer_info[index].pComment); info.printer_status = printer_info[index].Status; |