Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/download/download_ui_controller.cc

Issue 1704793002: Remove kDisableDownloadNotification and stop compiling shelf code on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Ones which are INTERRUPTED etc. can't be handed over to the Android 54 // Ones which are INTERRUPTED etc. can't be handed over to the Android
55 // DownloadManager. 55 // DownloadManager.
56 if (item->GetState() != content::DownloadItem::IN_PROGRESS) 56 if (item->GetState() != content::DownloadItem::IN_PROGRESS)
57 return; 57 return;
58 58
59 // GET downloads without authentication are delegated to the Android 59 // GET downloads without authentication are delegated to the Android
60 // DownloadManager. Chrome is responsible for the rest. See 60 // DownloadManager. Chrome is responsible for the rest. See
61 // InterceptDownloadResourceThrottle::ProcessDownloadRequest(). 61 // InterceptDownloadResourceThrottle::ProcessDownloadRequest().
62 content::DownloadControllerAndroid::Get()->OnDownloadStarted(item); 62 content::DownloadControllerAndroid::Get()->OnDownloadStarted(item);
63 } 63 }
64 64 #elif !defined(OS_CHROMEOS)
65 #else // OS_ANDROID
66
67 class DownloadShelfUIControllerDelegate 65 class DownloadShelfUIControllerDelegate
68 : public DownloadUIController::Delegate { 66 : public DownloadUIController::Delegate {
69 public: 67 public:
70 // |profile| is required to outlive DownloadShelfUIControllerDelegate. 68 // |profile| is required to outlive DownloadShelfUIControllerDelegate.
71 explicit DownloadShelfUIControllerDelegate(Profile* profile) 69 explicit DownloadShelfUIControllerDelegate(Profile* profile)
72 : profile_(profile) {} 70 : profile_(profile) {}
73 ~DownloadShelfUIControllerDelegate() override {} 71 ~DownloadShelfUIControllerDelegate() override {}
74 72
75 private: 73 private:
76 // DownloadUIController::Delegate 74 // DownloadUIController::Delegate
(...skipping 12 matching lines...) Expand all
89 // but better than not showing the download at all. 87 // but better than not showing the download at all.
90 if (browser == nullptr) 88 if (browser == nullptr)
91 browser = chrome::FindLastActiveWithProfile(profile_); 89 browser = chrome::FindLastActiveWithProfile(profile_);
92 90
93 if (browser && browser->window() && 91 if (browser && browser->window() &&
94 DownloadItemModel(item).ShouldShowInShelf()) { 92 DownloadItemModel(item).ShouldShowInShelf()) {
95 // GetDownloadShelf creates the download shelf if it was not yet created. 93 // GetDownloadShelf creates the download shelf if it was not yet created.
96 browser->window()->GetDownloadShelf()->AddDownload(item); 94 browser->window()->GetDownloadShelf()->AddDownload(item);
97 } 95 }
98 } 96 }
99 97 #endif
100 #endif // !OS_ANDROID
101 98
102 } // namespace 99 } // namespace
103 100
104 DownloadUIController::Delegate::~Delegate() { 101 DownloadUIController::Delegate::~Delegate() {
105 } 102 }
106 103
107 DownloadUIController::DownloadUIController(content::DownloadManager* manager, 104 DownloadUIController::DownloadUIController(content::DownloadManager* manager,
108 scoped_ptr<Delegate> delegate) 105 scoped_ptr<Delegate> delegate)
109 : download_notifier_(manager, this), delegate_(std::move(delegate)) { 106 : download_notifier_(manager, this), delegate_(std::move(delegate)) {
107 if (!delegate_) {
110 #if defined(OS_ANDROID) 108 #if defined(OS_ANDROID)
111 if (!delegate_)
112 delegate_.reset(new AndroidUIControllerDelegate()); 109 delegate_.reset(new AndroidUIControllerDelegate());
113 #else 110 #elif defined(OS_CHROMEOS)
114 #if defined(OS_CHROMEOS)
115 if (!delegate_ && DownloadNotificationManager::IsEnabled()) {
116 // The Profile is guaranteed to be valid since DownloadUIController is owned 111 // The Profile is guaranteed to be valid since DownloadUIController is owned
117 // by DownloadService, which in turn is a profile keyed service. 112 // by DownloadService, which in turn is a profile keyed service.
118 delegate_.reset(new DownloadNotificationManager( 113 delegate_.reset(new DownloadNotificationManager(
119 Profile::FromBrowserContext(manager->GetBrowserContext()))); 114 Profile::FromBrowserContext(manager->GetBrowserContext())));
120 } 115 #else
121 #endif // defined(OS_CHROMEOS)
122 if (!delegate_) {
123 delegate_.reset(new DownloadShelfUIControllerDelegate( 116 delegate_.reset(new DownloadShelfUIControllerDelegate(
124 Profile::FromBrowserContext(manager->GetBrowserContext()))); 117 Profile::FromBrowserContext(manager->GetBrowserContext())));
118 #endif
125 } 119 }
126 #endif // defined(OS_ANDROID)
127 } 120 }
128 121
129 DownloadUIController::~DownloadUIController() { 122 DownloadUIController::~DownloadUIController() {
130 } 123 }
131 124
132 void DownloadUIController::OnDownloadCreated(content::DownloadManager* manager, 125 void DownloadUIController::OnDownloadCreated(content::DownloadManager* manager,
133 content::DownloadItem* item) { 126 content::DownloadItem* item) {
134 // SavePackage downloads are created in a state where they can be shown in the 127 // SavePackage downloads are created in a state where they can be shown in the
135 // browser. Call OnDownloadUpdated() once to notify the UI immediately. 128 // browser. Call OnDownloadUpdated() once to notify the UI immediately.
136 OnDownloadUpdated(manager, item); 129 OnDownloadUpdated(manager, item);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 161 }
169 } 162 }
170 #endif 163 #endif
171 164
172 if (item->GetState() == content::DownloadItem::CANCELLED) 165 if (item->GetState() == content::DownloadItem::CANCELLED)
173 return; 166 return;
174 167
175 DownloadItemModel(item).SetWasUINotified(true); 168 DownloadItemModel(item).SetWasUINotified(true);
176 delegate_->OnNewDownloadReady(item); 169 delegate_->OnNewDownloadReady(item);
177 } 170 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/notification/download_notification_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698