OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ |
| 7 |
| 8 #include "chrome/browser/download/notification/download_notification_item.h" |
| 9 |
| 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "chrome/browser/download/download_command.h" |
| 12 #include "content/public/browser/download_item.h" |
| 13 #include "grit/theme_resources.h" |
| 14 #include "ui/message_center/message_center.h" |
| 15 #include "ui/message_center/notification.h" |
| 16 #include "ui/message_center/notification_delegate.h" |
| 17 |
| 18 using message_center::Notification; |
| 19 |
| 20 class DownloadNotificationItem |
| 21 : public message_center::NotificationDelegate, |
| 22 public content::DownloadItem::Observer { |
| 23 |
| 24 public: |
| 25 class Delegate { |
| 26 public: |
| 27 virtual void OnDownloadNotificationItemDestroying( |
| 28 DownloadNotificationItem* item) = 0; |
| 29 virtual void OnDownloadStarted(DownloadNotificationItem* item) = 0; |
| 30 virtual void OnDownloadStopped(DownloadNotificationItem* item) = 0; |
| 31 }; |
| 32 |
| 33 DownloadNotificationItem( |
| 34 content::DownloadItem* item, |
| 35 Delegate* delegate); |
| 36 |
| 37 protected: |
| 38 ~DownloadNotificationItem()override; |
| 39 |
| 40 private: |
| 41 // message_center::NotificationDelegate overrides: |
| 42 void Close(bool by_user) override; |
| 43 void Click() override; |
| 44 bool HasClickedListener() override; |
| 45 void ButtonClick(int button_index) override; |
| 46 |
| 47 // DownloadItem::Observer methods |
| 48 void OnDownloadUpdated(content::DownloadItem* item) override; |
| 49 void OnDownloadOpened(content::DownloadItem* item) override; |
| 50 void OnDownloadDestroyed(content::DownloadItem* item) override; |
| 51 |
| 52 void ShowNotificationAgainSoon(); |
| 53 void ShowNotificationAgain(); |
| 54 |
| 55 void SetNotificationData(); |
| 56 void SetImageToNotification(int resource_id); |
| 57 |
| 58 // Returns a short one-line status string for the download. |
| 59 base::string16 GetTitle() const; |
| 60 |
| 61 // Get the warning test to notify a dangerous download. Should only be called |
| 62 // if IsDangerous() is true. |
| 63 base::string16 GetWarningTextLong() const; |
| 64 |
| 65 scoped_ptr<std::vector<DownloadCommand::Commands> > |
| 66 GetPossibleActions() const; |
| 67 |
| 68 scoped_ptr<Notification> notification_; |
| 69 scoped_ptr<std::vector<DownloadCommand::Commands> > button_actions_; |
| 70 |
| 71 bool has_timeout_; |
| 72 bool openable_; |
| 73 bool downloading_; |
| 74 int image_resource_id_; |
| 75 message_center::MessageCenter* message_center_; |
| 76 content::DownloadItem* item_; |
| 77 |
| 78 Delegate* const delegate_; |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(DownloadNotificationItem); |
| 81 }; |
| 82 |
| 83 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ |
OLD | NEW |