OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_CUPS_PRINT_JOB_NOTIFICATION_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_NOTIFICATION_H_ |
| 7 |
| 8 #include "chrome/browser/notifications/notification.h" |
| 9 #include "chrome/browser/notifications/notification_delegate.h" |
| 10 |
| 11 class Profile; |
| 12 |
| 13 namespace chromeos { |
| 14 |
| 15 class CUPSPrintJob; |
| 16 |
| 17 // CUPSPrintJobNotification is used to update the notification of a print job |
| 18 // according to its state and respond to the user's action. |
| 19 class CUPSPrintJobNotification { |
| 20 public: |
| 21 enum ButtonCommand { |
| 22 CANCEL_PRINTING, |
| 23 PAUSE_PRINTING, |
| 24 RESUME_PRINTING, |
| 25 GET_HELP, |
| 26 }; |
| 27 |
| 28 CUPSPrintJobNotification(CUPSPrintJob* print_job, Profile* profile); |
| 29 ~CUPSPrintJobNotification(); |
| 30 |
| 31 void OnPrintJobStatusUpdated(); |
| 32 |
| 33 void CloseNotificationByUser(); |
| 34 void ClickOnNotificationButton(int button_index); |
| 35 const std::string& GetNotificationId(); |
| 36 |
| 37 private: |
| 38 // Update the notification based on the print job's status. |
| 39 void UpdateNotification(); |
| 40 void UpdateNotificationTitle(); |
| 41 void UpdateNotificationIcon(); |
| 42 void UpdateNotificationBodyMessage(); |
| 43 void UpdateNotificationType(); |
| 44 void UpdateNotificationButtons(); |
| 45 |
| 46 // Returns the buttons according to the print job's current status. |
| 47 std::unique_ptr<std::vector<ButtonCommand>> GetButtonCommands() const; |
| 48 base::string16 GetButtonLabel(ButtonCommand button) const; |
| 49 gfx::Image GetButtonIcon(ButtonCommand button) const; |
| 50 |
| 51 std::unique_ptr<Notification> notification_; |
| 52 std::string notification_id_; |
| 53 CUPSPrintJob* print_job_; |
| 54 scoped_refptr<NotificationDelegate> delegate_; |
| 55 Profile* profile_; |
| 56 |
| 57 // If the notification has been closed in the middle of printing or not. If it |
| 58 // is true, then prevent the following print job progress update after close, |
| 59 // and only show the print job done or failed notification. |
| 60 bool closed_in_middle_ = false; |
| 61 |
| 62 // Maintains a list of button actions according to the print job's current |
| 63 // status. |
| 64 std::unique_ptr<std::vector<ButtonCommand>> button_commands_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(CUPSPrintJobNotification); |
| 67 }; |
| 68 |
| 69 } // namespace chromeos |
| 70 |
| 71 #endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_PRINT_JOB_NOTIFICATION_H_ |
OLD | NEW |