blob: 2a5e6d5f172bf4a76ddac926197ea63715b7a5d8 [file] [log] [blame]
// Copyright 2019 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.
#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/printing/printer_configuration.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "base/task/post_task.h"
namespace cups_proxy {
using SetupPrinterCallback = base::OnceCallback<void(bool)>;
// This delegate grants the CupsProxyService access to the Chrome printing
// stack. This class can be created anywhere but must be accessed from a
// sequenced context.
class CupsProxyServiceDelegate {
virtual ~CupsProxyServiceDelegate();
// Exposing |weak_factory_|.GetWeakPtr method. Needed to share delegate with
// CupsProxyService internal managers.
base::WeakPtr<CupsProxyServiceDelegate> GetWeakPtr();
// Printer access can be disabled by either policy or settings.
virtual bool IsPrinterAccessAllowed() const = 0;
virtual std::vector<chromeos::Printer> GetPrinters(
chromeos::PrinterClass printer_class) = 0;
virtual absl::optional<chromeos::Printer> GetPrinter(
const std::string& id) = 0;
virtual std::vector<std::string> GetRecentlyUsedPrinters() = 0;
virtual bool IsPrinterInstalled(const chromeos::Printer& printer) = 0;
virtual void PrinterInstalled(const chromeos::Printer& printer) = 0;
virtual scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() = 0;
// |cb| will be run on this delegate's sequenced context.
virtual void SetupPrinter(const chromeos::Printer& printer,
SetupPrinterCallback cb) = 0;
base::WeakPtrFactory<CupsProxyServiceDelegate> weak_factory_{this};
} // namespace cups_proxy