OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/download/download_item_model.h" | 11 #include "chrome/browser/download/download_item_model.h" |
12 #include "chrome/browser/themes/theme_service.h" | 12 #include "chrome/browser/themes/theme_service.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/view_ids.h" | 14 #include "chrome/browser/ui/view_ids.h" |
15 #include "chrome/browser/ui/views/download/download_item_view.h" | 15 #include "chrome/browser/ui/views/download/download_item_view.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "content/browser/download/download_item.h" | 17 #include "content/browser/download/download_item.h" |
18 #include "content/browser/download/download_stats.h" | |
18 #include "content/browser/download/download_manager.h" | 19 #include "content/browser/download/download_manager.h" |
19 #include "content/browser/tab_contents/navigation_entry.h" | 20 #include "content/browser/tab_contents/navigation_entry.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
22 #include "grit/theme_resources_standard.h" | 23 #include "grit/theme_resources_standard.h" |
23 #include "ui/base/animation/slide_animation.h" | 24 #include "ui/base/animation/slide_animation.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
27 #include "views/background.h" | 28 #include "views/background.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 | 377 |
377 bool DownloadShelfView::IsClosing() const { | 378 bool DownloadShelfView::IsClosing() const { |
378 return shelf_animation_->IsClosing(); | 379 return shelf_animation_->IsClosing(); |
379 } | 380 } |
380 | 381 |
381 void DownloadShelfView::Show() { | 382 void DownloadShelfView::Show() { |
382 shelf_animation_->Show(); | 383 shelf_animation_->Show(); |
383 } | 384 } |
384 | 385 |
385 void DownloadShelfView::Close() { | 386 void DownloadShelfView::Close() { |
387 download_stats::RecordShelfSize(download_views_.size()); | |
388 int num_pending = 0; | |
389 for (size_t i = 0; i < download_views_.size(); ++i) { | |
390 DownloadItem* download = download_views_[i]->download(); | |
391 bool is_transfer_done = download->IsComplete() || | |
brettw
2011/10/01 16:45:45
This code is duplicated a number of times. Should
benjhayden
2011/10/03 20:54:39
Done with IsInProgress().
| |
392 download->IsCancelled() || | |
393 download->IsInterrupted(); | |
394 if (!is_transfer_done) | |
395 ++num_pending; | |
396 } | |
397 download_stats::RecordShelfPendingSize(num_pending); | |
386 parent_->SetDownloadShelfVisible(false); | 398 parent_->SetDownloadShelfVisible(false); |
387 shelf_animation_->Hide(); | 399 shelf_animation_->Hide(); |
388 } | 400 } |
389 | 401 |
390 Browser* DownloadShelfView::browser() const { | 402 Browser* DownloadShelfView::browser() const { |
391 return browser_; | 403 return browser_; |
392 } | 404 } |
393 | 405 |
394 void DownloadShelfView::Closed() { | 406 void DownloadShelfView::Closed() { |
395 // When the close animation is complete, remove all completed downloads. | 407 // When the close animation is complete, remove all completed downloads. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 const DownloadItemView* download_item_view) { | 455 const DownloadItemView* download_item_view) { |
444 gfx::Rect bounds = download_item_view->bounds(); | 456 gfx::Rect bounds = download_item_view->bounds(); |
445 | 457 |
446 #if defined(TOOLKIT_VIEWS) | 458 #if defined(TOOLKIT_VIEWS) |
447 bounds.set_height(bounds.height() - 1); | 459 bounds.set_height(bounds.height() - 1); |
448 bounds.Offset(0, 3); | 460 bounds.Offset(0, 3); |
449 #endif | 461 #endif |
450 | 462 |
451 return bounds; | 463 return bounds; |
452 } | 464 } |
OLD | NEW |