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

Side by Side Diff: chromeos/printing/ppd_provider.h

Issue 2343983004: Add PPDProvider barebones implementation and associated cache skeleton. (Closed)
Patch Set: Remove extra includes Created 4 years, 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_PRINTING_PPD_PROVIDER_H_
6 #define CHROMEOS_PRINTING_PPD_PROVIDER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "chromeos/printing/printer_configuration.h"
13
14 namespace net {
15 class URLRequestContextGetter;
16 }
17
18 namespace chromeos {
19 namespace printing {
20
21 class PPDCache;
22
23 // PPDProvider is responsible for mapping printer descriptions
24 // to CUPS-PostScript Printer Description (PPD) files. The
25 // provider is a caching client to
26 class CHROMEOS_EXPORT PPDProvider {
27 public:
28 // Possible results of a Lookup call.
29 enum LookupResult {
30 // Found a PPD
31 SUCCESS,
32
33 // TODO(justincarlson) - Should we have a "FALLBACK" result here indicating
34 // we found a ppd that we think will work, but wasn't an exact match?
skau 2016/09/17 00:59:59 What would provide the "FALLBACK" signal? I think
Carlson 2016/10/06 15:56:05 I'm just speculating here that there may be some u
35
36 // Looked for a ppd for this configuration, but couldn't find a match.
37 NOT_FOUND,
38
39 // Failed to contact the Quirks server to look for a PPD.
40 SERVER_ERROR,
41 };
42
43 typedef ::base::Callback<void(LookupResult, Printer::PPDFile)> LookupCallback;
skau 2016/09/17 00:59:59 Chromium is moving away from typedef in favor of u
Carlson 2016/10/06 15:56:05 I keep forgetting you can do that, done.
44
45 // Construction-time options. Everything in this structure should have
46 // a sane default.
47 struct Options {
48 // hostname of quirks server to query. Default is
49 // "chromeosquirksserver-pa.googleapis.com".
50 ::std::string quirks_server;
51
52 // API key for accessing quirks server.
53 ::std::string api_key;
54
55 // TODO(justincarlson) - Add a limit to the size of data we'll download for
56 // a single printer. There doesn't seem to actually be a simple way to
57 // enforce this, though? See
58 // https://groups.google.com/a/chromium.org/d/topic/chromium-dev/niK2rVMoMuo /discussion
59 };
60
61 // Return a sane set of default options.
62 static Options Defaults();
63
64 // Create and return a new PPDProvider with the given cache and options.
65 static std::unique_ptr<PPDProvider> Create(
66 scoped_refptr<net::URLRequestContextGetter> url_context_getter,
67 std::unique_ptr<PPDCache> cache,
68 const Options& options);
69
70 // Convenience overload to create a provider with default options.
71 static std::unique_ptr<PPDProvider> Create(
72 scoped_refptr<net::URLRequestContextGetter> url_context_getter,
73 std::unique_ptr<PPDCache> cache);
74
75 virtual ~PPDProvider() {}
76
77 // Given a manufacturer name and model name, attempt to get a PPD file for
78 // that printer. Will invoke cb with the result of the lookup. If the
79 // function returns SUCCESS, the second argument to the callback gives the
80 // found file, otherwise the PPDFile argument is invalid and should not be
81 // used.
82 virtual void Lookup(const std::string& manufacturer,
83 const std::string& model,
84 LookupCallback cb) = 0;
85 };
86
87 } // namespace printing
88 } // namespace chromeos
89
90 #endif // CHROMEOS_PRINTING_PPD_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698