OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |