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

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

Issue 2688413012: Don't animate the download shelf when entering/exiting fullscreen. (Closed)
Patch Set: Turn on animation for all tests except the one that was flaky due to animation. Created 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "chrome/browser/download/download_shelf.h" 7 #include "chrome/browser/download/download_shelf.h"
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 142 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
143 FROM_HERE, 143 FROM_HERE,
144 base::Bind(&DownloadShelf::ShowDownloadById, 144 base::Bind(&DownloadShelf::ShowDownloadById,
145 weak_ptr_factory_.GetWeakPtr(), download->GetId()), 145 weak_ptr_factory_.GetWeakPtr(), download->GetId()),
146 GetTransientDownloadShowDelay()); 146 GetTransientDownloadShowDelay());
147 } else { 147 } else {
148 ShowDownload(download); 148 ShowDownload(download);
149 } 149 }
150 } 150 }
151 151
152 void DownloadShelf::Show() { 152 void DownloadShelf::Open() {
153 if (is_hidden_) { 153 if (is_hidden_) {
154 should_show_on_unhide_ = true; 154 should_show_on_unhide_ = true;
155 return; 155 return;
156 } 156 }
157 DoShow(); 157 DoOpen();
158 } 158 }
159 159
160 void DownloadShelf::Close(CloseReason reason) { 160 void DownloadShelf::Close(CloseReason reason) {
161 if (is_hidden_) { 161 if (is_hidden_) {
162 should_show_on_unhide_ = false; 162 should_show_on_unhide_ = false;
163 return; 163 return;
164 } 164 }
165 DoClose(reason); 165 DoClose(reason);
166 } 166 }
167 167
168 void DownloadShelf::Hide() { 168 void DownloadShelf::Hide() {
169 if (is_hidden_) 169 if (is_hidden_)
170 return; 170 return;
171 is_hidden_ = true; 171 is_hidden_ = true;
172 if (IsShowing()) { 172 if (IsShowing()) {
173 should_show_on_unhide_ = true; 173 should_show_on_unhide_ = true;
174 DoClose(AUTOMATIC); 174 DoHide();
175 } 175 }
176 } 176 }
177 177
178 void DownloadShelf::Unhide() { 178 void DownloadShelf::Unhide() {
179 if (!is_hidden_) 179 if (!is_hidden_)
180 return; 180 return;
181 is_hidden_ = false; 181 is_hidden_ = false;
182 if (should_show_on_unhide_) { 182 if (should_show_on_unhide_) {
183 should_show_on_unhide_ = false; 183 should_show_on_unhide_ = false;
184 DoShow(); 184 DoUnhide();
185 } 185 }
186 } 186 }
187 187
188 base::TimeDelta DownloadShelf::GetTransientDownloadShowDelay() { 188 base::TimeDelta DownloadShelf::GetTransientDownloadShowDelay() {
189 return base::TimeDelta::FromSeconds(kDownloadShowDelayInSeconds); 189 return base::TimeDelta::FromSeconds(kDownloadShowDelayInSeconds);
190 } 190 }
191 191
192 content::DownloadManager* DownloadShelf::GetDownloadManager() { 192 content::DownloadManager* DownloadShelf::GetDownloadManager() {
193 return content::BrowserContext::GetDownloadManager(browser()->profile()); 193 return content::BrowserContext::GetDownloadManager(browser()->profile());
194 } 194 }
195 195
196 void DownloadShelf::ShowDownload(DownloadItem* download) { 196 void DownloadShelf::ShowDownload(DownloadItem* download) {
197 if (download->GetState() == DownloadItem::COMPLETE && 197 if (download->GetState() == DownloadItem::COMPLETE &&
198 DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete()) 198 DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete())
199 return; 199 return;
200 if (!DownloadServiceFactory::GetForBrowserContext( 200 if (!DownloadServiceFactory::GetForBrowserContext(
201 download->GetBrowserContext())->IsShelfEnabled()) 201 download->GetBrowserContext())->IsShelfEnabled())
202 return; 202 return;
203 203
204 if (is_hidden_) 204 if (is_hidden_)
205 Unhide(); 205 Unhide();
206 Show(); 206 Open();
207 DoAddDownload(download); 207 DoAddDownload(download);
208 208
209 // browser() can be NULL for tests. 209 // browser() can be NULL for tests.
210 if (!browser()) 210 if (!browser())
211 return; 211 return;
212 212
213 // Show the download started animation if: 213 // Show the download started animation if:
214 // - Download started animation is enabled for this download. It is disabled 214 // - Download started animation is enabled for this download. It is disabled
215 // for "Save As" downloads and extension installs, for example. 215 // for "Save As" downloads and extension installs, for example.
216 // - The browser has an active visible WebContents. (browser isn't minimized, 216 // - The browser has an active visible WebContents. (browser isn't minimized,
(...skipping 13 matching lines...) Expand all
230 content::DownloadManager* download_manager = GetDownloadManager(); 230 content::DownloadManager* download_manager = GetDownloadManager();
231 if (!download_manager) 231 if (!download_manager)
232 return; 232 return;
233 233
234 DownloadItem* download = download_manager->GetDownload(download_id); 234 DownloadItem* download = download_manager->GetDownload(download_id);
235 if (!download) 235 if (!download)
236 return; 236 return;
237 237
238 ShowDownload(download); 238 ShowDownload(download);
239 } 239 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_shelf.h ('k') | chrome/browser/download/download_shelf_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698