OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/download/download_ui_controller.h" | 5 #include "chrome/browser/download/download_ui_controller.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/callback.h" | 9 #include "base/callback.h" |
8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
9 #include "build/build_config.h" | 11 #include "build/build_config.h" |
10 #include "chrome/browser/download/download_item_model.h" | 12 #include "chrome/browser/download/download_item_model.h" |
11 #include "chrome/browser/download/download_shelf.h" | 13 #include "chrome/browser/download/download_shelf.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
13 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "content/public/browser/download_item.h" | 18 #include "content/public/browser/download_item.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 101 |
100 #endif // !OS_ANDROID | 102 #endif // !OS_ANDROID |
101 | 103 |
102 } // namespace | 104 } // namespace |
103 | 105 |
104 DownloadUIController::Delegate::~Delegate() { | 106 DownloadUIController::Delegate::~Delegate() { |
105 } | 107 } |
106 | 108 |
107 DownloadUIController::DownloadUIController(content::DownloadManager* manager, | 109 DownloadUIController::DownloadUIController(content::DownloadManager* manager, |
108 scoped_ptr<Delegate> delegate) | 110 scoped_ptr<Delegate> delegate) |
109 : download_notifier_(manager, this), | 111 : download_notifier_(manager, this), delegate_(std::move(delegate)) { |
110 delegate_(delegate.Pass()) { | |
111 #if defined(OS_ANDROID) | 112 #if defined(OS_ANDROID) |
112 if (!delegate_) | 113 if (!delegate_) |
113 delegate_.reset(new AndroidUIControllerDelegate()); | 114 delegate_.reset(new AndroidUIControllerDelegate()); |
114 #else | 115 #else |
115 #if defined(OS_CHROMEOS) | 116 #if defined(OS_CHROMEOS) |
116 if (!delegate_ && DownloadNotificationManager::IsEnabled()) { | 117 if (!delegate_ && DownloadNotificationManager::IsEnabled()) { |
117 // The Profile is guaranteed to be valid since DownloadUIController is owned | 118 // The Profile is guaranteed to be valid since DownloadUIController is owned |
118 // by DownloadService, which in turn is a profile keyed service. | 119 // by DownloadService, which in turn is a profile keyed service. |
119 delegate_.reset(new DownloadNotificationManager( | 120 delegate_.reset(new DownloadNotificationManager( |
120 Profile::FromBrowserContext(manager->GetBrowserContext()))); | 121 Profile::FromBrowserContext(manager->GetBrowserContext()))); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 170 } |
170 } | 171 } |
171 #endif | 172 #endif |
172 | 173 |
173 if (item->GetState() == content::DownloadItem::CANCELLED) | 174 if (item->GetState() == content::DownloadItem::CANCELLED) |
174 return; | 175 return; |
175 | 176 |
176 DownloadItemModel(item).SetWasUINotified(true); | 177 DownloadItemModel(item).SetWasUINotified(true); |
177 delegate_->OnNewDownloadReady(item); | 178 delegate_->OnNewDownloadReady(item); |
178 } | 179 } |
OLD | NEW |