| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <set> | 9 #include <set> |
| 9 | 10 |
| 10 #include "chrome/browser/download/download_ui_controller.h" | 11 #include "chrome/browser/download/download_ui_controller.h" |
| 11 #include "chrome/browser/download/notification/download_item_notification.h" | 12 #include "chrome/browser/download/notification/download_item_notification.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/public/browser/download_item.h" | 14 #include "content/public/browser/download_item.h" |
| 14 | 15 |
| 15 class DownloadNotificationManagerForProfile; | 16 class DownloadNotificationManagerForProfile; |
| 16 | 17 |
| 17 class DownloadNotificationManager : public DownloadUIController::Delegate { | 18 class DownloadNotificationManager : public DownloadUIController::Delegate { |
| 18 public: | 19 public: |
| 19 explicit DownloadNotificationManager(Profile* profile); | 20 explicit DownloadNotificationManager(Profile* profile); |
| 20 ~DownloadNotificationManager() override; | 21 ~DownloadNotificationManager() override; |
| 21 | 22 |
| 22 void OnAllDownloadsRemoving(Profile* profile); | 23 void OnAllDownloadsRemoving(Profile* profile); |
| 23 // DownloadUIController::Delegate: | 24 // DownloadUIController::Delegate: |
| 24 void OnNewDownloadReady(content::DownloadItem* item) override; | 25 void OnNewDownloadReady(content::DownloadItem* item) override; |
| 25 | 26 |
| 26 DownloadNotificationManagerForProfile* GetForProfile(Profile* profile) const; | 27 DownloadNotificationManagerForProfile* GetForProfile(Profile* profile) const; |
| 27 | 28 |
| 28 private: | 29 private: |
| 29 friend class test::DownloadItemNotificationTest; | 30 friend class test::DownloadItemNotificationTest; |
| 30 | 31 |
| 31 Profile* main_profile_ = nullptr; | 32 Profile* main_profile_ = nullptr; |
| 32 std::map<Profile*, DownloadNotificationManagerForProfile*> | 33 std::map<Profile*, std::unique_ptr<DownloadNotificationManagerForProfile>> |
| 33 manager_for_profile_; | 34 manager_for_profile_; |
| 34 | |
| 35 base::STLValueDeleter< | |
| 36 std::map<Profile*, DownloadNotificationManagerForProfile*>> | |
| 37 items_deleter_; | |
| 38 }; | 35 }; |
| 39 | 36 |
| 40 class DownloadNotificationManagerForProfile | 37 class DownloadNotificationManagerForProfile |
| 41 : public content::DownloadItem::Observer { | 38 : public content::DownloadItem::Observer { |
| 42 public: | 39 public: |
| 43 DownloadNotificationManagerForProfile( | 40 DownloadNotificationManagerForProfile( |
| 44 Profile* profile, DownloadNotificationManager* parent_manager); | 41 Profile* profile, DownloadNotificationManager* parent_manager); |
| 45 ~DownloadNotificationManagerForProfile() override; | 42 ~DownloadNotificationManagerForProfile() override; |
| 46 | 43 |
| 47 message_center::MessageCenter* message_center() const { | 44 message_center::MessageCenter* message_center() const { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 | 55 |
| 59 private: | 56 private: |
| 60 friend class test::DownloadItemNotificationTest; | 57 friend class test::DownloadItemNotificationTest; |
| 61 | 58 |
| 62 void OverrideMessageCenterForTest( | 59 void OverrideMessageCenterForTest( |
| 63 message_center::MessageCenter* message_center); | 60 message_center::MessageCenter* message_center); |
| 64 | 61 |
| 65 Profile* profile_ = nullptr; | 62 Profile* profile_ = nullptr; |
| 66 DownloadNotificationManager* parent_manager_; // weak | 63 DownloadNotificationManager* parent_manager_; // weak |
| 67 std::set<content::DownloadItem*> downloading_items_; | 64 std::set<content::DownloadItem*> downloading_items_; |
| 68 std::map<content::DownloadItem*, DownloadItemNotification*> items_; | 65 std::map<content::DownloadItem*, std::unique_ptr<DownloadItemNotification>> |
| 66 items_; |
| 69 | 67 |
| 70 // Pointer to the message center instance. | 68 // Pointer to the message center instance. |
| 71 message_center::MessageCenter* message_center_; | 69 message_center::MessageCenter* message_center_; |
| 72 | |
| 73 base::STLValueDeleter< | |
| 74 std::map<content::DownloadItem*, DownloadItemNotification*>> | |
| 75 items_deleter_; | |
| 76 }; | 70 }; |
| 77 | 71 |
| 78 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_ | 72 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |