OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cloud_print_proxy_backend.h" | 5 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/md5.h" | 8 #include "base/md5.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 info.printer_name, | 369 info.printer_name, |
370 mime_boundary, | 370 mime_boundary, |
371 std::string(), &post_data); | 371 std::string(), &post_data); |
372 CloudPrintHelpers::AddMultipartValueForUpload(kPrinterDescValue, | 372 CloudPrintHelpers::AddMultipartValueForUpload(kPrinterDescValue, |
373 info.printer_description, | 373 info.printer_description, |
374 mime_boundary, | 374 mime_boundary, |
375 std::string() , &post_data); | 375 std::string() , &post_data); |
376 CloudPrintHelpers::AddMultipartValueForUpload( | 376 CloudPrintHelpers::AddMultipartValueForUpload( |
377 kPrinterStatusValue, StringPrintf("%d", info.printer_status), | 377 kPrinterStatusValue, StringPrintf("%d", info.printer_status), |
378 mime_boundary, std::string(), &post_data); | 378 mime_boundary, std::string(), &post_data); |
| 379 // Add printer options as tags. |
| 380 std::map<std::string, std::string>::const_iterator it; |
| 381 for (it = info.options.begin(); it != info.options.end(); ++it) { |
| 382 // TODO(gene) Escape '=' char from name. Warning for now. |
| 383 if (it->first.find('=') != std::string::npos) { |
| 384 LOG(WARNING) << "CUPS option name contains '=' character"; |
| 385 NOTREACHED(); |
| 386 } |
| 387 std::string msg(it->first); |
| 388 msg += "="; |
| 389 msg += it->second; |
| 390 CloudPrintHelpers::AddMultipartValueForUpload( |
| 391 kPrinterTagValue, msg, mime_boundary, std::string(), &post_data); |
| 392 } |
379 CloudPrintHelpers::AddMultipartValueForUpload( | 393 CloudPrintHelpers::AddMultipartValueForUpload( |
380 kPrinterCapsValue, last_uploaded_printer_info_.printer_capabilities, | 394 kPrinterCapsValue, last_uploaded_printer_info_.printer_capabilities, |
381 mime_boundary, last_uploaded_printer_info_.caps_mime_type, | 395 mime_boundary, last_uploaded_printer_info_.caps_mime_type, |
382 &post_data); | 396 &post_data); |
383 CloudPrintHelpers::AddMultipartValueForUpload( | 397 CloudPrintHelpers::AddMultipartValueForUpload( |
384 kPrinterDefaultsValue, last_uploaded_printer_info_.printer_defaults, | 398 kPrinterDefaultsValue, last_uploaded_printer_info_.printer_defaults, |
385 mime_boundary, last_uploaded_printer_info_.defaults_mime_type, | 399 mime_boundary, last_uploaded_printer_info_.defaults_mime_type, |
386 &post_data); | 400 &post_data); |
387 // Send a hash of the printer capabilities to the server. We will use this | 401 // Send a hash of the printer capabilities to the server. We will use this |
388 // later to check if the capabilities have changed | 402 // later to check if the capabilities have changed |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 StartRegistration(); | 602 StartRegistration(); |
589 } | 603 } |
590 } | 604 } |
591 | 605 |
592 // PrinterJobHandler::Delegate implementation | 606 // PrinterJobHandler::Delegate implementation |
593 void CloudPrintProxyBackend::Core::OnPrinterJobHandlerShutdown( | 607 void CloudPrintProxyBackend::Core::OnPrinterJobHandlerShutdown( |
594 PrinterJobHandler* job_handler, const std::string& printer_id) { | 608 PrinterJobHandler* job_handler, const std::string& printer_id) { |
595 job_handler_map_.erase(printer_id); | 609 job_handler_map_.erase(printer_id); |
596 } | 610 } |
597 | 611 |
OLD | NEW |