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

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

Issue 10905006: Get semantic capabilities from Print Backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | « printing/backend/print_backend_chromeos.cc ('k') | printing/backend/print_backend_win.cc » ('j') | 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 "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 static const char kCUPSPrinterMakeModelOpt[] = "printer-make-and-model"; 101 static const char kCUPSPrinterMakeModelOpt[] = "printer-make-and-model";
102 102
103 class PrintBackendCUPS : public PrintBackend { 103 class PrintBackendCUPS : public PrintBackend {
104 public: 104 public:
105 PrintBackendCUPS(const GURL& print_server_url, 105 PrintBackendCUPS(const GURL& print_server_url,
106 http_encryption_t encryption, bool blocking); 106 http_encryption_t encryption, bool blocking);
107 107
108 // PrintBackend implementation. 108 // PrintBackend implementation.
109 virtual bool EnumeratePrinters(PrinterList* printer_list) OVERRIDE; 109 virtual bool EnumeratePrinters(PrinterList* printer_list) OVERRIDE;
110 virtual std::string GetDefaultPrinterName() OVERRIDE; 110 virtual std::string GetDefaultPrinterName() OVERRIDE;
111 virtual bool GetPrinterSemanticCapsAndDefaults(
112 const std::string& printer_name,
113 PrinterSemanticCapsAndDefaults* printer_info) OVERRIDE;
111 virtual bool GetPrinterCapsAndDefaults( 114 virtual bool GetPrinterCapsAndDefaults(
112 const std::string& printer_name, 115 const std::string& printer_name,
113 PrinterCapsAndDefaults* printer_info) OVERRIDE; 116 PrinterCapsAndDefaults* printer_info) OVERRIDE;
114 virtual std::string GetPrinterDriverInfo( 117 virtual std::string GetPrinterDriverInfo(
115 const std::string& printer_name) OVERRIDE; 118 const std::string& printer_name) OVERRIDE;
116 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; 119 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE;
117 120
118 protected: 121 protected:
119 virtual ~PrintBackendCUPS() {} 122 virtual ~PrintBackendCUPS() {}
120 123
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 206 }
204 207
205 std::string PrintBackendCUPS::GetDefaultPrinterName() { 208 std::string PrintBackendCUPS::GetDefaultPrinterName() {
206 // Not using cupsGetDefault() because it lies about the default printer. 209 // Not using cupsGetDefault() because it lies about the default printer.
207 cups_dest_t* dests; 210 cups_dest_t* dests;
208 int num_dests = GetDests(&dests); 211 int num_dests = GetDests(&dests);
209 cups_dest_t* dest = cupsGetDest(NULL, NULL, num_dests, dests); 212 cups_dest_t* dest = cupsGetDest(NULL, NULL, num_dests, dests);
210 return dest ? std::string(dest->name) : std::string(); 213 return dest ? std::string(dest->name) : std::string();
211 } 214 }
212 215
216 bool PrintBackendCUPS::GetPrinterSemanticCapsAndDefaults(
217 const std::string& printer_name,
218 PrinterSemanticCapsAndDefaults* printer_info) {
219 PrinterCapsAndDefaults info;
220 if (!GetPrinterCapsAndDefaults(printer_name, &info) )
221 return false;
222
223 return parsePpdCapabilities(
224 printer_name, info.printer_capabilities, printer_info);
225 }
226
213 bool PrintBackendCUPS::GetPrinterCapsAndDefaults( 227 bool PrintBackendCUPS::GetPrinterCapsAndDefaults(
214 const std::string& printer_name, 228 const std::string& printer_name,
215 PrinterCapsAndDefaults* printer_info) { 229 PrinterCapsAndDefaults* printer_info) {
216 DCHECK(printer_info); 230 DCHECK(printer_info);
217 231
218 VLOG(1) << "CUPS: Getting caps and defaults" 232 VLOG(1) << "CUPS: Getting caps and defaults"
219 << ", printer name: " << printer_name; 233 << ", printer name: " << printer_name;
220 234
221 FilePath ppd_path(GetPPD(printer_name.c_str())); 235 FilePath ppd_path(GetPPD(printer_name.c_str()));
222 // In some cases CUPS failed to get ppd file. 236 // In some cases CUPS failed to get ppd file.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 << ", HTTP error: " << http_error; 367 << ", HTTP error: " << http_error;
354 file_util::Delete(ppd_path, false); 368 file_util::Delete(ppd_path, false);
355 ppd_path.clear(); 369 ppd_path.clear();
356 } 370 }
357 } 371 }
358 } 372 }
359 return ppd_path; 373 return ppd_path;
360 } 374 }
361 375
362 } // namespace printing 376 } // namespace printing
OLDNEW
« no previous file with comments | « printing/backend/print_backend_chromeos.cc ('k') | printing/backend/print_backend_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698