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

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

Issue 12217101: Replace FilePath with base::FilePath in some more top level directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « media/webm/chromeos/webm_encoder.cc ('k') | printing/backend/print_backend_cups.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/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 13 matching lines...) Expand all
24 const char kColorMode[] = "ColorMode"; 24 const char kColorMode[] = "ColorMode";
25 const char kProcessColorModel[] = "ProcessColorModel"; 25 const char kProcessColorModel[] = "ProcessColorModel";
26 const char kPrintoutMode[] = "PrintoutMode"; 26 const char kPrintoutMode[] = "PrintoutMode";
27 const char kDraftGray[] = "Draft.Gray"; 27 const char kDraftGray[] = "Draft.Gray";
28 const char kHighGray[] = "High.Gray"; 28 const char kHighGray[] = "High.Gray";
29 29
30 const char kDuplex[] = "Duplex"; 30 const char kDuplex[] = "Duplex";
31 const char kDuplexNone[] = "None"; 31 const char kDuplexNone[] = "None";
32 32
33 #if !defined(OS_MACOSX) 33 #if !defined(OS_MACOSX)
34 void ParseLpOptions(const FilePath& filepath, const std::string& printer_name, 34 void ParseLpOptions(const base::FilePath& filepath,
35 const std::string& printer_name,
35 int* num_options, cups_option_t** options) { 36 int* num_options, cups_option_t** options) {
36 std::string content; 37 std::string content;
37 if (!file_util::ReadFileToString(filepath, &content)) 38 if (!file_util::ReadFileToString(filepath, &content))
38 return; 39 return;
39 40
40 const char kDest[] = "dest"; 41 const char kDest[] = "dest";
41 const char kDefault[] = "default"; 42 const char kDefault[] = "default";
42 const size_t kDestLen = sizeof(kDest) - 1; 43 const size_t kDestLen = sizeof(kDest) - 1;
43 const size_t kDefaultLen = sizeof(kDefault) - 1; 44 const size_t kDefaultLen = sizeof(kDefault) - 1;
44 std::vector<std::string> lines; 45 std::vector<std::string> lines;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 87 }
87 88
88 void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) { 89 void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) {
89 cups_option_t* options = NULL; 90 cups_option_t* options = NULL;
90 int num_options = 0; 91 int num_options = 0;
91 ppdMarkDefaults(*ppd); 92 ppdMarkDefaults(*ppd);
92 93
93 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions"; 94 const char kSystemLpOptionPath[] = "/etc/cups/lpoptions";
94 const char kUserLpOptionPath[] = ".cups/lpoptions"; 95 const char kUserLpOptionPath[] = ".cups/lpoptions";
95 96
96 std::vector<FilePath> file_locations; 97 std::vector<base::FilePath> file_locations;
97 file_locations.push_back(FilePath(kSystemLpOptionPath)); 98 file_locations.push_back(base::FilePath(kSystemLpOptionPath));
98 file_locations.push_back(FilePath( 99 file_locations.push_back(base::FilePath(
99 file_util::GetHomeDir().Append(kUserLpOptionPath))); 100 file_util::GetHomeDir().Append(kUserLpOptionPath)));
100 101
101 for (std::vector<FilePath>::const_iterator it = file_locations.begin(); 102 for (std::vector<base::FilePath>::const_iterator it = file_locations.begin();
102 it != file_locations.end(); ++it) { 103 it != file_locations.end(); ++it) {
103 num_options = 0; 104 num_options = 0;
104 options = NULL; 105 options = NULL;
105 ParseLpOptions(*it, printer_name, &num_options, &options); 106 ParseLpOptions(*it, printer_name, &num_options, &options);
106 if (num_options > 0 && options) { 107 if (num_options > 0 && options) {
107 cupsMarkOptions(*ppd, num_options, options); 108 cupsMarkOptions(*ppd, num_options, options);
108 cupsFreeOptions(num_options, options); 109 cupsFreeOptions(num_options, options);
109 } 110 }
110 } 111 }
111 } 112 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 334 }
334 335
335 http_t* HttpConnectionCUPS::http() { 336 http_t* HttpConnectionCUPS::http() {
336 return http_; 337 return http_;
337 } 338 }
338 339
339 bool parsePpdCapabilities( 340 bool parsePpdCapabilities(
340 const std::string& printer_name, 341 const std::string& printer_name,
341 const std::string& printer_capabilities, 342 const std::string& printer_capabilities,
342 PrinterSemanticCapsAndDefaults* printer_info) { 343 PrinterSemanticCapsAndDefaults* printer_info) {
343 FilePath ppd_file_path; 344 base::FilePath ppd_file_path;
344 if (!file_util::CreateTemporaryFile(&ppd_file_path)) 345 if (!file_util::CreateTemporaryFile(&ppd_file_path))
345 return false; 346 return false;
346 347
347 int data_size = printer_capabilities.length(); 348 int data_size = printer_capabilities.length();
348 if (data_size != file_util::WriteFile( 349 if (data_size != file_util::WriteFile(
349 ppd_file_path, 350 ppd_file_path,
350 printer_capabilities.data(), 351 printer_capabilities.data(),
351 data_size)) { 352 data_size)) {
352 file_util::Delete(ppd_file_path, false); 353 file_util::Delete(ppd_file_path, false);
353 return false; 354 return false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 caps.color_default = is_color; 387 caps.color_default = is_color;
387 388
388 ppdClose(ppd); 389 ppdClose(ppd);
389 file_util::Delete(ppd_file_path, false); 390 file_util::Delete(ppd_file_path, false);
390 391
391 *printer_info = caps; 392 *printer_info = caps;
392 return true; 393 return true;
393 } 394 }
394 395
395 } // namespace printing 396 } // namespace printing
OLDNEW
« no previous file with comments | « media/webm/chromeos/webm_encoder.cc ('k') | printing/backend/print_backend_cups.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698