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/base_paths.h" |
9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" |
11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
14 #include "base/values.h" | 16 #include "base/values.h" |
15 #include "printing/backend/print_backend.h" | 17 #include "printing/backend/print_backend.h" |
16 #include "printing/backend/print_backend_consts.h" | 18 #include "printing/backend/print_backend_consts.h" |
17 #include "url/gurl.h" | 19 #include "url/gurl.h" |
18 | 20 |
19 namespace printing { | 21 namespace printing { |
20 | 22 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) { | 94 void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) { |
93 cups_option_t* options = NULL; | 95 cups_option_t* options = NULL; |
94 int num_options = 0; | 96 int num_options = 0; |
95 ppdMarkDefaults(*ppd); | 97 ppdMarkDefaults(*ppd); |
96 | 98 |
97 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions"; | 99 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions"; |
98 const char kUserLpOptionPath[] = ".cups/lpoptions"; | 100 const char kUserLpOptionPath[] = ".cups/lpoptions"; |
99 | 101 |
100 std::vector<base::FilePath> file_locations; | 102 std::vector<base::FilePath> file_locations; |
101 file_locations.push_back(base::FilePath(kSystemLpOptionPath)); | 103 file_locations.push_back(base::FilePath(kSystemLpOptionPath)); |
102 file_locations.push_back(base::FilePath( | 104 base::FilePath homedir; |
103 base::GetHomeDir().Append(kUserLpOptionPath))); | 105 PathService::Get(base::DIR_HOME, &homedir); |
| 106 file_locations.push_back(base::FilePath(homedir.Append(kUserLpOptionPath))); |
104 | 107 |
105 for (std::vector<base::FilePath>::const_iterator it = file_locations.begin(); | 108 for (std::vector<base::FilePath>::const_iterator it = file_locations.begin(); |
106 it != file_locations.end(); ++it) { | 109 it != file_locations.end(); ++it) { |
107 num_options = 0; | 110 num_options = 0; |
108 options = NULL; | 111 options = NULL; |
109 ParseLpOptions(*it, printer_name, &num_options, &options); | 112 ParseLpOptions(*it, printer_name, &num_options, &options); |
110 if (num_options > 0 && options) { | 113 if (num_options > 0 && options) { |
111 cupsMarkOptions(*ppd, num_options, options); | 114 cupsMarkOptions(*ppd, num_options, options); |
112 cupsFreeOptions(num_options, options); | 115 cupsFreeOptions(num_options, options); |
113 } | 116 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 caps.bw_model = cm_black; | 394 caps.bw_model = cm_black; |
392 | 395 |
393 ppdClose(ppd); | 396 ppdClose(ppd); |
394 base::DeleteFile(ppd_file_path, false); | 397 base::DeleteFile(ppd_file_path, false); |
395 | 398 |
396 *printer_info = caps; | 399 *printer_info = caps; |
397 return true; | 400 return true; |
398 } | 401 } |
399 | 402 |
400 } // namespace printing | 403 } // namespace printing |
OLD | NEW |