OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/service/cloud_print/print_system.h" | 5 #include "chrome/service/cloud_print/print_system.h" |
6 | 6 |
7 #include <cups/cups.h> | 7 #include <cups/cups.h> |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <pthread.h> | 10 #include <pthread.h> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // the number of requests. | 71 // the number of requests. |
72 typedef std::map<std::string, printing::PrinterCapsAndDefaults> CapsMap; | 72 typedef std::map<std::string, printing::PrinterCapsAndDefaults> CapsMap; |
73 CapsMap caps_cache; | 73 CapsMap caps_cache; |
74 }; | 74 }; |
75 | 75 |
76 class PrintSystemCUPS : public PrintSystem { | 76 class PrintSystemCUPS : public PrintSystem { |
77 public: | 77 public: |
78 explicit PrintSystemCUPS(const DictionaryValue* print_system_settings); | 78 explicit PrintSystemCUPS(const DictionaryValue* print_system_settings); |
79 | 79 |
80 // PrintSystem implementation. | 80 // PrintSystem implementation. |
81 virtual PrintSystemResult Init(); | 81 virtual PrintSystemResult Init() OVERRIDE; |
82 | |
83 virtual PrintSystem::PrintSystemResult EnumeratePrinters( | 82 virtual PrintSystem::PrintSystemResult EnumeratePrinters( |
84 printing::PrinterList* printer_list); | 83 printing::PrinterList* printer_list) OVERRIDE; |
85 | |
86 virtual void GetPrinterCapsAndDefaults( | 84 virtual void GetPrinterCapsAndDefaults( |
87 const std::string& printer_name, | 85 const std::string& printer_name, |
88 PrinterCapsAndDefaultsCallback* callback); | 86 const PrinterCapsAndDefaultsCallback& callback) OVERRIDE; |
89 | 87 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; |
90 virtual bool IsValidPrinter(const std::string& printer_name); | 88 virtual bool ValidatePrintTicket( |
91 | 89 const std::string& printer_name, |
92 virtual bool ValidatePrintTicket(const std::string& printer_name, | 90 const std::string& print_ticket_data) OVERRIDE; |
93 const std::string& print_ticket_data); | |
94 | |
95 virtual bool GetJobDetails(const std::string& printer_name, | 91 virtual bool GetJobDetails(const std::string& printer_name, |
96 PlatformJobId job_id, | 92 PlatformJobId job_id, |
97 PrintJobDetails *job_details); | 93 PrintJobDetails *job_details) OVERRIDE; |
98 | 94 virtual PrintSystem::PrintServerWatcher* CreatePrintServerWatcher() OVERRIDE; |
99 virtual PrintSystem::PrintServerWatcher* CreatePrintServerWatcher(); | |
100 virtual PrintSystem::PrinterWatcher* CreatePrinterWatcher( | 95 virtual PrintSystem::PrinterWatcher* CreatePrinterWatcher( |
101 const std::string& printer_name); | 96 const std::string& printer_name) OVERRIDE; |
102 virtual PrintSystem::JobSpooler* CreateJobSpooler(); | 97 virtual PrintSystem::JobSpooler* CreateJobSpooler() OVERRIDE; |
103 virtual std::string GetSupportedMimeTypes(); | 98 virtual std::string GetSupportedMimeTypes() OVERRIDE; |
104 | 99 |
105 // Helper functions. | 100 // Helper functions. |
106 PlatformJobId SpoolPrintJob(const std::string& print_ticket, | 101 PlatformJobId SpoolPrintJob(const std::string& print_ticket, |
107 const FilePath& print_data_file_path, | 102 const FilePath& print_data_file_path, |
108 const std::string& print_data_mime_type, | 103 const std::string& print_data_mime_type, |
109 const std::string& printer_name, | 104 const std::string& printer_name, |
110 const std::string& job_title, | 105 const std::string& job_title, |
111 const std::vector<std::string>& tags, | 106 const std::vector<std::string>& tags, |
112 bool* dry_run); | 107 bool* dry_run); |
113 bool GetPrinterInfo(const std::string& printer_name, | 108 bool GetPrinterInfo(const std::string& printer_name, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 142 |
148 // Full name contains print server url:port and printer name. Short name | 143 // Full name contains print server url:port and printer name. Short name |
149 // is the name of the printer in the CUPS server. | 144 // is the name of the printer in the CUPS server. |
150 std::string MakeFullPrinterName(const GURL& url, | 145 std::string MakeFullPrinterName(const GURL& url, |
151 const std::string& short_printer_name); | 146 const std::string& short_printer_name); |
152 PrintServerInfoCUPS* FindServerByFullName( | 147 PrintServerInfoCUPS* FindServerByFullName( |
153 const std::string& full_printer_name, std::string* short_printer_name); | 148 const std::string& full_printer_name, std::string* short_printer_name); |
154 | 149 |
155 // Helper method to invoke a PrinterCapsAndDefaultsCallback. | 150 // Helper method to invoke a PrinterCapsAndDefaultsCallback. |
156 static void RunCapsCallback( | 151 static void RunCapsCallback( |
157 PrinterCapsAndDefaultsCallback* callback, | 152 const PrinterCapsAndDefaultsCallback& callback, |
158 bool succeeded, | 153 bool succeeded, |
159 const std::string& printer_name, | 154 const std::string& printer_name, |
160 const printing::PrinterCapsAndDefaults& printer_info); | 155 const printing::PrinterCapsAndDefaults& printer_info); |
161 | 156 |
162 // PrintServerList contains information about all print servers and backends | 157 // PrintServerList contains information about all print servers and backends |
163 // this proxy is connected to. | 158 // this proxy is connected to. |
164 typedef std::list<PrintServerInfoCUPS> PrintServerList; | 159 typedef std::list<PrintServerInfoCUPS> PrintServerList; |
165 PrintServerList print_servers_; | 160 PrintServerList print_servers_; |
166 | 161 |
167 int update_timeout_; | 162 int update_timeout_; |
168 bool initialized_; | 163 bool initialized_; |
169 bool printer_enum_succeeded_; | 164 bool printer_enum_succeeded_; |
170 bool notify_delete_; | 165 bool notify_delete_; |
171 }; | 166 }; |
172 | 167 |
173 class PrintServerWatcherCUPS | 168 class PrintServerWatcherCUPS |
174 : public PrintSystem::PrintServerWatcher { | 169 : public PrintSystem::PrintServerWatcher { |
175 public: | 170 public: |
176 explicit PrintServerWatcherCUPS(PrintSystemCUPS* print_system) | 171 explicit PrintServerWatcherCUPS(PrintSystemCUPS* print_system) |
177 : print_system_(print_system), | 172 : print_system_(print_system), |
178 delegate_(NULL) { | 173 delegate_(NULL) { |
179 } | 174 } |
180 ~PrintServerWatcherCUPS() { | 175 ~PrintServerWatcherCUPS() { |
181 StopWatching(); | 176 StopWatching(); |
182 } | 177 } |
183 | 178 |
184 // PrintSystem::PrintServerWatcher interface | 179 // PrintSystem::PrintServerWatcher implementation. |
185 virtual bool StartWatching( | 180 virtual bool StartWatching( |
186 PrintSystem::PrintServerWatcher::Delegate* delegate) { | 181 PrintSystem::PrintServerWatcher::Delegate* delegate) OVERRIDE { |
187 delegate_ = delegate; | 182 delegate_ = delegate; |
188 printers_hash_ = GetPrintersHash(); | 183 printers_hash_ = GetPrintersHash(); |
189 MessageLoop::current()->PostDelayedTask( | 184 MessageLoop::current()->PostDelayedTask( |
190 FROM_HERE, | 185 FROM_HERE, |
191 base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), | 186 base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), |
192 print_system_->GetUpdateTimeoutMs()); | 187 print_system_->GetUpdateTimeoutMs()); |
193 return true; | 188 return true; |
194 } | 189 } |
195 virtual bool StopWatching() { | 190 |
| 191 virtual bool StopWatching() OVERRIDE { |
196 delegate_ = NULL; | 192 delegate_ = NULL; |
197 return true; | 193 return true; |
198 } | 194 } |
199 | 195 |
200 void CheckForUpdates() { | 196 void CheckForUpdates() { |
201 if (delegate_ == NULL) | 197 if (delegate_ == NULL) |
202 return; // Orphan call. We have been stopped already. | 198 return; // Orphan call. We have been stopped already. |
203 VLOG(1) << "CP_CUPS: Checking for new printers"; | 199 VLOG(1) << "CP_CUPS: Checking for new printers"; |
204 std::string new_hash = GetPrintersHash(); | 200 std::string new_hash = GetPrintersHash(); |
205 if (printers_hash_ != new_hash) { | 201 if (printers_hash_ != new_hash) { |
206 printers_hash_ = new_hash; | 202 printers_hash_ = new_hash; |
207 delegate_->OnPrinterAdded(); | 203 delegate_->OnPrinterAdded(); |
208 } | 204 } |
209 MessageLoop::current()->PostDelayedTask( | 205 MessageLoop::current()->PostDelayedTask( |
210 FROM_HERE, | 206 FROM_HERE, |
211 base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), | 207 base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), |
212 print_system_->GetUpdateTimeoutMs()); | 208 print_system_->GetUpdateTimeoutMs()); |
213 } | 209 } |
| 210 |
214 private: | 211 private: |
215 std::string GetPrintersHash() { | 212 std::string GetPrintersHash() { |
216 printing::PrinterList printer_list; | 213 printing::PrinterList printer_list; |
217 print_system_->EnumeratePrinters(&printer_list); | 214 print_system_->EnumeratePrinters(&printer_list); |
218 | 215 |
219 // Sort printer names. | 216 // Sort printer names. |
220 std::vector<std::string> printers; | 217 std::vector<std::string> printers; |
221 printing::PrinterList::iterator it; | 218 printing::PrinterList::iterator it; |
222 for (it = printer_list.begin(); it != printer_list.end(); ++it) | 219 for (it = printer_list.begin(); it != printer_list.end(); ++it) |
223 printers.push_back(it->printer_name); | 220 printers.push_back(it->printer_name); |
224 std::sort(printers.begin(), printers.end()); | 221 std::sort(printers.begin(), printers.end()); |
225 | 222 |
226 std::string to_hash; | 223 std::string to_hash; |
227 for (size_t i = 0; i < printers.size(); i++) | 224 for (size_t i = 0; i < printers.size(); i++) |
228 to_hash += printers[i]; | 225 to_hash += printers[i]; |
229 | 226 |
230 return base::MD5String(to_hash); | 227 return base::MD5String(to_hash); |
231 } | 228 } |
232 | 229 |
233 scoped_refptr<PrintSystemCUPS> print_system_; | 230 scoped_refptr<PrintSystemCUPS> print_system_; |
234 PrintSystem::PrintServerWatcher::Delegate* delegate_; | 231 PrintSystem::PrintServerWatcher::Delegate* delegate_; |
235 std::string printers_hash_; | 232 std::string printers_hash_; |
| 233 |
236 DISALLOW_COPY_AND_ASSIGN(PrintServerWatcherCUPS); | 234 DISALLOW_COPY_AND_ASSIGN(PrintServerWatcherCUPS); |
237 }; | 235 }; |
238 | 236 |
239 class PrinterWatcherCUPS | 237 class PrinterWatcherCUPS |
240 : public PrintSystem::PrinterWatcher { | 238 : public PrintSystem::PrinterWatcher { |
241 public: | 239 public: |
242 PrinterWatcherCUPS(PrintSystemCUPS* print_system, | 240 PrinterWatcherCUPS(PrintSystemCUPS* print_system, |
243 const std::string& printer_name) | 241 const std::string& printer_name) |
244 : printer_name_(printer_name), | 242 : printer_name_(printer_name), |
245 delegate_(NULL), | 243 delegate_(NULL), |
246 print_system_(print_system) { | 244 print_system_(print_system) { |
247 } | 245 } |
| 246 |
248 ~PrinterWatcherCUPS() { | 247 ~PrinterWatcherCUPS() { |
249 StopWatching(); | 248 StopWatching(); |
250 } | 249 } |
251 | 250 |
252 // PrintSystem::PrinterWatcher interface | 251 // PrintSystem::PrinterWatcher implementation. |
253 virtual bool StartWatching( | 252 virtual bool StartWatching( |
254 PrintSystem::PrinterWatcher::Delegate* delegate) { | 253 PrintSystem::PrinterWatcher::Delegate* delegate) OVERRIDE{ |
255 if (delegate_ != NULL) | 254 if (delegate_ != NULL) |
256 StopWatching(); | 255 StopWatching(); |
257 delegate_ = delegate; | 256 delegate_ = delegate; |
258 settings_hash_ = GetSettingsHash(); | 257 settings_hash_ = GetSettingsHash(); |
259 // Schedule next job status update. | 258 // Schedule next job status update. |
260 MessageLoop::current()->PostDelayedTask( | 259 MessageLoop::current()->PostDelayedTask( |
261 FROM_HERE, | 260 FROM_HERE, |
262 base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), | 261 base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), |
263 kJobUpdateTimeoutMs); | 262 kJobUpdateTimeoutMs); |
264 // Schedule next printer check. | 263 // Schedule next printer check. |
265 // TODO(gene): Randomize time for the next printer update. | 264 // TODO(gene): Randomize time for the next printer update. |
266 MessageLoop::current()->PostDelayedTask( | 265 MessageLoop::current()->PostDelayedTask( |
267 FROM_HERE, | 266 FROM_HERE, |
268 base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), | 267 base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), |
269 print_system_->GetUpdateTimeoutMs()); | 268 print_system_->GetUpdateTimeoutMs()); |
270 return true; | 269 return true; |
271 } | 270 } |
272 virtual bool StopWatching() { | 271 |
| 272 virtual bool StopWatching() OVERRIDE{ |
273 delegate_ = NULL; | 273 delegate_ = NULL; |
274 return true; | 274 return true; |
275 } | 275 } |
| 276 |
276 bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { | 277 bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { |
277 DCHECK(printer_info); | 278 DCHECK(printer_info); |
278 return print_system_->GetPrinterInfo(printer_name_, printer_info); | 279 return print_system_->GetPrinterInfo(printer_name_, printer_info); |
279 } | 280 } |
280 | 281 |
281 void JobStatusUpdate() { | 282 void JobStatusUpdate() { |
282 if (delegate_ == NULL) | 283 if (delegate_ == NULL) |
283 return; // Orphan call. We have been stopped already. | 284 return; // Orphan call. We have been stopped already. |
284 // For CUPS proxy, we are going to fire OnJobChanged notification | 285 // For CUPS proxy, we are going to fire OnJobChanged notification |
285 // periodically. Higher level will check if there are any outstanding | 286 // periodically. Higher level will check if there are any outstanding |
(...skipping 20 matching lines...) Expand all Loading... |
306 settings_hash_ = new_hash; | 307 settings_hash_ = new_hash; |
307 delegate_->OnPrinterChanged(); | 308 delegate_->OnPrinterChanged(); |
308 VLOG(1) << "CP_CUPS: Printer update detected for: " << printer_name_; | 309 VLOG(1) << "CP_CUPS: Printer update detected for: " << printer_name_; |
309 } | 310 } |
310 } | 311 } |
311 MessageLoop::current()->PostDelayedTask( | 312 MessageLoop::current()->PostDelayedTask( |
312 FROM_HERE, | 313 FROM_HERE, |
313 base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), | 314 base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), |
314 print_system_->GetUpdateTimeoutMs()); | 315 print_system_->GetUpdateTimeoutMs()); |
315 } | 316 } |
| 317 |
316 private: | 318 private: |
317 std::string GetSettingsHash() { | 319 std::string GetSettingsHash() { |
318 printing::PrinterBasicInfo info; | 320 printing::PrinterBasicInfo info; |
319 if (!print_system_->GetPrinterInfo(printer_name_, &info)) | 321 if (!print_system_->GetPrinterInfo(printer_name_, &info)) |
320 return std::string(); | 322 return std::string(); |
321 | 323 |
322 printing::PrinterCapsAndDefaults caps; | 324 printing::PrinterCapsAndDefaults caps; |
323 if (!print_system_->GetPrinterCapsAndDefaults(printer_name_, &caps)) | 325 if (!print_system_->GetPrinterCapsAndDefaults(printer_name_, &caps)) |
324 return std::string(); | 326 return std::string(); |
325 | 327 |
(...skipping 10 matching lines...) Expand all Loading... |
336 to_hash += caps.printer_defaults; | 338 to_hash += caps.printer_defaults; |
337 to_hash += caps.defaults_mime_type; | 339 to_hash += caps.defaults_mime_type; |
338 | 340 |
339 return base::MD5String(to_hash); | 341 return base::MD5String(to_hash); |
340 } | 342 } |
341 | 343 |
342 std::string printer_name_; | 344 std::string printer_name_; |
343 PrintSystem::PrinterWatcher::Delegate* delegate_; | 345 PrintSystem::PrinterWatcher::Delegate* delegate_; |
344 scoped_refptr<PrintSystemCUPS> print_system_; | 346 scoped_refptr<PrintSystemCUPS> print_system_; |
345 std::string settings_hash_; | 347 std::string settings_hash_; |
| 348 |
346 DISALLOW_COPY_AND_ASSIGN(PrinterWatcherCUPS); | 349 DISALLOW_COPY_AND_ASSIGN(PrinterWatcherCUPS); |
347 }; | 350 }; |
348 | 351 |
349 class JobSpoolerCUPS : public PrintSystem::JobSpooler { | 352 class JobSpoolerCUPS : public PrintSystem::JobSpooler { |
350 public: | 353 public: |
351 explicit JobSpoolerCUPS(PrintSystemCUPS* print_system) | 354 explicit JobSpoolerCUPS(PrintSystemCUPS* print_system) |
352 : print_system_(print_system) { | 355 : print_system_(print_system) { |
353 DCHECK(print_system_.get()); | 356 DCHECK(print_system_.get()); |
354 } | 357 } |
| 358 |
355 // PrintSystem::JobSpooler implementation. | 359 // PrintSystem::JobSpooler implementation. |
356 virtual bool Spool(const std::string& print_ticket, | 360 virtual bool Spool(const std::string& print_ticket, |
357 const FilePath& print_data_file_path, | 361 const FilePath& print_data_file_path, |
358 const std::string& print_data_mime_type, | 362 const std::string& print_data_mime_type, |
359 const std::string& printer_name, | 363 const std::string& printer_name, |
360 const std::string& job_title, | 364 const std::string& job_title, |
361 const std::vector<std::string>& tags, | 365 const std::vector<std::string>& tags, |
362 JobSpooler::Delegate* delegate) { | 366 JobSpooler::Delegate* delegate) OVERRIDE{ |
363 DCHECK(delegate); | 367 DCHECK(delegate); |
364 bool dry_run = false; | 368 bool dry_run = false; |
365 int job_id = print_system_->SpoolPrintJob( | 369 int job_id = print_system_->SpoolPrintJob( |
366 print_ticket, print_data_file_path, print_data_mime_type, | 370 print_ticket, print_data_file_path, print_data_mime_type, |
367 printer_name, job_title, tags, &dry_run); | 371 printer_name, job_title, tags, &dry_run); |
368 MessageLoop::current()->PostTask( | 372 MessageLoop::current()->PostTask( |
369 FROM_HERE, | 373 FROM_HERE, |
370 base::Bind(&JobSpoolerCUPS::NotifyDelegate, delegate, job_id, dry_run)); | 374 base::Bind(&JobSpoolerCUPS::NotifyDelegate, delegate, job_id, dry_run)); |
371 return true; | 375 return true; |
372 } | 376 } |
373 | 377 |
374 static void NotifyDelegate(JobSpooler::Delegate* delegate, | 378 static void NotifyDelegate(JobSpooler::Delegate* delegate, |
375 int job_id, bool dry_run) { | 379 int job_id, bool dry_run) { |
376 if (dry_run || job_id) | 380 if (dry_run || job_id) |
377 delegate->OnJobSpoolSucceeded(job_id); | 381 delegate->OnJobSpoolSucceeded(job_id); |
378 else | 382 else |
379 delegate->OnJobSpoolFailed(); | 383 delegate->OnJobSpoolFailed(); |
380 } | 384 } |
| 385 |
381 private: | 386 private: |
382 scoped_refptr<PrintSystemCUPS> print_system_; | 387 scoped_refptr<PrintSystemCUPS> print_system_; |
| 388 |
383 DISALLOW_COPY_AND_ASSIGN(JobSpoolerCUPS); | 389 DISALLOW_COPY_AND_ASSIGN(JobSpoolerCUPS); |
384 }; | 390 }; |
385 | 391 |
386 PrintSystemCUPS::PrintSystemCUPS(const DictionaryValue* print_system_settings) | 392 PrintSystemCUPS::PrintSystemCUPS(const DictionaryValue* print_system_settings) |
387 : update_timeout_(kCheckForPrinterUpdatesMs), | 393 : update_timeout_(kCheckForPrinterUpdatesMs), |
388 initialized_(false), | 394 initialized_(false), |
389 printer_enum_succeeded_(false), | 395 printer_enum_succeeded_(false), |
390 notify_delete_(true) { | 396 notify_delete_(true) { |
391 if (print_system_settings) { | 397 if (print_system_settings) { |
392 int timeout; | 398 int timeout; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 it->printers.begin(), it->printers.end()); | 482 it->printers.begin(), it->printers.end()); |
477 } | 483 } |
478 VLOG(1) << "CUPS: Total " << printer_list->size() << " printers enumerated."; | 484 VLOG(1) << "CUPS: Total " << printer_list->size() << " printers enumerated."; |
479 // TODO(sanjeevr): Maybe some day we want to report the actual server names | 485 // TODO(sanjeevr): Maybe some day we want to report the actual server names |
480 // for which the enumeration failed. | 486 // for which the enumeration failed. |
481 return PrintSystemResult(printer_enum_succeeded_, std::string()); | 487 return PrintSystemResult(printer_enum_succeeded_, std::string()); |
482 } | 488 } |
483 | 489 |
484 void PrintSystemCUPS::GetPrinterCapsAndDefaults( | 490 void PrintSystemCUPS::GetPrinterCapsAndDefaults( |
485 const std::string& printer_name, | 491 const std::string& printer_name, |
486 PrinterCapsAndDefaultsCallback* callback) { | 492 const PrinterCapsAndDefaultsCallback& callback) { |
487 printing::PrinterCapsAndDefaults printer_info; | 493 printing::PrinterCapsAndDefaults printer_info; |
488 bool succeeded = GetPrinterCapsAndDefaults(printer_name, &printer_info); | 494 bool succeeded = GetPrinterCapsAndDefaults(printer_name, &printer_info); |
489 MessageLoop::current()->PostTask( | 495 MessageLoop::current()->PostTask( |
490 FROM_HERE, | 496 FROM_HERE, |
491 base::Bind(&PrintSystemCUPS::RunCapsCallback, callback, succeeded, | 497 base::Bind(&PrintSystemCUPS::RunCapsCallback, callback, succeeded, |
492 printer_name, printer_info)); | 498 printer_name, printer_info)); |
493 } | 499 } |
494 | 500 |
495 bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { | 501 bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { |
496 return GetPrinterInfo(printer_name, NULL); | 502 return GetPrinterInfo(printer_name, NULL); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 *short_printer_name = full_printer_name.substr(separator + 1); | 809 *short_printer_name = full_printer_name.substr(separator + 1); |
804 return &(*it); | 810 return &(*it); |
805 } | 811 } |
806 } | 812 } |
807 | 813 |
808 LOG(WARNING) << "Server not found for printer: " << full_printer_name; | 814 LOG(WARNING) << "Server not found for printer: " << full_printer_name; |
809 return NULL; | 815 return NULL; |
810 } | 816 } |
811 | 817 |
812 void PrintSystemCUPS::RunCapsCallback( | 818 void PrintSystemCUPS::RunCapsCallback( |
813 PrinterCapsAndDefaultsCallback* callback, | 819 const PrinterCapsAndDefaultsCallback& callback, |
814 bool succeeded, | 820 bool succeeded, |
815 const std::string& printer_name, | 821 const std::string& printer_name, |
816 const printing::PrinterCapsAndDefaults& printer_info) { | 822 const printing::PrinterCapsAndDefaults& printer_info) { |
817 callback->Run(succeeded, printer_name, printer_info); | 823 callback.Run(succeeded, printer_name, printer_info); |
818 delete callback; | |
819 } | 824 } |
820 | 825 |
821 } // namespace cloud_print | 826 } // namespace cloud_print |
OLD | NEW |