diff options
author | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 23:07:30 +0000 |
---|---|---|
committer | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 23:07:30 +0000 |
commit | ce6f591cf3cd7fe9c4a2cf40ffa9f70db20d2865 (patch) | |
tree | b014617d73b0e21c5090bd9f1d830a1f012c99d4 /printing/backend | |
parent | 30b33994dbd7d1e7b28725eab3cb098dcf8ceca9 (diff) | |
download | chromium_src-ce6f591cf3cd7fe9c4a2cf40ffa9f70db20d2865.zip chromium_src-ce6f591cf3cd7fe9c4a2cf40ffa9f70db20d2865.tar.gz chromium_src-ce6f591cf3cd7fe9c4a2cf40ffa9f70db20d2865.tar.bz2 |
Adding functionality to specify TLS encryption CUPS print servers for cloudprint connector.
BUG=127858
TEST=add 'cups_encryption' filed to 'Service State' file in print settings section. Value should be 0..4 (see http_encryption_t for possible values).
Review URL: https://chromiumcodereview.appspot.com/10399050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/backend')
-rw-r--r-- | printing/backend/cups_helper.cc | 7 | ||||
-rw-r--r-- | printing/backend/cups_helper.h | 5 | ||||
-rw-r--r-- | printing/backend/print_backend_consts.cc | 1 | ||||
-rw-r--r-- | printing/backend/print_backend_consts.h | 1 | ||||
-rw-r--r-- | printing/backend/print_backend_cups.cc | 23 |
5 files changed, 26 insertions, 11 deletions
diff --git a/printing/backend/cups_helper.cc b/printing/backend/cups_helper.cc index 7df5302..7fc6983 100644 --- a/printing/backend/cups_helper.cc +++ b/printing/backend/cups_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,8 @@ static const int kDefaultIPPServerPort = 631; // Helper wrapper around http_t structure, with connection and cleanup // functionality. -HttpConnectionCUPS::HttpConnectionCUPS(const GURL& print_server_url) +HttpConnectionCUPS::HttpConnectionCUPS(const GURL& print_server_url, + http_encryption_t encryption) : http_(NULL) { // If we have an empty url, use default print server. if (print_server_url.is_empty()) @@ -25,7 +26,7 @@ HttpConnectionCUPS::HttpConnectionCUPS(const GURL& print_server_url) port = kDefaultIPPServerPort; http_ = httpConnectEncrypt(print_server_url.host().c_str(), port, - HTTP_ENCRYPT_NEVER); + encryption); if (http_ == NULL) { LOG(ERROR) << "CP_CUPS: Failed connecting to print server: " << print_server_url; diff --git a/printing/backend/cups_helper.h b/printing/backend/cups_helper.h index ee1de9a..09052f9 100644 --- a/printing/backend/cups_helper.h +++ b/printing/backend/cups_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,8 @@ namespace printing { // functionality. class PRINTING_EXPORT HttpConnectionCUPS { public: - explicit HttpConnectionCUPS(const GURL& print_server_url); + HttpConnectionCUPS(const GURL& print_server_url, + http_encryption_t encryption); ~HttpConnectionCUPS(); void SetBlocking(bool blocking); diff --git a/printing/backend/print_backend_consts.cc b/printing/backend/print_backend_consts.cc index 43bd89f..8b2f6db 100644 --- a/printing/backend/print_backend_consts.cc +++ b/printing/backend/print_backend_consts.cc @@ -11,5 +11,6 @@ const char kDriverNameTagName[] = "drivername"; const char kDriverInfoTagName[] = "system_driverinfo"; const char kCUPSPrintServerURL[] = "print_server_url"; const char kCUPSBlocking[] = "cups_blocking"; +const char kCUPSEncryption[] = "cups_encryption"; const char kValueTrue[] = "true"; const char kValueFalse[] = "false"; diff --git a/printing/backend/print_backend_consts.h b/printing/backend/print_backend_consts.h index 88b01fb..c0a63db 100644 --- a/printing/backend/print_backend_consts.h +++ b/printing/backend/print_backend_consts.h @@ -13,6 +13,7 @@ PRINTING_EXPORT extern const char kDriverNameTagName[]; PRINTING_EXPORT extern const char kDriverInfoTagName[]; PRINTING_EXPORT extern const char kCUPSPrintServerURL[]; PRINTING_EXPORT extern const char kCUPSBlocking[]; +PRINTING_EXPORT extern const char kCUPSEncryption[]; PRINTING_EXPORT extern const char kValueTrue[]; PRINTING_EXPORT extern const char kValueFalse[]; diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc index 9bba09a..db606c8 100644 --- a/printing/backend/print_backend_cups.cc +++ b/printing/backend/print_backend_cups.cc @@ -102,7 +102,8 @@ static const char kCUPSPrinterMakeModelOpt[] = "printer-make-and-model"; class PrintBackendCUPS : public PrintBackend { public: - PrintBackendCUPS(const GURL& print_server_url, bool blocking); + PrintBackendCUPS(const GURL& print_server_url, + http_encryption_t encryption, bool blocking); // PrintBackend implementation. virtual bool EnumeratePrinters(PrinterList* printer_list) OVERRIDE; @@ -126,11 +127,16 @@ class PrintBackendCUPS : public PrintBackend { FilePath GetPPD(const char* name); GURL print_server_url_; + http_encryption_t cups_encryption_; bool blocking_; }; -PrintBackendCUPS::PrintBackendCUPS(const GURL& print_server_url, bool blocking) - : print_server_url_(print_server_url), blocking_(blocking) { +PrintBackendCUPS::PrintBackendCUPS(const GURL& print_server_url, + http_encryption_t encryption, + bool blocking) + : print_server_url_(print_server_url), + cups_encryption_(encryption), + blocking_(blocking) { } bool PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) { @@ -275,22 +281,27 @@ scoped_refptr<PrintBackend> PrintBackend::CreateInstance( #endif std::string print_server_url_str, cups_blocking; + int encryption = HTTP_ENCRYPT_NEVER; if (print_backend_settings) { print_backend_settings->GetString(kCUPSPrintServerURL, &print_server_url_str); print_backend_settings->GetString(kCUPSBlocking, &cups_blocking); + + print_backend_settings->GetInteger(kCUPSEncryption, &encryption); } GURL print_server_url(print_server_url_str.c_str()); - return new PrintBackendCUPS(print_server_url, cups_blocking == kValueTrue); + return new PrintBackendCUPS(print_server_url, + static_cast<http_encryption_t>(encryption), + cups_blocking == kValueTrue); } int PrintBackendCUPS::GetDests(cups_dest_t** dests) { if (print_server_url_.is_empty()) { // Use default (local) print server. return cupsGetDests(dests); } else { - HttpConnectionCUPS http(print_server_url_); + HttpConnectionCUPS http(print_server_url_, cups_encryption_); http.SetBlocking(blocking_); return cupsGetDests2(http.http(), dests); } @@ -314,7 +325,7 @@ FilePath PrintBackendCUPS::GetPPD(const char* name) { // Note: After looking at CUPS sources, it looks like non-blocking // connection will timeout after 10 seconds of no data period. And it will // return the same way as if data was completely and sucessfully downloaded. - HttpConnectionCUPS http(print_server_url_); + HttpConnectionCUPS http(print_server_url_, cups_encryption_); http.SetBlocking(blocking_); ppd_file_path = cupsGetPPD2(http.http(), name); // Check if the get full PPD, since non-blocking call may simply return |