OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "printing/backend/print_backend.h" | 5 #include "printing/backend/print_backend.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "printing/backend/print_backend_consts.h" | 9 #include "printing/backend/print_backend_consts.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 #if defined(USE_CUPS) | 12 #if defined(USE_CUPS) |
13 #include "printing/backend/print_backend_cups.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "printing/backend/print_backend_cups_ipp.h" |
14 #endif // defined(USE_CUPS) | 15 #endif // defined(USE_CUPS) |
15 | 16 |
16 namespace printing { | 17 namespace printing { |
17 | 18 |
18 // Provides a stubbed out PrintBackend implementation for use on ChromeOS. | 19 // Provides either a stubbed out PrintBackend implementation or a CUPS IPP |
| 20 // implementation for use on ChromeOS. |
19 class PrintBackendChromeOS : public PrintBackend { | 21 class PrintBackendChromeOS : public PrintBackend { |
20 public: | 22 public: |
21 PrintBackendChromeOS(); | 23 PrintBackendChromeOS(); |
22 | 24 |
23 // PrintBackend implementation. | 25 // PrintBackend implementation. |
24 bool EnumeratePrinters(PrinterList* printer_list) override; | 26 bool EnumeratePrinters(PrinterList* printer_list) override; |
25 std::string GetDefaultPrinterName() override; | 27 std::string GetDefaultPrinterName() override; |
26 bool GetPrinterBasicInfo(const std::string& printer_name, | 28 bool GetPrinterBasicInfo(const std::string& printer_name, |
27 PrinterBasicInfo* printer_info) override; | 29 PrinterBasicInfo* printer_info) override; |
28 bool GetPrinterSemanticCapsAndDefaults( | 30 bool GetPrinterSemanticCapsAndDefaults( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 int encryption = HTTP_ENCRYPT_NEVER; | 88 int encryption = HTTP_ENCRYPT_NEVER; |
87 if (print_backend_settings) { | 89 if (print_backend_settings) { |
88 print_backend_settings->GetString(kCUPSPrintServerURL, | 90 print_backend_settings->GetString(kCUPSPrintServerURL, |
89 &print_server_url_str); | 91 &print_server_url_str); |
90 | 92 |
91 print_backend_settings->GetString(kCUPSBlocking, &cups_blocking); | 93 print_backend_settings->GetString(kCUPSBlocking, &cups_blocking); |
92 | 94 |
93 print_backend_settings->GetInteger(kCUPSEncryption, &encryption); | 95 print_backend_settings->GetInteger(kCUPSEncryption, &encryption); |
94 } | 96 } |
95 GURL print_server_url(print_server_url_str.c_str()); | 97 GURL print_server_url(print_server_url_str.c_str()); |
96 return new PrintBackendCUPS(print_server_url, | 98 |
97 static_cast<http_encryption_t>(encryption), | 99 std::unique_ptr<CupsConnection> connection = |
98 cups_blocking == kValueTrue); | 100 base::MakeUnique<CupsConnection>( |
| 101 print_server_url, static_cast<http_encryption_t>(encryption), |
| 102 cups_blocking == kValueTrue); |
| 103 |
| 104 return new PrintBackendCupsIpp(std::move(connection)); |
99 #endif // defined(USE_CUPS) | 105 #endif // defined(USE_CUPS) |
100 } | 106 } |
101 | 107 |
102 return new PrintBackendChromeOS(); | 108 return new PrintBackendChromeOS(); |
103 } | 109 } |
104 | 110 |
105 } // namespace printing | 111 } // namespace printing |
OLD | NEW |