OLD | NEW |
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/cups_helper.h" | 5 #include "printing/backend/cups_helper.h" |
6 | 6 |
7 #include <cups/ppd.h> | 7 #include <cups/ppd.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 PrinterSemanticCapsAndDefaults* printer_info) { | 343 PrinterSemanticCapsAndDefaults* printer_info) { |
344 base::FilePath ppd_file_path; | 344 base::FilePath ppd_file_path; |
345 if (!file_util::CreateTemporaryFile(&ppd_file_path)) | 345 if (!file_util::CreateTemporaryFile(&ppd_file_path)) |
346 return false; | 346 return false; |
347 | 347 |
348 int data_size = printer_capabilities.length(); | 348 int data_size = printer_capabilities.length(); |
349 if (data_size != file_util::WriteFile( | 349 if (data_size != file_util::WriteFile( |
350 ppd_file_path, | 350 ppd_file_path, |
351 printer_capabilities.data(), | 351 printer_capabilities.data(), |
352 data_size)) { | 352 data_size)) { |
353 file_util::Delete(ppd_file_path, false); | 353 base::Delete(ppd_file_path, false); |
354 return false; | 354 return false; |
355 } | 355 } |
356 | 356 |
357 ppd_file_t* ppd = ppdOpenFile(ppd_file_path.value().c_str()); | 357 ppd_file_t* ppd = ppdOpenFile(ppd_file_path.value().c_str()); |
358 if (!ppd) | 358 if (!ppd) |
359 return false; | 359 return false; |
360 | 360 |
361 printing::PrinterSemanticCapsAndDefaults caps; | 361 printing::PrinterSemanticCapsAndDefaults caps; |
362 #if !defined(OS_MACOSX) | 362 #if !defined(OS_MACOSX) |
363 MarkLpOptions(printer_name, &ppd); | 363 MarkLpOptions(printer_name, &ppd); |
(...skipping 16 matching lines...) Expand all Loading... |
380 bool is_color = false; | 380 bool is_color = false; |
381 int cm_color = 0, cm_black = 0; | 381 int cm_color = 0, cm_black = 0; |
382 if (!GetColorModelSettings(ppd, &cm_black, &cm_color, &is_color)) { | 382 if (!GetColorModelSettings(ppd, &cm_black, &cm_color, &is_color)) { |
383 VLOG(1) << "Unknown printer color model"; | 383 VLOG(1) << "Unknown printer color model"; |
384 } | 384 } |
385 | 385 |
386 caps.color_changeable = (cm_color && cm_black && (cm_color != cm_black)); | 386 caps.color_changeable = (cm_color && cm_black && (cm_color != cm_black)); |
387 caps.color_default = is_color; | 387 caps.color_default = is_color; |
388 | 388 |
389 ppdClose(ppd); | 389 ppdClose(ppd); |
390 file_util::Delete(ppd_file_path, false); | 390 base::Delete(ppd_file_path, false); |
391 | 391 |
392 *printer_info = caps; | 392 *printer_info = caps; |
393 return true; | 393 return true; |
394 } | 394 } |
395 | 395 |
396 } // namespace printing | 396 } // namespace printing |
OLD | NEW |