| 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/printing/cloud_print/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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 21 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
| 22 #include "chrome/browser/printing/cloud_print/privet_constants.h" | 22 #include "chrome/browser/printing/cloud_print/privet_constants.h" |
| 23 #include "chrome/common/chrome_content_client.h" | 23 #include "chrome/common/chrome_content_client.h" |
| 24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/cloud_print/cloud_print_constants.h" | 25 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 26 #include "net/base/url_util.h" | 26 #include "net/base/url_util.h" |
| 27 #include "printing/features/features.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 #if defined(ENABLE_PRINT_PREVIEW) | 30 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 30 #include "chrome/browser/printing/pwg_raster_converter.h" | 31 #include "chrome/browser/printing/pwg_raster_converter.h" |
| 31 #include "components/cloud_devices/common/printer_description.h" | 32 #include "components/cloud_devices/common/printer_description.h" |
| 32 #include "printing/pdf_render_settings.h" | 33 #include "printing/pdf_render_settings.h" |
| 33 #include "printing/pwg_raster_settings.h" | 34 #include "printing/pwg_raster_settings.h" |
| 34 #include "ui/gfx/text_elider.h" | 35 #include "ui/gfx/text_elider.h" |
| 35 #endif // ENABLE_PRINT_PREVIEW | 36 #endif // ENABLE_PRINT_PREVIEW |
| 36 | 37 |
| 37 namespace cloud_print { | 38 namespace cloud_print { |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 const char kUrlPlaceHolder[] = "http://host/"; | 42 const char kUrlPlaceHolder[] = "http://host/"; |
| 42 const char kPrivetRegisterActionArgName[] = "action"; | 43 const char kPrivetRegisterActionArgName[] = "action"; |
| 43 const char kPrivetRegisterUserArgName[] = "user"; | 44 const char kPrivetRegisterUserArgName[] = "user"; |
| 44 | 45 |
| 45 const int kPrivetCancelationTimeoutSeconds = 3; | 46 const int kPrivetCancelationTimeoutSeconds = 3; |
| 46 | 47 |
| 47 #if defined(ENABLE_PRINT_PREVIEW) | 48 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 48 const char kPrivetURLKeyUserName[] = "user_name"; | 49 const char kPrivetURLKeyUserName[] = "user_name"; |
| 49 const char kPrivetURLKeyClientName[] = "client_name"; | 50 const char kPrivetURLKeyClientName[] = "client_name"; |
| 50 const char kPrivetURLKeyJobname[] = "job_name"; | 51 const char kPrivetURLKeyJobname[] = "job_name"; |
| 51 const char kPrivetURLKeyOffline[] = "offline"; | 52 const char kPrivetURLKeyOffline[] = "offline"; |
| 52 const char kPrivetURLValueOffline[] = "1"; | 53 const char kPrivetURLValueOffline[] = "1"; |
| 53 const char kPrivetURLValueClientName[] = "Chrome"; | 54 const char kPrivetURLValueClientName[] = "Chrome"; |
| 54 | 55 |
| 55 const char kPrivetContentTypePDF[] = "application/pdf"; | 56 const char kPrivetContentTypePDF[] = "application/pdf"; |
| 56 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster"; | 57 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster"; |
| 57 const char kPrivetContentTypeAny[] = "*/*"; | 58 const char kPrivetContentTypeAny[] = "*/*"; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 bool has_error) { | 388 bool has_error) { |
| 388 callback_.Run(&value); | 389 callback_.Run(&value); |
| 389 } | 390 } |
| 390 | 391 |
| 391 void PrivetJSONOperationImpl::OnNeedPrivetToken( | 392 void PrivetJSONOperationImpl::OnNeedPrivetToken( |
| 392 PrivetURLFetcher* fetcher, | 393 PrivetURLFetcher* fetcher, |
| 393 const PrivetURLFetcher::TokenCallback& callback) { | 394 const PrivetURLFetcher::TokenCallback& callback) { |
| 394 privet_client_->RefreshPrivetToken(callback); | 395 privet_client_->RefreshPrivetToken(callback); |
| 395 } | 396 } |
| 396 | 397 |
| 397 #if defined(ENABLE_PRINT_PREVIEW) | 398 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 398 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl( | 399 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl( |
| 399 PrivetHTTPClient* privet_client, | 400 PrivetHTTPClient* privet_client, |
| 400 PrivetLocalPrintOperation::Delegate* delegate) | 401 PrivetLocalPrintOperation::Delegate* delegate) |
| 401 : privet_client_(privet_client), | 402 : privet_client_(privet_client), |
| 402 delegate_(delegate), | 403 delegate_(delegate), |
| 403 use_pdf_(false), | 404 use_pdf_(false), |
| 404 has_extended_workflow_(false), | 405 has_extended_workflow_(false), |
| 405 started_(false), | 406 started_(false), |
| 406 offline_(false), | 407 offline_(false), |
| 407 invalid_job_retries_(0), | 408 invalid_job_retries_(0), |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 std::unique_ptr<PrivetJSONOperation> | 791 std::unique_ptr<PrivetJSONOperation> |
| 791 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation( | 792 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation( |
| 792 const PrivetJSONOperation::ResultCallback& callback) { | 793 const PrivetJSONOperation::ResultCallback& callback) { |
| 793 return std::unique_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl( | 794 return std::unique_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl( |
| 794 info_client(), kPrivetCapabilitiesPath, "", callback)); | 795 info_client(), kPrivetCapabilitiesPath, "", callback)); |
| 795 } | 796 } |
| 796 | 797 |
| 797 std::unique_ptr<PrivetLocalPrintOperation> | 798 std::unique_ptr<PrivetLocalPrintOperation> |
| 798 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( | 799 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( |
| 799 PrivetLocalPrintOperation::Delegate* delegate) { | 800 PrivetLocalPrintOperation::Delegate* delegate) { |
| 800 #if defined(ENABLE_PRINT_PREVIEW) | 801 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 801 return std::unique_ptr<PrivetLocalPrintOperation>( | 802 return std::unique_ptr<PrivetLocalPrintOperation>( |
| 802 new PrivetLocalPrintOperationImpl(info_client(), delegate)); | 803 new PrivetLocalPrintOperationImpl(info_client(), delegate)); |
| 803 #else | 804 #else |
| 804 return std::unique_ptr<PrivetLocalPrintOperation>(); | 805 return std::unique_ptr<PrivetLocalPrintOperation>(); |
| 805 #endif // ENABLE_PRINT_PREVIEW | 806 #endif // ENABLE_PRINT_PREVIEW |
| 806 } | 807 } |
| 807 | 808 |
| 808 } // namespace cloud_print | 809 } // namespace cloud_print |
| OLD | NEW |