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

Unified Diff: printing/backend/print_backend_cups.cc

Issue 7569028: CUPS printing: Do not add scanners to the printer list. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/backend/print_backend_cups.cc
===================================================================
--- printing/backend/print_backend_cups.cc (revision 95638)
+++ printing/backend/print_backend_cups.cc (working copy)
@@ -21,7 +21,10 @@
#include "printing/backend/cups_helper.h"
#include "printing/backend/print_backend_consts.h"
-#if !defined(OS_MACOSX)
+#if defined(OS_MACOSX)
+// Mac still builds against the 10.5 SDK, which does not have this in cups.h.
Mark Mentovai 2011/08/08 21:02:07 Don’t do this. You need more #if: #if defined(OS_
Lei Zhang 2011/08/08 22:04:02 Mark: Thanks, more #ifs added. On 2011/08/08 21:0
+#define CUPS_PRINTER_SCANNER 0x2000000
+#else
GCRY_THREAD_OPTION_PTHREAD_IMPL;
namespace {
@@ -71,12 +74,13 @@
base::LINKER_INITIALIZED);
} // namespace
-#endif
+#endif // defined(OS_MACOSX)
namespace printing {
static const char kCUPSPrinterInfoOpt[] = "printer-info";
static const char kCUPSPrinterStateOpt[] = "printer-state";
+static const char kCUPSPrinterTypeOpt[] = "printer-type";
class PrintBackendCUPS : public PrintBackend {
public:
@@ -126,6 +130,16 @@
for (int printer_index = 0; printer_index < num_dests; printer_index++) {
const cups_dest_t& printer = destinations[printer_index];
+ // CUPS can have 'printers' that are actually scanners. (not MFC)
+ // At least on Mac. Check for scanners and skip them.
+ const char* type_str = cupsGetOption(kCUPSPrinterTypeOpt,
+ printer.num_options, printer.options);
+ if (type_str != NULL) {
+ int type;
+ if (base::StringToInt(type_str, &type) && (type & CUPS_PRINTER_SCANNER))
+ continue;
+ }
+
PrinterBasicInfo printer_info;
printer_info.printer_name = printer.name;
printer_info.is_default = printer.is_default;
« 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