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

Unified Diff: chromeos/printing/printer_configuration.cc

Issue 2903113002: Track printer protocol usage for CUPS printers. (Closed)
Patch Set: rebase Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/printing/printer_configuration.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/printing/printer_configuration.cc
diff --git a/chromeos/printing/printer_configuration.cc b/chromeos/printing/printer_configuration.cc
index aac6a9633f66eba488c7bf9f306eca05a562e3c6..b857bf9af5f757906f9aeeefd882553ab2907e6d 100644
--- a/chromeos/printing/printer_configuration.cc
+++ b/chromeos/printing/printer_configuration.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/guid.h"
+#include "base/strings/string_piece.h"
namespace chromeos {
@@ -30,4 +31,31 @@ bool Printer::IsIppEverywhere() const {
return ppd_reference_.autoconf;
}
+Printer::PrinterProtocol Printer::GetProtocol() const {
+ const base::StringPiece uri(uri_);
+
+ if (uri.starts_with("usb:"))
+ return PrinterProtocol::kUsb;
+
+ if (uri.starts_with("ipp:"))
+ return PrinterProtocol::kIpp;
+
+ if (uri.starts_with("ipps:"))
+ return PrinterProtocol::kIpps;
+
+ if (uri.starts_with("http:"))
+ return PrinterProtocol::kHttp;
+
+ if (uri.starts_with("https:"))
+ return PrinterProtocol::kHttps;
+
+ if (uri.starts_with("socket:"))
+ return PrinterProtocol::kSocket;
+
+ if (uri.starts_with("lpd:"))
+ return PrinterProtocol::kLpd;
+
+ return PrinterProtocol::kUnknown;
+}
+
} // namespace chromeos
« no previous file with comments | « chromeos/printing/printer_configuration.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698