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" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/local_discovery/privet_constants.h" | 16 #include "chrome/browser/local_discovery/privet_constants.h" |
17 #include "components/cloud_devices/common/printer_description.h" | 17 #include "components/cloud_devices/common/printer_description.h" |
18 #include "net/base/url_util.h" | 18 #include "net/base/url_util.h" |
19 #include "printing/pwg_raster_settings.h" | 19 #include "printing/pwg_raster_settings.h" |
20 #include "printing/units.h" | 20 #include "printing/units.h" |
21 #include "ui/gfx/text_elider.h" | 21 #include "ui/gfx/text_elider.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
| 24 #if defined(ENABLE_FULL_PRINTING) |
| 25 #include "chrome/browser/local_discovery/pwg_raster_converter.h" |
| 26 #endif // ENABLE_FULL_PRINTING |
| 27 |
24 using namespace cloud_devices::printer; | 28 using namespace cloud_devices::printer; |
25 | 29 |
26 namespace cloud_print { | 30 namespace cloud_print { |
27 extern const char kContentTypeJSON[]; | 31 extern const char kContentTypeJSON[]; |
28 } | 32 } |
29 | 33 |
30 namespace local_discovery { | 34 namespace local_discovery { |
31 | 35 |
32 namespace { | 36 namespace { |
33 const char kUrlPlaceHolder[] = "http://host/"; | 37 const char kUrlPlaceHolder[] = "http://host/"; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 457 |
454 bool PrivetDataReadOperationImpl::OnRawData(PrivetURLFetcher* fetcher, | 458 bool PrivetDataReadOperationImpl::OnRawData(PrivetURLFetcher* fetcher, |
455 bool is_file, | 459 bool is_file, |
456 const std::string& data_str, | 460 const std::string& data_str, |
457 const base::FilePath& file_path) { | 461 const base::FilePath& file_path) { |
458 ResponseType type = (is_file) ? RESPONSE_TYPE_FILE : RESPONSE_TYPE_STRING; | 462 ResponseType type = (is_file) ? RESPONSE_TYPE_FILE : RESPONSE_TYPE_STRING; |
459 callback_.Run(type, data_str, file_path); | 463 callback_.Run(type, data_str, file_path); |
460 return true; | 464 return true; |
461 } | 465 } |
462 | 466 |
| 467 #if defined(ENABLE_FULL_PRINTING) |
463 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl( | 468 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl( |
464 PrivetHTTPClient* privet_client, | 469 PrivetHTTPClient* privet_client, |
465 PrivetLocalPrintOperation::Delegate* delegate) | 470 PrivetLocalPrintOperation::Delegate* delegate) |
466 : privet_client_(privet_client), | 471 : privet_client_(privet_client), |
467 delegate_(delegate), | 472 delegate_(delegate), |
468 use_pdf_(false), | 473 use_pdf_(false), |
469 has_extended_workflow_(false), | 474 has_extended_workflow_(false), |
470 started_(false), | 475 started_(false), |
471 offline_(false), | 476 offline_(false), |
472 dpi_(printing::kDefaultPdfDpi), | 477 dpi_(printing::kDefaultPdfDpi), |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 817 |
813 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) { | 818 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) { |
814 DCHECK(!started_); | 819 DCHECK(!started_); |
815 page_size_ = page_size; | 820 page_size_ = page_size; |
816 } | 821 } |
817 | 822 |
818 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting( | 823 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting( |
819 scoped_ptr<PWGRasterConverter> pwg_raster_converter) { | 824 scoped_ptr<PWGRasterConverter> pwg_raster_converter) { |
820 pwg_raster_converter_ = pwg_raster_converter.Pass(); | 825 pwg_raster_converter_ = pwg_raster_converter.Pass(); |
821 } | 826 } |
| 827 #endif // ENABLE_FULL_PRINTING |
822 | 828 |
823 PrivetHTTPClientImpl::PrivetHTTPClientImpl( | 829 PrivetHTTPClientImpl::PrivetHTTPClientImpl( |
824 const std::string& name, | 830 const std::string& name, |
825 const net::HostPortPair& host_port, | 831 const net::HostPortPair& host_port, |
826 net::URLRequestContextGetter* request_context) | 832 net::URLRequestContextGetter* request_context) |
827 : name_(name), request_context_(request_context), host_port_(host_port) {} | 833 : name_(name), request_context_(request_context), host_port_(host_port) {} |
828 | 834 |
829 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() { | 835 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() { |
830 } | 836 } |
831 | 837 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 scoped_ptr<PrivetJSONOperation> | 920 scoped_ptr<PrivetJSONOperation> |
915 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation( | 921 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation( |
916 const PrivetJSONOperation::ResultCallback& callback) { | 922 const PrivetJSONOperation::ResultCallback& callback) { |
917 return scoped_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl( | 923 return scoped_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl( |
918 info_client(), kPrivetCapabilitiesPath, "", callback)); | 924 info_client(), kPrivetCapabilitiesPath, "", callback)); |
919 } | 925 } |
920 | 926 |
921 scoped_ptr<PrivetLocalPrintOperation> | 927 scoped_ptr<PrivetLocalPrintOperation> |
922 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( | 928 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( |
923 PrivetLocalPrintOperation::Delegate* delegate) { | 929 PrivetLocalPrintOperation::Delegate* delegate) { |
| 930 #if defined(ENABLE_FULL_PRINTING) |
924 return scoped_ptr<PrivetLocalPrintOperation>( | 931 return scoped_ptr<PrivetLocalPrintOperation>( |
925 new PrivetLocalPrintOperationImpl(info_client(), delegate)); | 932 new PrivetLocalPrintOperationImpl(info_client(), delegate)); |
| 933 #else |
| 934 return scoped_ptr<PrivetLocalPrintOperation>(); |
| 935 #endif // ENABLE_FULL_PRINTING |
926 } | 936 } |
927 | 937 |
928 } // namespace local_discovery | 938 } // namespace local_discovery |
OLD | NEW |