| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // the order users would expect. | 120 // the order users would expect. |
| 121 AddChildViewAt(view, 0); | 121 AddChildViewAt(view, 0); |
| 122 if (download_views_.size() > kMaxDownloadViews) | 122 if (download_views_.size() > kMaxDownloadViews) |
| 123 RemoveDownloadView(*download_views_.begin()); | 123 RemoveDownloadView(*download_views_.begin()); |
| 124 | 124 |
| 125 new_item_animation_->Reset(); | 125 new_item_animation_->Reset(); |
| 126 new_item_animation_->Show(); | 126 new_item_animation_->Show(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void DownloadShelfView::DoAddDownload(DownloadItem* download) { | 129 void DownloadShelfView::DoAddDownload(DownloadItem* download) { |
| 130 DownloadItemView* view = new DownloadItemView(download, this); | 130 AddDownloadView(new DownloadItemView(download, this)); |
| 131 AddDownloadView(view); | |
| 132 } | 131 } |
| 133 | 132 |
| 134 void DownloadShelfView::MouseMovedOutOfHost() { | 133 void DownloadShelfView::MouseMovedOutOfHost() { |
| 135 Close(AUTOMATIC); | 134 Close(AUTOMATIC); |
| 136 } | 135 } |
| 137 | 136 |
| 138 void DownloadShelfView::RemoveDownloadView(View* view) { | 137 void DownloadShelfView::RemoveDownloadView(View* view) { |
| 139 DCHECK(view); | 138 DCHECK(view); |
| 140 std::vector<DownloadItemView*>::iterator i = | 139 std::vector<DownloadItemView*>::iterator i = |
| 141 find(download_views_.begin(), download_views_.end(), view); | 140 find(download_views_.begin(), download_views_.end(), view); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 358 |
| 360 void DownloadShelfView::LinkClicked(views::Link* source, int event_flags) { | 359 void DownloadShelfView::LinkClicked(views::Link* source, int event_flags) { |
| 361 chrome::ShowDownloads(browser_); | 360 chrome::ShowDownloads(browser_); |
| 362 } | 361 } |
| 363 | 362 |
| 364 void DownloadShelfView::ButtonPressed( | 363 void DownloadShelfView::ButtonPressed( |
| 365 views::Button* button, const ui::Event& event) { | 364 views::Button* button, const ui::Event& event) { |
| 366 Close(USER_ACTION); | 365 Close(USER_ACTION); |
| 367 } | 366 } |
| 368 | 367 |
| 368 void DownloadShelfView::RemoveDownload(DownloadItem* download) { |
| 369 for (size_t i = 0; i < download_views_.size(); ++i) { |
| 370 if (download_views_[i]->download() == download) { |
| 371 RemoveDownloadView(download_views_[i]); |
| 372 return; |
| 373 } |
| 374 } |
| 375 } |
| 376 |
| 369 bool DownloadShelfView::IsShowing() const { | 377 bool DownloadShelfView::IsShowing() const { |
| 370 return visible() && shelf_animation_->IsShowing(); | 378 return visible() && shelf_animation_->IsShowing(); |
| 371 } | 379 } |
| 372 | 380 |
| 373 bool DownloadShelfView::IsClosing() const { | 381 bool DownloadShelfView::IsClosing() const { |
| 374 return shelf_animation_->IsClosing(); | 382 return shelf_animation_->IsClosing(); |
| 375 } | 383 } |
| 376 | 384 |
| 377 void DownloadShelfView::DoShow() { | 385 void DownloadShelfView::DoShow() { |
| 378 SetVisible(true); | 386 SetVisible(true); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 SetVisible(false); | 428 SetVisible(false); |
| 421 } | 429 } |
| 422 | 430 |
| 423 bool DownloadShelfView::CanAutoClose() { | 431 bool DownloadShelfView::CanAutoClose() { |
| 424 for (size_t i = 0; i < download_views_.size(); ++i) { | 432 for (size_t i = 0; i < download_views_.size(); ++i) { |
| 425 if (!download_views_[i]->download()->GetOpened()) | 433 if (!download_views_[i]->download()->GetOpened()) |
| 426 return false; | 434 return false; |
| 427 } | 435 } |
| 428 return true; | 436 return true; |
| 429 } | 437 } |
| OLD | NEW |