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 | |
| 5 | #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_NOTIFICATION_H_ |
| 6 | #define CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_NOTIFICATION_H_ |
| 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" |
| 14 | #include "ui/message_center/public/cpp/notification_delegate.h" |
| 15 | |
| 16 | class Profile; |
| 17 | |
| 18 | namespace message_center { |
| 19 | class Notification; |
| 20 | } |
| 21 | |
| 22 | namespace chromeos { |
| 23 | |
| 24 | // UsbPrinterNotification is used to update the notification of a print job |
| 25 | // according to its state and respond to the user's action. |
| 26 | class UsbPrinterNotification : public message_center::NotificationObserver { |
| 27 | public: |
| 28 | enum class Type { kEphemeral }; |
| 29 | |
| 30 | UsbPrinterNotification(const Printer& printer, |
| 31 | const std::string& notification_id, |
| 32 | Type type, |
| 33 | Profile* profile); |
| 34 | |
| 35 | virtual ~UsbPrinterNotification(); |
| 36 | |
| 37 | // Closes the notification, removing it from the notification tray. |
| 38 | void CloseNotification(); |
| 39 | |
| 40 | // message_center::NotificationObserver |
| 41 | void Close(bool by_user) override; |
| 42 | void Click(const base::Optional<int>& button_index, |
| 43 | const base::Optional<base::string16>& reply) override; |
| 44 | |
| 45 | private: |
| 46 | void UpdateContents(); |
| 47 | |
| 48 | void ShowNotification(); |
| 49 | |
| 50 | const Printer printer_; |
| 51 | std::string notification_id_; |
| 52 | Type type_; |
| 53 | Profile* profile_; // Not owned. |
| 54 | std::unique_ptr<message_center::Notification> notification_; |
| 55 | bool visible_; |
| 56 | |
| 57 | base::WeakPtrFactory<UsbPrinterNotification> weak_factory_; |
| 58 | |
| 59 | DISALLOW_COPY_AND_ASSIGN(UsbPrinterNotification); |
| 60 | }; |
| 61 | |
| 62 | } // namespace chromeos |
| 63 | |
| 64 | #endif // CHROME_BROWSER_CHROMEOS_PRINTING_USB_PRINTER_NOTIFICATION_H_ |