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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 cups_option_t* options = NULL; | 92 cups_option_t* options = NULL; |
93 int num_options = 0; | 93 int num_options = 0; |
94 ppdMarkDefaults(*ppd); | 94 ppdMarkDefaults(*ppd); |
95 | 95 |
96 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions"; | 96 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions"; |
97 const char kUserLpOptionPath[] = ".cups/lpoptions"; | 97 const char kUserLpOptionPath[] = ".cups/lpoptions"; |
98 | 98 |
99 std::vector<base::FilePath> file_locations; | 99 std::vector<base::FilePath> file_locations; |
100 file_locations.push_back(base::FilePath(kSystemLpOptionPath)); | 100 file_locations.push_back(base::FilePath(kSystemLpOptionPath)); |
101 file_locations.push_back(base::FilePath( | 101 file_locations.push_back(base::FilePath( |
102 file_util::GetHomeDir().Append(kUserLpOptionPath))); | 102 base::GetHomeDir().Append(kUserLpOptionPath))); |
103 | 103 |
104 for (std::vector<base::FilePath>::const_iterator it = file_locations.begin(); | 104 for (std::vector<base::FilePath>::const_iterator it = file_locations.begin(); |
105 it != file_locations.end(); ++it) { | 105 it != file_locations.end(); ++it) { |
106 num_options = 0; | 106 num_options = 0; |
107 options = NULL; | 107 options = NULL; |
108 ParseLpOptions(*it, printer_name, &num_options, &options); | 108 ParseLpOptions(*it, printer_name, &num_options, &options); |
109 if (num_options > 0 && options) { | 109 if (num_options > 0 && options) { |
110 cupsMarkOptions(*ppd, num_options, options); | 110 cupsMarkOptions(*ppd, num_options, options); |
111 cupsFreeOptions(num_options, options); | 111 cupsFreeOptions(num_options, options); |
112 } | 112 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 caps.bw_model = cm_black; | 390 caps.bw_model = cm_black; |
391 | 391 |
392 ppdClose(ppd); | 392 ppdClose(ppd); |
393 base::DeleteFile(ppd_file_path, false); | 393 base::DeleteFile(ppd_file_path, false); |
394 | 394 |
395 *printer_info = caps; | 395 *printer_info = caps; |
396 return true; | 396 return true; |
397 } | 397 } |
398 | 398 |
399 } // namespace printing | 399 } // namespace printing |
OLD | NEW |