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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chromeos/printing/printer_configuration.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 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 "chromeos/printing/printer_configuration.h" 5 #include "chromeos/printing/printer_configuration.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/strings/string_piece.h"
10 11
11 namespace chromeos { 12 namespace chromeos {
12 13
13 Printer::Printer() : source_(SRC_USER_PREFS) { 14 Printer::Printer() : source_(SRC_USER_PREFS) {
14 id_ = base::GenerateGUID(); 15 id_ = base::GenerateGUID();
15 } 16 }
16 17
17 Printer::Printer(const std::string& id, const base::Time& last_updated) 18 Printer::Printer(const std::string& id, const base::Time& last_updated)
18 : id_(id), source_(SRC_USER_PREFS), last_updated_(last_updated) { 19 : id_(id), source_(SRC_USER_PREFS), last_updated_(last_updated) {
19 if (id_.empty()) 20 if (id_.empty())
20 id_ = base::GenerateGUID(); 21 id_ = base::GenerateGUID();
21 } 22 }
22 23
23 Printer::Printer(const Printer& other) = default; 24 Printer::Printer(const Printer& other) = default;
24 25
25 Printer& Printer::operator=(const Printer& other) = default; 26 Printer& Printer::operator=(const Printer& other) = default;
26 27
27 Printer::~Printer() {} 28 Printer::~Printer() {}
28 29
29 bool Printer::IsIppEverywhere() const { 30 bool Printer::IsIppEverywhere() const {
30 return ppd_reference_.autoconf; 31 return ppd_reference_.autoconf;
31 } 32 }
32 33
34 Printer::PrinterProtocol Printer::GetProtocol() const {
35 const base::StringPiece uri(uri_);
36
37 if (uri.starts_with("usb:"))
38 return PrinterProtocol::kUsb;
39
40 if (uri.starts_with("ipp:"))
41 return PrinterProtocol::kIpp;
42
43 if (uri.starts_with("ipps:"))
44 return PrinterProtocol::kIpps;
45
46 if (uri.starts_with("http:"))
47 return PrinterProtocol::kHttp;
48
49 if (uri.starts_with("https:"))
50 return PrinterProtocol::kHttps;
51
52 if (uri.starts_with("socket:"))
53 return PrinterProtocol::kSocket;
54
55 if (uri.starts_with("lpd:"))
56 return PrinterProtocol::kLpd;
57
58 return PrinterProtocol::kUnknown;
59 }
60
33 } // namespace chromeos 61 } // namespace chromeos
OLDNEW
« 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