| 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 "chrome/service/cloud_print/cloud_print_connector.h" | 5 #include "chrome/service/cloud_print/cloud_print_connector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 next_response_handler_ = handler; | 355 next_response_handler_ = handler; |
| 356 request_ = CloudPrintURLFetcher::Create(); | 356 request_ = CloudPrintURLFetcher::Create(); |
| 357 request_->StartPostRequest( | 357 request_->StartPostRequest( |
| 358 type, url, this, max_retries, mime_type, post_data, std::string()); | 358 type, url, this, max_retries, mime_type, post_data, std::string()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void CloudPrintConnector::ReportUserMessage(const std::string& message_id, | 361 void CloudPrintConnector::ReportUserMessage(const std::string& message_id, |
| 362 const std::string& failure_msg) { | 362 const std::string& failure_msg) { |
| 363 // This is a fire and forget type of function. | 363 // This is a fire and forget type of function. |
| 364 // Result of this request will be ignored. | 364 // Result of this request will be ignored. |
| 365 std::string mime_boundary; | 365 std::string mime_boundary = net::GenerateMimeMultipartBoundary(); |
| 366 CreateMimeBoundaryForUpload(&mime_boundary); | |
| 367 GURL url = GetUrlForUserMessage(settings_.server_url(), message_id); | 366 GURL url = GetUrlForUserMessage(settings_.server_url(), message_id); |
| 368 std::string post_data; | 367 std::string post_data; |
| 369 net::AddMultipartValueForUpload(kMessageTextValue, failure_msg, mime_boundary, | 368 net::AddMultipartValueForUpload(kMessageTextValue, failure_msg, mime_boundary, |
| 370 std::string(), &post_data); | 369 std::string(), &post_data); |
| 371 net::AddMultipartFinalDelimiterForUpload(mime_boundary, &post_data); | 370 net::AddMultipartFinalDelimiterForUpload(mime_boundary, &post_data); |
| 372 std::string mime_type("multipart/form-data; boundary="); | 371 std::string mime_type("multipart/form-data; boundary="); |
| 373 mime_type += mime_boundary; | 372 mime_type += mime_boundary; |
| 374 user_message_request_ = CloudPrintURLFetcher::Create(); | 373 user_message_request_ = CloudPrintURLFetcher::Create(); |
| 375 user_message_request_->StartPostRequest( | 374 user_message_request_->StartPostRequest( |
| 376 CloudPrintURLFetcher::REQUEST_USER_MESSAGE, url, this, 1, mime_type, | 375 CloudPrintURLFetcher::REQUEST_USER_MESSAGE, url, this, 1, mime_type, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); | 601 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); |
| 603 ReportUserMessage(kGetPrinterCapsFailedMessageId, status_message); | 602 ReportUserMessage(kGetPrinterCapsFailedMessageId, status_message); |
| 604 | 603 |
| 605 ContinuePendingTaskProcessing(); // Skip this printer registration. | 604 ContinuePendingTaskProcessing(); // Skip this printer registration. |
| 606 return; | 605 return; |
| 607 } | 606 } |
| 608 | 607 |
| 609 const printing::PrinterBasicInfo& info = pending_tasks_.front().printer_info; | 608 const printing::PrinterBasicInfo& info = pending_tasks_.front().printer_info; |
| 610 DCHECK(IsSamePrinter(info.printer_name, printer_name)); | 609 DCHECK(IsSamePrinter(info.printer_name, printer_name)); |
| 611 | 610 |
| 612 std::string mime_boundary; | 611 std::string mime_boundary = net::GenerateMimeMultipartBoundary(); |
| 613 CreateMimeBoundaryForUpload(&mime_boundary); | |
| 614 std::string post_data; | 612 std::string post_data; |
| 615 | 613 |
| 616 net::AddMultipartValueForUpload(kProxyIdValue, | 614 net::AddMultipartValueForUpload(kProxyIdValue, |
| 617 settings_.proxy_id(), mime_boundary, std::string(), &post_data); | 615 settings_.proxy_id(), mime_boundary, std::string(), &post_data); |
| 618 net::AddMultipartValueForUpload(kPrinterNameValue, | 616 net::AddMultipartValueForUpload(kPrinterNameValue, |
| 619 info.printer_name, mime_boundary, std::string(), &post_data); | 617 info.printer_name, mime_boundary, std::string(), &post_data); |
| 620 net::AddMultipartValueForUpload(kPrinterDescValue, | 618 net::AddMultipartValueForUpload(kPrinterDescValue, |
| 621 info.printer_description, mime_boundary, std::string(), &post_data); | 619 info.printer_description, mime_boundary, std::string(), &post_data); |
| 622 net::AddMultipartValueForUpload(kPrinterStatusValue, | 620 net::AddMultipartValueForUpload(kPrinterStatusValue, |
| 623 base::IntToString(info.printer_status), | 621 base::IntToString(info.printer_status), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 652 kCloudPrintAPIMaxRetryCount, mime_type, post_data, | 650 kCloudPrintAPIMaxRetryCount, mime_type, post_data, |
| 653 &CloudPrintConnector::HandleRegisterPrinterResponse); | 651 &CloudPrintConnector::HandleRegisterPrinterResponse); |
| 654 } | 652 } |
| 655 | 653 |
| 656 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, | 654 bool CloudPrintConnector::IsSamePrinter(const std::string& name1, |
| 657 const std::string& name2) const { | 655 const std::string& name2) const { |
| 658 return base::EqualsCaseInsensitiveASCII(name1, name2); | 656 return base::EqualsCaseInsensitiveASCII(name1, name2); |
| 659 } | 657 } |
| 660 | 658 |
| 661 } // namespace cloud_print | 659 } // namespace cloud_print |
| OLD | NEW |