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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (base::strncasecmp (line.c_str(), kDefault, kDefaultLen) == 0 && | 55 if (base::strncasecmp (line.c_str(), kDefault, kDefaultLen) == 0 && |
56 isspace(line[kDefaultLen])) { | 56 isspace(line[kDefaultLen])) { |
57 line = line.substr(kDefaultLen); | 57 line = line.substr(kDefaultLen); |
58 } else if (base::strncasecmp (line.c_str(), kDest, kDestLen) == 0 && | 58 } else if (base::strncasecmp (line.c_str(), kDest, kDestLen) == 0 && |
59 isspace(line[kDestLen])) { | 59 isspace(line[kDestLen])) { |
60 line = line.substr(kDestLen); | 60 line = line.substr(kDestLen); |
61 } else { | 61 } else { |
62 continue; | 62 continue; |
63 } | 63 } |
64 | 64 |
65 TrimWhitespaceASCII(line, TRIM_ALL, &line); | 65 base::TrimWhitespaceASCII(line, base::TRIM_ALL, &line); |
66 if (line.empty()) | 66 if (line.empty()) |
67 continue; | 67 continue; |
68 | 68 |
69 size_t space_found = line.find(' '); | 69 size_t space_found = line.find(' '); |
70 if (space_found == std::string::npos) | 70 if (space_found == std::string::npos) |
71 continue; | 71 continue; |
72 | 72 |
73 std::string name = line.substr(0, space_found); | 73 std::string name = line.substr(0, space_found); |
74 if (name.empty()) | 74 if (name.empty()) |
75 continue; | 75 continue; |
76 | 76 |
77 if (base::strncasecmp(printer_name.c_str(), name.c_str(), | 77 if (base::strncasecmp(printer_name.c_str(), name.c_str(), |
78 name.length()) != 0) { | 78 name.length()) != 0) { |
79 continue; // This is not the required printer. | 79 continue; // This is not the required printer. |
80 } | 80 } |
81 | 81 |
82 line = line.substr(space_found + 1); | 82 line = line.substr(space_found + 1); |
83 TrimWhitespaceASCII(line, TRIM_ALL, &line); // Remove extra spaces. | 83 // Remove extra spaces. |
| 84 base::TrimWhitespaceASCII(line, base::TRIM_ALL, &line); |
84 if (line.empty()) | 85 if (line.empty()) |
85 continue; | 86 continue; |
86 // Parse the selected printer custom options. | 87 // Parse the selected printer custom options. |
87 *num_options = cupsParseOptions(line.c_str(), 0, options); | 88 *num_options = cupsParseOptions(line.c_str(), 0, options); |
88 } | 89 } |
89 } | 90 } |
90 | 91 |
91 void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) { | 92 void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) { |
92 cups_option_t* options = NULL; | 93 cups_option_t* options = NULL; |
93 int num_options = 0; | 94 int num_options = 0; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 caps.bw_model = cm_black; | 391 caps.bw_model = cm_black; |
391 | 392 |
392 ppdClose(ppd); | 393 ppdClose(ppd); |
393 base::DeleteFile(ppd_file_path, false); | 394 base::DeleteFile(ppd_file_path, false); |
394 | 395 |
395 *printer_info = caps; | 396 *printer_info = caps; |
396 return true; | 397 return true; |
397 } | 398 } |
398 | 399 |
399 } // namespace printing | 400 } // namespace printing |
OLD | NEW |