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

Side by Side Diff: chrome/browser/ui/views/download/download_shelf_view.cc

Issue 16018005: Use DownloadItem::GetState() in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stopping complete_animation_ when download is cancelled Created 7 years, 6 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 #include "chrome/browser/ui/views/download/download_shelf_view.h" 5 #include "chrome/browser/ui/views/download/download_shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return shelf_animation_->IsClosing(); 396 return shelf_animation_->IsClosing();
397 } 397 }
398 398
399 void DownloadShelfView::DoShow() { 399 void DownloadShelfView::DoShow() {
400 shelf_animation_->Show(); 400 shelf_animation_->Show();
401 } 401 }
402 402
403 void DownloadShelfView::DoClose(CloseReason reason) { 403 void DownloadShelfView::DoClose(CloseReason reason) {
404 int num_in_progress = 0; 404 int num_in_progress = 0;
405 for (size_t i = 0; i < download_views_.size(); ++i) { 405 for (size_t i = 0; i < download_views_.size(); ++i) {
406 if (download_views_[i]->download()->IsInProgress()) 406 if (download_views_[i]->download()->GetState() == DownloadItem::IN_PROGRESS)
407 ++num_in_progress; 407 ++num_in_progress;
408 } 408 }
409 download_util::RecordShelfClose(download_views_.size(), 409 download_util::RecordShelfClose(download_views_.size(),
410 num_in_progress, 410 num_in_progress,
411 reason == AUTOMATIC); 411 reason == AUTOMATIC);
412 parent_->SetDownloadShelfVisible(false); 412 parent_->SetDownloadShelfVisible(false);
413 shelf_animation_->Hide(); 413 shelf_animation_->Hide();
414 } 414 }
415 415
416 Browser* DownloadShelfView::browser() const { 416 Browser* DownloadShelfView::browser() const {
417 return browser_; 417 return browser_;
418 } 418 }
419 419
420 void DownloadShelfView::Closed() { 420 void DownloadShelfView::Closed() {
421 // Don't remove completed downloads if the shelf is just being auto-hidden 421 // Don't remove completed downloads if the shelf is just being auto-hidden
422 // rather than explicitly closed by the user. 422 // rather than explicitly closed by the user.
423 if (is_hidden()) 423 if (is_hidden())
424 return; 424 return;
425 // When the close animation is complete, remove all completed downloads. 425 // When the close animation is complete, remove all completed downloads.
426 size_t i = 0; 426 size_t i = 0;
427 while (i < download_views_.size()) { 427 while (i < download_views_.size()) {
428 DownloadItem* download = download_views_[i]->download(); 428 DownloadItem* download = download_views_[i]->download();
429 bool is_transfer_done = download->IsComplete() || 429 DownloadItem::DownloadState state = download->GetState();
430 download->IsCancelled() || 430 bool is_transfer_done = state == DownloadItem::COMPLETE ||
431 download->IsInterrupted(); 431 state == DownloadItem::CANCELLED ||
432 state == DownloadItem::INTERRUPTED;
432 if (is_transfer_done && !download->IsDangerous()) { 433 if (is_transfer_done && !download->IsDangerous()) {
433 RemoveDownloadView(download_views_[i]); 434 RemoveDownloadView(download_views_[i]);
434 } else { 435 } else {
435 // Treat the item as opened when we close. This way if we get shown again 436 // Treat the item as opened when we close. This way if we get shown again
436 // the user need not open this item for the shelf to auto-close. 437 // the user need not open this item for the shelf to auto-close.
437 download->SetOpened(true); 438 download->SetOpened(true);
438 ++i; 439 ++i;
439 } 440 }
440 } 441 }
441 } 442 }
(...skipping 30 matching lines...) Expand all
472 const DownloadItemView* download_item_view) { 473 const DownloadItemView* download_item_view) {
473 gfx::Rect bounds = download_item_view->bounds(); 474 gfx::Rect bounds = download_item_view->bounds();
474 475
475 #if defined(TOOLKIT_VIEWS) 476 #if defined(TOOLKIT_VIEWS)
476 bounds.set_height(bounds.height() - 1); 477 bounds.set_height(bounds.height() - 1);
477 bounds.Offset(0, 3); 478 bounds.Offset(0, 3);
478 #endif 479 #endif
479 480
480 return bounds; 481 return bounds;
481 } 482 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.cc ('k') | chrome/browser/ui/webui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698