Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / download / notification / download_group_notification.h
bloba676e3d531f6225ec928c511bbfbe2e41e105bcd
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.
5 #ifndef CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_GROUP_NOTIFICATION_H_
6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_GROUP_NOTIFICATION_H_
8 #include <set>
10 #include "chrome/browser/download/notification/download_notification.h"
11 #include "chrome/browser/notifications/notification.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/download_item.h"
15 class DownloadNotificationManagerForProfile;
17 class DownloadGroupNotification : public DownloadNotification {
18 public:
19 static base::string16 TruncateFileName(const content::DownloadItem* download);
21 DownloadGroupNotification(
22 Profile* profile, DownloadNotificationManagerForProfile* manager);
23 ~DownloadGroupNotification() override;
25 bool IsPopup() const;
26 void OnDownloadAdded(content::DownloadItem* download);
28 // Methods called from NotificationWatcher.
29 void OnDownloadUpdated(content::DownloadItem* download) override;
30 void OnDownloadRemoved(content::DownloadItem* download) override;
31 void OnNotificationClose() override;
32 void OnNotificationClick() override;
33 void OnNotificationButtonClick(int button_index) override;
34 std::string GetNotificationId() const override;
36 bool visible() const { return visible_; }
38 private:
39 struct DownloadItemIdCompare {
40 bool operator()(const content::DownloadItem* a,
41 const content::DownloadItem* b) const {
42 return b->GetId() < a->GetId(); // descending order
46 struct FilenameCache {
47 base::FilePath original_filename;
48 base::string16 truncated_filename;
51 void Update();
52 void UpdateNotificationData();
54 void Hide();
55 void Show();
57 void OpenDownloads();
59 Profile* profile_ = nullptr;
60 // Flag to show the notification on the next update.
61 bool show_next_ = false;
62 // Hides the notification on the next udpate.
63 bool hide_next_ = false;
64 // Current vilibility status of the notification.
65 bool visible_ = false;
67 scoped_ptr<Notification> notification_;
68 std::set<content::DownloadItem*,
69 DownloadGroupNotification::DownloadItemIdCompare> items_;
70 std::map<content::DownloadItem*, FilenameCache> truncated_filename_cache_;
72 DISALLOW_COPY_AND_ASSIGN(DownloadGroupNotification);
75 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_GROUP_NOTIFICATION_H_