Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/local_discovery/privet_http_impl.cc

Issue 702603004: Renamed DISABLE_BASIC_PRINTING and ENABLE_FULL_PRINTING. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wed Nov 5 02:31:54 PST 2014 Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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) 24 #if defined(ENABLE_PRINT_PREVIEW)
25 #include "chrome/browser/local_discovery/pwg_raster_converter.h" 25 #include "chrome/browser/local_discovery/pwg_raster_converter.h"
26 #endif // ENABLE_FULL_PRINTING 26 #endif // ENABLE_PRINT_PREVIEW
27 27
28 using namespace cloud_devices::printer; 28 using namespace cloud_devices::printer;
29 29
30 namespace cloud_print { 30 namespace cloud_print {
31 extern const char kContentTypeJSON[]; 31 extern const char kContentTypeJSON[];
32 } 32 }
33 33
34 namespace local_discovery { 34 namespace local_discovery {
35 35
36 namespace { 36 namespace {
37 const char kUrlPlaceHolder[] = "http://host/"; 37 const char kUrlPlaceHolder[] = "http://host/";
38 const char kPrivetRegisterActionArgName[] = "action"; 38 const char kPrivetRegisterActionArgName[] = "action";
39 const char kPrivetRegisterUserArgName[] = "user"; 39 const char kPrivetRegisterUserArgName[] = "user";
40 40
41 const int kPrivetCancelationTimeoutSeconds = 3; 41 const int kPrivetCancelationTimeoutSeconds = 3;
42 42
43 #if defined(ENABLE_FULL_PRINTING) 43 #if defined(ENABLE_PRINT_PREVIEW)
44 const char kPrivetURLKeyUserName[] = "user_name"; 44 const char kPrivetURLKeyUserName[] = "user_name";
45 const char kPrivetURLKeyClientName[] = "client_name"; 45 const char kPrivetURLKeyClientName[] = "client_name";
46 const char kPrivetURLKeyJobname[] = "job_name"; 46 const char kPrivetURLKeyJobname[] = "job_name";
47 const char kPrivetURLKeyOffline[] = "offline"; 47 const char kPrivetURLKeyOffline[] = "offline";
48 const char kPrivetURLValueOffline[] = "1"; 48 const char kPrivetURLValueOffline[] = "1";
49 const char kPrivetURLValueClientName[] = "Chrome"; 49 const char kPrivetURLValueClientName[] = "Chrome";
50 50
51 const char kPrivetContentTypePDF[] = "application/pdf"; 51 const char kPrivetContentTypePDF[] = "application/pdf";
52 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster"; 52 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster";
53 const char kPrivetContentTypeAny[] = "*/*"; 53 const char kPrivetContentTypeAny[] = "*/*";
54 54
55 const char kPrivetKeyJobID[] = "job_id"; 55 const char kPrivetKeyJobID[] = "job_id";
56 56
57 const int kPrivetLocalPrintMaxRetries = 2; 57 const int kPrivetLocalPrintMaxRetries = 2;
58 const int kPrivetLocalPrintDefaultTimeout = 5; 58 const int kPrivetLocalPrintDefaultTimeout = 5;
59 59
60 const size_t kPrivetLocalPrintMaxJobNameLength = 64; 60 const size_t kPrivetLocalPrintMaxJobNameLength = 64;
61 #endif // ENABLE_FULL_PRINTING 61 #endif // ENABLE_PRINT_PREVIEW
62 62
63 GURL CreatePrivetURL(const std::string& path) { 63 GURL CreatePrivetURL(const std::string& path) {
64 GURL url(kUrlPlaceHolder); 64 GURL url(kUrlPlaceHolder);
65 GURL::Replacements replacements; 65 GURL::Replacements replacements;
66 replacements.SetPathStr(path); 66 replacements.SetPathStr(path);
67 return url.ReplaceComponents(replacements); 67 return url.ReplaceComponents(replacements);
68 } 68 }
69 69
70 GURL CreatePrivetRegisterURL(const std::string& action, 70 GURL CreatePrivetRegisterURL(const std::string& action,
71 const std::string& user) { 71 const std::string& user) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 458
459 bool PrivetDataReadOperationImpl::OnRawData(PrivetURLFetcher* fetcher, 459 bool PrivetDataReadOperationImpl::OnRawData(PrivetURLFetcher* fetcher,
460 bool is_file, 460 bool is_file,
461 const std::string& data_str, 461 const std::string& data_str,
462 const base::FilePath& file_path) { 462 const base::FilePath& file_path) {
463 ResponseType type = (is_file) ? RESPONSE_TYPE_FILE : RESPONSE_TYPE_STRING; 463 ResponseType type = (is_file) ? RESPONSE_TYPE_FILE : RESPONSE_TYPE_STRING;
464 callback_.Run(type, data_str, file_path); 464 callback_.Run(type, data_str, file_path);
465 return true; 465 return true;
466 } 466 }
467 467
468 #if defined(ENABLE_FULL_PRINTING) 468 #if defined(ENABLE_PRINT_PREVIEW)
469 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl( 469 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl(
470 PrivetHTTPClient* privet_client, 470 PrivetHTTPClient* privet_client,
471 PrivetLocalPrintOperation::Delegate* delegate) 471 PrivetLocalPrintOperation::Delegate* delegate)
472 : privet_client_(privet_client), 472 : privet_client_(privet_client),
473 delegate_(delegate), 473 delegate_(delegate),
474 use_pdf_(false), 474 use_pdf_(false),
475 has_extended_workflow_(false), 475 has_extended_workflow_(false),
476 started_(false), 476 started_(false),
477 offline_(false), 477 offline_(false),
478 dpi_(printing::kDefaultPdfDpi), 478 dpi_(printing::kDefaultPdfDpi),
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 818
819 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) { 819 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) {
820 DCHECK(!started_); 820 DCHECK(!started_);
821 page_size_ = page_size; 821 page_size_ = page_size;
822 } 822 }
823 823
824 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting( 824 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting(
825 scoped_ptr<PWGRasterConverter> pwg_raster_converter) { 825 scoped_ptr<PWGRasterConverter> pwg_raster_converter) {
826 pwg_raster_converter_ = pwg_raster_converter.Pass(); 826 pwg_raster_converter_ = pwg_raster_converter.Pass();
827 } 827 }
828 #endif // ENABLE_FULL_PRINTING 828 #endif // ENABLE_PRINT_PREVIEW
829 829
830 PrivetHTTPClientImpl::PrivetHTTPClientImpl( 830 PrivetHTTPClientImpl::PrivetHTTPClientImpl(
831 const std::string& name, 831 const std::string& name,
832 const net::HostPortPair& host_port, 832 const net::HostPortPair& host_port,
833 net::URLRequestContextGetter* request_context) 833 net::URLRequestContextGetter* request_context)
834 : name_(name), request_context_(request_context), host_port_(host_port) {} 834 : name_(name), request_context_(request_context), host_port_(host_port) {}
835 835
836 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() { 836 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() {
837 } 837 }
838 838
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 scoped_ptr<PrivetJSONOperation> 921 scoped_ptr<PrivetJSONOperation>
922 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation( 922 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation(
923 const PrivetJSONOperation::ResultCallback& callback) { 923 const PrivetJSONOperation::ResultCallback& callback) {
924 return scoped_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl( 924 return scoped_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl(
925 info_client(), kPrivetCapabilitiesPath, "", callback)); 925 info_client(), kPrivetCapabilitiesPath, "", callback));
926 } 926 }
927 927
928 scoped_ptr<PrivetLocalPrintOperation> 928 scoped_ptr<PrivetLocalPrintOperation>
929 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( 929 PrivetV1HTTPClientImpl::CreateLocalPrintOperation(
930 PrivetLocalPrintOperation::Delegate* delegate) { 930 PrivetLocalPrintOperation::Delegate* delegate) {
931 #if defined(ENABLE_FULL_PRINTING) 931 #if defined(ENABLE_PRINT_PREVIEW)
932 return scoped_ptr<PrivetLocalPrintOperation>( 932 return scoped_ptr<PrivetLocalPrintOperation>(
933 new PrivetLocalPrintOperationImpl(info_client(), delegate)); 933 new PrivetLocalPrintOperationImpl(info_client(), delegate));
934 #else 934 #else
935 return scoped_ptr<PrivetLocalPrintOperation>(); 935 return scoped_ptr<PrivetLocalPrintOperation>();
936 #endif // ENABLE_FULL_PRINTING 936 #endif // ENABLE_PRINT_PREVIEW
937 } 937 }
938 938
939 } // namespace local_discovery 939 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698