Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: chrome/browser/download/notification/download_notification_item.h

Issue 852043002: Initial Implementation of Download Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build & test errors on non-ChromeOS platform. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 : public content::DownloadItem::Observer {
26 public:
27 class Delegate {
28 public:
29 virtual void OnDownloadStarted(DownloadNotificationItem* item) = 0;
30 virtual void OnDownloadStopped(DownloadNotificationItem* item) = 0;
31 virtual void OnDownloadRemoved(DownloadNotificationItem* item) = 0;
32 };
33
34 DownloadNotificationItem(content::DownloadItem* item, Delegate* delegate);
35
36 ~DownloadNotificationItem() override;
37
38 private:
39 class NotificationWatcher : public message_center::NotificationDelegate,
40 public message_center::MessageCenterObserver {
41 public:
42 explicit NotificationWatcher(DownloadNotificationItem* item);
43
44 private:
45 ~NotificationWatcher() override;
46
47 // message_center::NotificationDelegate overrides:
48 void Close(bool by_user) override;
49 void Click() override;
50 bool HasClickedListener() override;
51 void ButtonClick(int button_index) override;
52
53 // message_center::MessageCenterObserver overrides:
54 void OnNotificationRemoved(const std::string& id, bool by_user) override;
55
56 DownloadNotificationItem* item_;
57 };
58
59 void OnNotificationClick();
60 void OnNotificationButtonClick(int button_index);
61 void OnNotificationClose(bool by_user);
62 void OnNotificationRemoved(bool by_user);
63
64 // DownloadItem::Observer overrides:
65 void OnDownloadUpdated(content::DownloadItem* item) override;
66 void OnDownloadOpened(content::DownloadItem* item) override;
67 void OnDownloadRemoved(content::DownloadItem* item) override;
68 void OnDownloadDestroyed(content::DownloadItem* item) override;
69
70 void UpdateNotificationData();
71 void SetNotificationImage(int resource_id);
72
73 // Returns a short one-line status string for the download.
74 base::string16 GetTitle() const;
75
76 // Returns a short one-line status string for a download command.
77 base::string16 GetCommandLabel(DownloadCommands::Command command) const;
78
79 // Get the warning test to notify a dangerous download. Should only be called
80 // if IsDangerous() is true.
81 base::string16 GetWarningText() const;
82
83 scoped_ptr<std::vector<DownloadCommands::Command>> GetPossibleActions() const;
84
85 bool openable_;
86 bool downloading_;
87 bool reshow_after_remove_;
88 int image_resource_id_;
89 scoped_refptr<NotificationWatcher> watcher_;
90
91 message_center::MessageCenter* message_center_;
92 scoped_ptr<Notification> notification_;
93
94 content::DownloadItem* item_;
95 scoped_ptr<std::vector<DownloadCommands::Command>> button_actions_;
96
97 Delegate* const delegate_;
98
99 friend class test::DownloadNotificationItemTest;
100
101 DISALLOW_COPY_AND_ASSIGN(DownloadNotificationItem);
102 };
103
104 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_ui_controller.cc ('k') | chrome/browser/download/notification/download_notification_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698