| 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/printing/cloud_print/privet_http_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 19 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 19 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
| 20 #include "chrome/browser/local_discovery/privet_constants.h" | 20 #include "chrome/browser/printing/cloud_print/privet_constants.h" |
| 21 #include "chrome/common/chrome_content_client.h" | 21 #include "chrome/common/chrome_content_client.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/cloud_print/cloud_print_constants.h" | 23 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 24 #include "net/base/url_util.h" | 24 #include "net/base/url_util.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 #if defined(ENABLE_PRINT_PREVIEW) | 27 #if defined(ENABLE_PRINT_PREVIEW) |
| 28 #include "chrome/browser/local_discovery/pwg_raster_converter.h" | 28 #include "chrome/browser/printing/pwg_raster_converter.h" |
| 29 #include "components/cloud_devices/common/printer_description.h" | 29 #include "components/cloud_devices/common/printer_description.h" |
| 30 #include "printing/pdf_render_settings.h" | 30 #include "printing/pdf_render_settings.h" |
| 31 #include "printing/pwg_raster_settings.h" | 31 #include "printing/pwg_raster_settings.h" |
| 32 #include "ui/gfx/text_elider.h" | 32 #include "ui/gfx/text_elider.h" |
| 33 #endif // ENABLE_PRINT_PREVIEW | 33 #endif // ENABLE_PRINT_PREVIEW |
| 34 | 34 |
| 35 namespace local_discovery { | 35 namespace cloud_print { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 const char kUrlPlaceHolder[] = "http://host/"; | 39 const char kUrlPlaceHolder[] = "http://host/"; |
| 40 const char kPrivetRegisterActionArgName[] = "action"; | 40 const char kPrivetRegisterActionArgName[] = "action"; |
| 41 const char kPrivetRegisterUserArgName[] = "user"; | 41 const char kPrivetRegisterUserArgName[] = "user"; |
| 42 | 42 |
| 43 const int kPrivetCancelationTimeoutSeconds = 3; | 43 const int kPrivetCancelationTimeoutSeconds = 3; |
| 44 | 44 |
| 45 #if defined(ENABLE_PRINT_PREVIEW) | 45 #if defined(ENABLE_PRINT_PREVIEW) |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 void PrivetLocalPrintOperationImpl::StartPrinting() { | 539 void PrivetLocalPrintOperationImpl::StartPrinting() { |
| 540 if (has_extended_workflow_ && jobid_.empty()) { | 540 if (has_extended_workflow_ && jobid_.empty()) { |
| 541 DoCreatejob(); | 541 DoCreatejob(); |
| 542 } else { | 542 } else { |
| 543 DoSubmitdoc(); | 543 DoSubmitdoc(); |
| 544 } | 544 } |
| 545 } | 545 } |
| 546 | 546 |
| 547 void PrivetLocalPrintOperationImpl::StartConvertToPWG() { | 547 void PrivetLocalPrintOperationImpl::StartConvertToPWG() { |
| 548 using printing::PWGRasterConverter; |
| 548 if (!pwg_raster_converter_) | 549 if (!pwg_raster_converter_) |
| 549 pwg_raster_converter_ = PWGRasterConverter::CreateDefault(); | 550 pwg_raster_converter_ = PWGRasterConverter::CreateDefault(); |
| 550 | 551 |
| 551 pwg_raster_converter_->Start( | 552 pwg_raster_converter_->Start( |
| 552 data_.get(), | 553 data_.get(), |
| 553 PWGRasterConverter::GetConversionSettings(capabilities_, page_size_), | 554 PWGRasterConverter::GetConversionSettings(capabilities_, page_size_), |
| 554 PWGRasterConverter::GetBitmapSettings(capabilities_, ticket_), | 555 PWGRasterConverter::GetBitmapSettings(capabilities_, ticket_), |
| 555 base::Bind(&PrivetLocalPrintOperationImpl::OnPWGRasterConverted, | 556 base::Bind(&PrivetLocalPrintOperationImpl::OnPWGRasterConverted, |
| 556 base::Unretained(this))); | 557 base::Unretained(this))); |
| 557 } | 558 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 DCHECK(!started_); | 683 DCHECK(!started_); |
| 683 offline_ = offline; | 684 offline_ = offline; |
| 684 } | 685 } |
| 685 | 686 |
| 686 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) { | 687 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) { |
| 687 DCHECK(!started_); | 688 DCHECK(!started_); |
| 688 page_size_ = page_size; | 689 page_size_ = page_size; |
| 689 } | 690 } |
| 690 | 691 |
| 691 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting( | 692 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting( |
| 692 scoped_ptr<PWGRasterConverter> pwg_raster_converter) { | 693 scoped_ptr<printing::PWGRasterConverter> pwg_raster_converter) { |
| 693 pwg_raster_converter_ = std::move(pwg_raster_converter); | 694 pwg_raster_converter_ = std::move(pwg_raster_converter); |
| 694 } | 695 } |
| 695 #endif // ENABLE_PRINT_PREVIEW | 696 #endif // ENABLE_PRINT_PREVIEW |
| 696 | 697 |
| 697 PrivetHTTPClientImpl::PrivetHTTPClientImpl( | 698 PrivetHTTPClientImpl::PrivetHTTPClientImpl( |
| 698 const std::string& name, | 699 const std::string& name, |
| 699 const net::HostPortPair& host_port, | 700 const net::HostPortPair& host_port, |
| 700 const scoped_refptr<net::URLRequestContextGetter>& context_getter) | 701 const scoped_refptr<net::URLRequestContextGetter>& context_getter) |
| 701 : name_(name), context_getter_(context_getter), host_port_(host_port) {} | 702 : name_(name), context_getter_(context_getter), host_port_(host_port) {} |
| 702 | 703 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( | 795 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( |
| 795 PrivetLocalPrintOperation::Delegate* delegate) { | 796 PrivetLocalPrintOperation::Delegate* delegate) { |
| 796 #if defined(ENABLE_PRINT_PREVIEW) | 797 #if defined(ENABLE_PRINT_PREVIEW) |
| 797 return scoped_ptr<PrivetLocalPrintOperation>( | 798 return scoped_ptr<PrivetLocalPrintOperation>( |
| 798 new PrivetLocalPrintOperationImpl(info_client(), delegate)); | 799 new PrivetLocalPrintOperationImpl(info_client(), delegate)); |
| 799 #else | 800 #else |
| 800 return scoped_ptr<PrivetLocalPrintOperation>(); | 801 return scoped_ptr<PrivetLocalPrintOperation>(); |
| 801 #endif // ENABLE_PRINT_PREVIEW | 802 #endif // ENABLE_PRINT_PREVIEW |
| 802 } | 803 } |
| 803 | 804 |
| 804 } // namespace local_discovery | 805 } // namespace cloud_print |
| OLD | NEW |