summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 05:41:27 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 05:41:27 +0000
commitce80f5f9b5b2e8238875419a5adf61875524f3ef (patch)
treedb9d9ce2b12d8c8fb5b849589b314df23723d9a6 /printing
parentc4cee35c075d205ee711e5da8d83fb9f2e4974a7 (diff)
downloadchromium_src-ce80f5f9b5b2e8238875419a5adf61875524f3ef.zip
chromium_src-ce80f5f9b5b2e8238875419a5adf61875524f3ef.tar.gz
chromium_src-ce80f5f9b5b2e8238875419a5adf61875524f3ef.tar.bz2
CUPS printing: Do not add scanners to the printer list.
BUG=91755 TEST=see bug Review URL: http://codereview.chromium.org/7569028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/backend/print_backend_cups.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc
index 8578a7c..9a4cf1c 100644
--- a/printing/backend/print_backend_cups.cc
+++ b/printing/backend/print_backend_cups.cc
@@ -4,12 +4,17 @@
#include "printing/backend/print_backend.h"
+#include "build/build_config.h"
+
#include <dlfcn.h>
#include <errno.h>
-#if !defined(OS_MACOSX)
+#include <pthread.h>
+
+#if defined(OS_MACOSX)
+#include <AvailabilityMacros.h>
+#else
#include <gcrypt.h>
#endif
-#include <pthread.h>
#include "base/file_util.h"
#include "base/lazy_instance.h"
@@ -21,7 +26,11 @@
#include "printing/backend/cups_helper.h"
#include "printing/backend/print_backend_consts.h"
-#if !defined(OS_MACOSX)
+#if defined(OS_MACOSX)
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
+const int CUPS_PRINTER_SCANNER = 0x2000000; // Scanner-only device
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
+#else
GCRY_THREAD_OPTION_PTHREAD_IMPL;
namespace {
@@ -71,12 +80,13 @@ static base::LazyInstance<GcryptInitializer> g_gcrypt_initializer(
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 +136,16 @@ bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) {
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;