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_NOTIFICATION_MANAGER_H_
6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_
10 #include "chrome/browser/download/download_ui_controller.h"
11 #include "chrome/browser/download/notification/download_group_notification.h"
12 #include "chrome/browser/download/notification/download_item_notification.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/download_item.h"
16 class DownloadNotificationManagerForProfile
;
18 class DownloadNotificationManager
: public DownloadUIController::Delegate
{
20 static bool IsEnabled();
22 explicit DownloadNotificationManager(Profile
* profile
);
23 ~DownloadNotificationManager() override
;
25 void OnAllDownloadsRemoving(Profile
* profile
);
26 // DownloadUIController::Delegate:
27 void OnNewDownloadReady(content::DownloadItem
* item
) override
;
29 DownloadNotificationManagerForProfile
* GetForProfile(Profile
* profile
) const;
32 friend class test::DownloadItemNotificationTest
;
34 Profile
* main_profile_
= nullptr;
35 std::map
<Profile
*, DownloadNotificationManagerForProfile
*>
38 STLValueDeleter
<std::map
<Profile
*, DownloadNotificationManagerForProfile
*>>
42 class DownloadNotificationManagerForProfile
43 : public content::DownloadItem::Observer
{
45 DownloadNotificationManagerForProfile(
46 Profile
* profile
, DownloadNotificationManager
* parent_manager
);
47 ~DownloadNotificationManagerForProfile() override
;
49 // DownloadItem::Observer overrides:
50 void OnDownloadUpdated(content::DownloadItem
* download
) override
;
51 void OnDownloadOpened(content::DownloadItem
* download
) override
;
52 void OnDownloadRemoved(content::DownloadItem
* download
) override
;
53 void OnDownloadDestroyed(content::DownloadItem
* download
) override
;
55 void OnNewDownloadReady(content::DownloadItem
* item
);
57 DownloadGroupNotification
* GetGroupNotification() const;
60 friend class test::DownloadItemNotificationTest
;
62 Profile
* profile_
= nullptr;
63 DownloadNotificationManager
* parent_manager_
; // weak
64 std::set
<content::DownloadItem
*> downloading_items_
;
65 std::map
<content::DownloadItem
*, DownloadItemNotification
*> items_
;
66 scoped_ptr
<DownloadGroupNotification
> group_notification_
;
68 STLValueDeleter
<std::map
<content::DownloadItem
*, DownloadItemNotification
*>>
72 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_