Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 1 | // 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 Choi | a52715a | 2021-09-09 02:45:17 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_ASH_PRINTING_USB_PRINTER_NOTIFICATION_H_ |
| 6 | #define CHROME_BROWSER_ASH_PRINTING_USB_PRINTER_NOTIFICATION_H_ |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 7 | |
| 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 Kavanagh | c8ba61a | 2019-05-13 17:24:46 | [diff] [blame] | 14 | #include "chromeos/printing/printer_configuration.h" |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 15 | #include "ui/message_center/public/cpp/notification_delegate.h" |
| 16 | |
| 17 | class Profile; |
| 18 | |
| 19 | namespace message_center { |
| 20 | class Notification; |
Yeunjoo Choi | da53f44 | 2021-09-17 01:07:36 | [diff] [blame] | 21 | } // namespace message_center |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 22 | |
Yeunjoo Choi | da53f44 | 2021-09-17 01:07:36 | [diff] [blame] | 23 | namespace ash { |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 24 | |
| 25 | // UsbPrinterNotification is used to update the notification of a print job |
| 26 | // according to its state and respond to the user's action. |
| 27 | class UsbPrinterNotification : public message_center::NotificationObserver { |
| 28 | public: |
Bailey Berro | ac4eb30 | 2019-05-17 21:34:56 | [diff] [blame] | 29 | enum class Type { kEphemeral, kSaved, kConfigurationRequired }; |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 30 | |
Yeunjoo Choi | da53f44 | 2021-09-17 01:07:36 | [diff] [blame] | 31 | UsbPrinterNotification(const chromeos::Printer& printer, |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 32 | 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 Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 43 | void Click(const absl::optional<int>& button_index, |
| 44 | const absl::optional<std::u16string>& reply) override; |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 45 | |
| 46 | private: |
| 47 | void UpdateContents(); |
| 48 | |
| 49 | void ShowNotification(); |
| 50 | |
Yeunjoo Choi | da53f44 | 2021-09-17 01:07:36 | [diff] [blame] | 51 | const chromeos::Printer printer_; |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 52 | 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 Roman | 47d432e | 2019-08-20 14:24:00 | [diff] [blame] | 58 | base::WeakPtrFactory<UsbPrinterNotification> weak_factory_{this}; |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 59 | |
| 60 | DISALLOW_COPY_AND_ASSIGN(UsbPrinterNotification); |
| 61 | }; |
| 62 | |
Yeunjoo Choi | da53f44 | 2021-09-17 01:07:36 | [diff] [blame] | 63 | } // namespace ash |
Bailey Berro | e91e9d68 | 2019-05-10 21:35:46 | [diff] [blame] | 64 | |
Yeunjoo Choi | a52715a | 2021-09-09 02:45:17 | [diff] [blame] | 65 | #endif // CHROME_BROWSER_ASH_PRINTING_USB_PRINTER_NOTIFICATION_H_ |