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_item_notification.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/download_item.h"
15 class DownloadNotificationManagerForProfile
;
17 class DownloadNotificationManager
: public DownloadUIController::Delegate
{
19 static bool IsEnabled();
21 explicit DownloadNotificationManager(Profile
* profile
);
22 ~DownloadNotificationManager() override
;
24 void OnAllDownloadsRemoving(Profile
* profile
);
25 // DownloadUIController::Delegate:
26 void OnNewDownloadReady(content::DownloadItem
* item
) override
;
28 DownloadNotificationManagerForProfile
* GetForProfile(Profile
* profile
) const;
31 friend class test::DownloadItemNotificationTest
;
33 Profile
* main_profile_
= nullptr;
34 std::map
<Profile
*, DownloadNotificationManagerForProfile
*>
37 STLValueDeleter
<std::map
<Profile
*, DownloadNotificationManagerForProfile
*>>
41 class DownloadNotificationManagerForProfile
42 : public content::DownloadItem::Observer
{
44 DownloadNotificationManagerForProfile(
45 Profile
* profile
, DownloadNotificationManager
* parent_manager
);
46 ~DownloadNotificationManagerForProfile() override
;
48 // DownloadItem::Observer overrides:
49 void OnDownloadUpdated(content::DownloadItem
* download
) override
;
50 void OnDownloadOpened(content::DownloadItem
* download
) override
;
51 void OnDownloadRemoved(content::DownloadItem
* download
) override
;
52 void OnDownloadDestroyed(content::DownloadItem
* download
) override
;
54 void OnNewDownloadReady(content::DownloadItem
* item
);
57 friend class test::DownloadItemNotificationTest
;
59 Profile
* profile_
= nullptr;
60 DownloadNotificationManager
* parent_manager_
; // weak
61 std::set
<content::DownloadItem
*> downloading_items_
;
62 std::map
<content::DownloadItem
*, DownloadItemNotification
*> items_
;
64 STLValueDeleter
<std::map
<content::DownloadItem
*, DownloadItemNotification
*>>
68 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_