blob: 1a9f6c8d87b1fcc167c6db37f4f1daccc50aac6c [file] [log] [blame]
Bailey Berroe91e9d682019-05-10 21:35:461// Copyright 2019 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
Yeunjoo Choia52715a2021-09-09 02:45:175#ifndef CHROME_BROWSER_ASH_PRINTING_USB_PRINTER_NOTIFICATION_H_
6#define CHROME_BROWSER_ASH_PRINTING_USB_PRINTER_NOTIFICATION_H_
Bailey Berroe91e9d682019-05-10 21:35:467
8#include <memory>
9#include <string>
10#include <vector>
11
12#include "base/memory/weak_ptr.h"
13#include "chrome/browser/chromeos/printing/printer_configurer.h"
Zentaro Kavanaghc8ba61a2019-05-13 17:24:4614#include "chromeos/printing/printer_configuration.h"
Bailey Berroe91e9d682019-05-10 21:35:4615#include "ui/message_center/public/cpp/notification_delegate.h"
16
17class Profile;
18
19namespace message_center {
20class Notification;
Yeunjoo Choida53f442021-09-17 01:07:3621} // namespace message_center
Bailey Berroe91e9d682019-05-10 21:35:4622
Yeunjoo Choida53f442021-09-17 01:07:3623namespace ash {
Bailey Berroe91e9d682019-05-10 21:35:4624
25// UsbPrinterNotification is used to update the notification of a print job
26// according to its state and respond to the user's action.
27class UsbPrinterNotification : public message_center::NotificationObserver {
28 public:
Bailey Berroac4eb302019-05-17 21:34:5629 enum class Type { kEphemeral, kSaved, kConfigurationRequired };
Bailey Berroe91e9d682019-05-10 21:35:4630
Yeunjoo Choida53f442021-09-17 01:07:3631 UsbPrinterNotification(const chromeos::Printer& printer,
Bailey Berroe91e9d682019-05-10 21:35:4632 const std::string& notification_id,
33 Type type,
34 Profile* profile);
35
36 virtual ~UsbPrinterNotification();
37
38 // Closes the notification, removing it from the notification tray.
39 void CloseNotification();
40
41 // message_center::NotificationObserver
42 void Close(bool by_user) override;
Anton Bikineev46bbb972021-05-15 17:53:5343 void Click(const absl::optional<int>& button_index,
44 const absl::optional<std::u16string>& reply) override;
Bailey Berroe91e9d682019-05-10 21:35:4645
46 private:
47 void UpdateContents();
48
49 void ShowNotification();
50
Yeunjoo Choida53f442021-09-17 01:07:3651 const chromeos::Printer printer_;
Bailey Berroe91e9d682019-05-10 21:35:4652 std::string notification_id_;
53 Type type_;
54 Profile* profile_; // Not owned.
55 std::unique_ptr<message_center::Notification> notification_;
56 bool visible_;
57
Jeremy Roman47d432e2019-08-20 14:24:0058 base::WeakPtrFactory<UsbPrinterNotification> weak_factory_{this};
Bailey Berroe91e9d682019-05-10 21:35:4659
60 DISALLOW_COPY_AND_ASSIGN(UsbPrinterNotification);
61};
62
Yeunjoo Choida53f442021-09-17 01:07:3663} // namespace ash
Bailey Berroe91e9d682019-05-10 21:35:4664
Yeunjoo Choia52715a2021-09-09 02:45:1765#endif // CHROME_BROWSER_ASH_PRINTING_USB_PRINTER_NOTIFICATION_H_