Chromium Code Reviews| Index: chromeos/printing/ppd_provider.h |
| diff --git a/chromeos/printing/ppd_provider.h b/chromeos/printing/ppd_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..076bb6167b61e2db02e009cca8cf940a20e2fa09 |
| --- /dev/null |
| +++ b/chromeos/printing/ppd_provider.h |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2016 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. |
| + |
| +#ifndef CHROMEOS_PRINTING_PPD_PROVIDER_H_ |
| +#define CHROMEOS_PRINTING_PPD_PROVIDER_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "chromeos/printing/printer_configuration.h" |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +namespace chromeos { |
| +namespace printing { |
| + |
| +class PPDCache; |
| + |
| +// PPDProvider is responsible for mapping printer descriptions |
| +// to CUPS-PostScript Printer Description (PPD) files. The |
| +// provider is a caching client to |
| +class CHROMEOS_EXPORT PPDProvider { |
| + public: |
| + // Possible results of a Lookup call. |
| + enum LookupResult { |
| + // Found a PPD |
| + SUCCESS, |
| + |
| + // TODO(justincarlson) - Should we have a "FALLBACK" result here indicating |
| + // 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
|
| + |
| + // Looked for a ppd for this configuration, but couldn't find a match. |
| + NOT_FOUND, |
| + |
| + // Failed to contact the Quirks server to look for a PPD. |
| + SERVER_ERROR, |
| + }; |
| + |
| + 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.
|
| + |
| + // Construction-time options. Everything in this structure should have |
| + // a sane default. |
| + struct Options { |
| + // hostname of quirks server to query. Default is |
| + // "chromeosquirksserver-pa.googleapis.com". |
| + ::std::string quirks_server; |
| + |
| + // API key for accessing quirks server. |
| + ::std::string api_key; |
| + |
| + // TODO(justincarlson) - Add a limit to the size of data we'll download for |
| + // a single printer. There doesn't seem to actually be a simple way to |
| + // enforce this, though? See |
| + // https://groups.google.com/a/chromium.org/d/topic/chromium-dev/niK2rVMoMuo/discussion |
| + }; |
| + |
| + // Return a sane set of default options. |
| + static Options Defaults(); |
| + |
| + // Create and return a new PPDProvider with the given cache and options. |
| + static std::unique_ptr<PPDProvider> Create( |
| + scoped_refptr<net::URLRequestContextGetter> url_context_getter, |
| + std::unique_ptr<PPDCache> cache, |
| + const Options& options); |
| + |
| + // Convenience overload to create a provider with default options. |
| + static std::unique_ptr<PPDProvider> Create( |
| + scoped_refptr<net::URLRequestContextGetter> url_context_getter, |
| + std::unique_ptr<PPDCache> cache); |
| + |
| + virtual ~PPDProvider() {} |
| + |
| + // Given a manufacturer name and model name, attempt to get a PPD file for |
| + // that printer. Will invoke cb with the result of the lookup. If the |
| + // function returns SUCCESS, the second argument to the callback gives the |
| + // found file, otherwise the PPDFile argument is invalid and should not be |
| + // used. |
| + virtual void Lookup(const std::string& manufacturer, |
| + const std::string& model, |
| + LookupCallback cb) = 0; |
| +}; |
| + |
| +} // namespace printing |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_PRINTING_PPD_PROVIDER_H_ |