| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/local_discovery/privet_http_impl.h" | 5 #include "chrome/browser/local_discovery/privet_http_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 url_fetcher_->Start(); | 538 url_fetcher_->Start(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void PrivetLocalPrintOperationImpl::DoCreatejob() { | 541 void PrivetLocalPrintOperationImpl::DoCreatejob() { |
| 542 current_response_ = base::Bind( | 542 current_response_ = base::Bind( |
| 543 &PrivetLocalPrintOperationImpl::OnCreatejobResponse, | 543 &PrivetLocalPrintOperationImpl::OnCreatejobResponse, |
| 544 base::Unretained(this)); | 544 base::Unretained(this)); |
| 545 | 545 |
| 546 url_fetcher_= privet_client_->CreateURLFetcher( | 546 url_fetcher_= privet_client_->CreateURLFetcher( |
| 547 CreatePrivetURL(kPrivetCreatejobPath), net::URLFetcher::POST, this); | 547 CreatePrivetURL(kPrivetCreatejobPath), net::URLFetcher::POST, this); |
| 548 url_fetcher_->SetUploadData(kPrivetContentTypeCJT, ticket_); | 548 url_fetcher_->SetUploadData(kPrivetContentTypeCJT, ticket_.ToString()); |
| 549 | 549 |
| 550 url_fetcher_->Start(); | 550 url_fetcher_->Start(); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void PrivetLocalPrintOperationImpl::DoSubmitdoc() { | 553 void PrivetLocalPrintOperationImpl::DoSubmitdoc() { |
| 554 current_response_ = base::Bind( | 554 current_response_ = base::Bind( |
| 555 &PrivetLocalPrintOperationImpl::OnSubmitdocResponse, | 555 &PrivetLocalPrintOperationImpl::OnSubmitdocResponse, |
| 556 base::Unretained(this)); | 556 base::Unretained(this)); |
| 557 | 557 |
| 558 GURL url = CreatePrivetURL(kPrivetSubmitdocPath); | 558 GURL url = CreatePrivetURL(kPrivetSubmitdocPath); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } else { | 599 } else { |
| 600 // TODO(noamsml): Move to file-based upload data? | 600 // TODO(noamsml): Move to file-based upload data? |
| 601 std::string data_str((const char*)data_->front(), data_->size()); | 601 std::string data_str((const char*)data_->front(), data_->size()); |
| 602 url_fetcher_->SetUploadData(kPrivetContentTypePDF, data_str); | 602 url_fetcher_->SetUploadData(kPrivetContentTypePDF, data_str); |
| 603 } | 603 } |
| 604 | 604 |
| 605 url_fetcher_->Start(); | 605 url_fetcher_->Start(); |
| 606 } | 606 } |
| 607 | 607 |
| 608 void PrivetLocalPrintOperationImpl::StartPrinting() { | 608 void PrivetLocalPrintOperationImpl::StartPrinting() { |
| 609 if (has_extended_workflow_ && !ticket_.empty() && jobid_.empty()) { | 609 if (has_extended_workflow_ && jobid_.empty()) { |
| 610 DoCreatejob(); | 610 DoCreatejob(); |
| 611 } else { | 611 } else { |
| 612 DoSubmitdoc(); | 612 DoSubmitdoc(); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 void PrivetLocalPrintOperationImpl::StartConvertToPWG() { | 616 void PrivetLocalPrintOperationImpl::StartConvertToPWG() { |
| 617 if (!pwg_raster_converter_) | 617 if (!pwg_raster_converter_) |
| 618 pwg_raster_converter_ = PWGRasterConverter::CreateDefault(); | 618 pwg_raster_converter_ = PWGRasterConverter::CreateDefault(); |
| 619 double scale = dpi_; | 619 double scale = dpi_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 privet_client_->RefreshPrivetToken(callback); | 755 privet_client_->RefreshPrivetToken(callback); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void PrivetLocalPrintOperationImpl::SetData(base::RefCountedBytes* data) { | 758 void PrivetLocalPrintOperationImpl::SetData(base::RefCountedBytes* data) { |
| 759 DCHECK(!started_); | 759 DCHECK(!started_); |
| 760 data_ = data; | 760 data_ = data; |
| 761 } | 761 } |
| 762 | 762 |
| 763 void PrivetLocalPrintOperationImpl::SetTicket(const std::string& ticket) { | 763 void PrivetLocalPrintOperationImpl::SetTicket(const std::string& ticket) { |
| 764 DCHECK(!started_); | 764 DCHECK(!started_); |
| 765 ticket_ = ticket; | 765 ticket_.InitFromString(ticket); |
| 766 } |
| 767 |
| 768 void PrivetLocalPrintOperationImpl::SetCapabilities( |
| 769 const std::string& capabilities) { |
| 770 DCHECK(!started_); |
| 771 capabilities_.InitFromString(capabilities); |
| 766 } | 772 } |
| 767 | 773 |
| 768 void PrivetLocalPrintOperationImpl::SetUsername(const std::string& user) { | 774 void PrivetLocalPrintOperationImpl::SetUsername(const std::string& user) { |
| 769 DCHECK(!started_); | 775 DCHECK(!started_); |
| 770 user_= user; | 776 user_= user; |
| 771 } | 777 } |
| 772 | 778 |
| 773 void PrivetLocalPrintOperationImpl::SetJobname(const std::string& jobname) { | 779 void PrivetLocalPrintOperationImpl::SetJobname(const std::string& jobname) { |
| 774 DCHECK(!started_); | 780 DCHECK(!started_); |
| 775 jobname_ = jobname; | 781 jobname_ = jobname; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 TokenCallbackVector token_callbacks; | 900 TokenCallbackVector token_callbacks; |
| 895 token_callbacks_.swap(token_callbacks); | 901 token_callbacks_.swap(token_callbacks); |
| 896 | 902 |
| 897 for (TokenCallbackVector::iterator i = token_callbacks.begin(); | 903 for (TokenCallbackVector::iterator i = token_callbacks.begin(); |
| 898 i != token_callbacks.end(); i++) { | 904 i != token_callbacks.end(); i++) { |
| 899 i->Run(token); | 905 i->Run(token); |
| 900 } | 906 } |
| 901 } | 907 } |
| 902 | 908 |
| 903 } // namespace local_discovery | 909 } // namespace local_discovery |
| OLD | NEW |