Chromium Code Reviews| Index: chrome/browser/download/download_ui_controller.cc |
| diff --git a/chrome/browser/download/download_ui_controller.cc b/chrome/browser/download/download_ui_controller.cc |
| index ae197a84cb20182f7f4803728ad6b461202d9264..c21aa817a64c5502d61716bf12e60a4cb6efa54f 100644 |
| --- a/chrome/browser/download/download_ui_controller.cc |
| +++ b/chrome/browser/download/download_ui_controller.cc |
| @@ -19,12 +19,15 @@ |
| #if defined(OS_ANDROID) |
| #include "content/public/browser/android/download_controller_android.h" |
| #else |
| -#include "chrome/browser/download/notification/download_notification_manager.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| #include "chrome/browser/ui/host_desktop.h" |
| #endif |
| +#if defined(OS_CHROMEOS) |
| +#include "chrome/browser/download/notification/download_notification_manager.h" |
| +#endif |
| + |
| namespace { |
| // DownloadShelfUIControllerDelegate{Android,} is used when a |
| @@ -104,22 +107,23 @@ DownloadUIController::DownloadUIController(content::DownloadManager* manager, |
| scoped_ptr<Delegate> delegate) |
| : download_notifier_(manager, this), |
| delegate_(delegate.Pass()) { |
| - if (!delegate_) { |
| #if defined(OS_ANDROID) |
| + if (!delegate_) |
| delegate_.reset(new AndroidUIControllerDelegate()); |
| #else |
| - // The delegate should not be invoked after the profile has gone away. This |
| - // should be the case since DownloadUIController is owned by |
| - // DownloadService, which in turn is a profile keyed service. |
| - if (DownloadNotificationManager::IsEnabled()) { |
| - delegate_.reset(new DownloadNotificationManager( |
| - Profile::FromBrowserContext(manager->GetBrowserContext()))); |
| - } else { |
| - delegate_.reset(new DownloadShelfUIControllerDelegate( |
| - Profile::FromBrowserContext(manager->GetBrowserContext()))); |
| - } |
| -#endif |
| +#if defined(OS_CHROMEOS) |
| + if (!delegate_ && DownloadNotificationManager::IsEnabled()) { |
| + // The Profile is guaranteed to be valid since DownloadUIController is owned |
| + // by DownloadService, which in turn is a profile keyed service. |
| + delegate_.reset(new DownloadNotificationManager( |
| + Profile::FromBrowserContext(manager->GetBrowserContext()))); |
|
yoshiki
2015/09/25 18:14:35
Please set |DownloadShelfUIControllerDelegate| to
Evan Stade
2015/09/25 19:06:53
not 100% sure I follow your meaning, but I think t
yoshiki
2015/09/25 23:35:31
Sorry, you're correct. Please ignore my comment.
|
| + } |
| +#endif // defined(OS_CHROMEOS) |
| + if (!delegate_) { |
| + delegate_.reset(new DownloadShelfUIControllerDelegate( |
| + Profile::FromBrowserContext(manager->GetBrowserContext()))); |
| } |
| +#endif // defined(OS_ANDROID) |
| } |
| DownloadUIController::~DownloadUIController() { |