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_commands.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/message_center_observer.h" | |
16 #include "ui/message_center/notification.h" | |
17 #include "ui/message_center/notification_delegate.h" | |
18 | |
19 using message_center::Notification; | |
20 | |
21 namespace test { | |
22 class DownloadNotificationItemTest; | |
23 } | |
24 | |
25 class DownloadNotificationItem | |
26 : public message_center::NotificationDelegate, | |
27 public message_center::MessageCenterObserver, | |
28 public content::DownloadItem::Observer { | |
29 | |
30 public: | |
31 class Delegate { | |
32 public: | |
33 virtual void OnDownloadStarted(DownloadNotificationItem* item) = 0; | |
34 virtual void OnDownloadStopped(DownloadNotificationItem* item) = 0; | |
35 virtual void OnDownloadRemoved(DownloadNotificationItem* item) = 0; | |
36 }; | |
37 | |
38 DownloadNotificationItem( | |
39 content::DownloadItem* item, | |
40 Delegate* delegate); | |
41 | |
42 protected: | |
43 ~DownloadNotificationItem() override; | |
44 | |
45 private: | |
46 // message_center::NotificationDelegate overrides: | |
47 void Close(bool by_user) override; | |
48 void Click() override; | |
49 bool HasClickedListener() override; | |
50 void ButtonClick(int button_index) override; | |
51 | |
52 // message_center::MessageCenterObserver overrides: | |
53 void OnNotificationRemoved(const std::string& id, bool by_user) override; | |
54 | |
55 // DownloadItem::Observer overrides: | |
56 void OnDownloadUpdated(content::DownloadItem* item) override; | |
57 void OnDownloadOpened(content::DownloadItem* item) override; | |
58 void OnDownloadRemoved(content::DownloadItem* item) override; | |
asanka
2015/02/20 23:34:40
You also need to listen for OnDownloadDestroyed().
yoshiki
2015/02/24 21:30:57
Done.
| |
59 | |
60 void SetNotificationData(); | |
asanka
2015/02/20 23:34:40
Reword? It's updating the notification based on th
yoshiki
2015/02/24 21:30:57
Done. Does the new name look good for you?
| |
61 void SetImageToNotification(int resource_id); | |
asanka
2015/02/20 23:34:40
Reword?
yoshiki
2015/02/24 21:30:57
Done. Does the new name look good for you?
| |
62 | |
63 // Returns a short one-line status string for the download. | |
64 base::string16 GetTitle() const; | |
65 | |
66 // Returns a short one-line status string for a download command. | |
67 base::string16 GetCommandLabel(DownloadCommands::Command command) const; | |
68 | |
69 // Get the warning test to notify a dangerous download. Should only be called | |
70 // if IsDangerous() is true. | |
71 base::string16 GetWarningText() const; | |
72 | |
73 scoped_ptr<std::vector<DownloadCommands::Command> > | |
74 GetPossibleActions() const; | |
75 | |
76 scoped_ptr<Notification> notification_; | |
77 scoped_ptr<std::vector<DownloadCommands::Command> > button_actions_; | |
78 | |
79 bool openable_; | |
80 bool downloading_; | |
81 bool popup_closing_; | |
82 int image_resource_id_; | |
83 message_center::MessageCenter* message_center_; | |
84 content::DownloadItem* item_; | |
85 | |
86 Delegate* const delegate_; | |
87 | |
88 friend class test::DownloadNotificationItemTest; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(DownloadNotificationItem); | |
91 }; | |
92 | |
93 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ | |
OLD | NEW |