| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/download_shelf_view.h" | 5 #include "chrome/browser/views/download_shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/app/theme/theme_resources.h" | 9 #include "chrome/app/theme/theme_resources.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 new_item_animation_.reset(new SlideAnimation(this)); | 105 new_item_animation_.reset(new SlideAnimation(this)); |
| 106 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); | 106 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); |
| 107 | 107 |
| 108 shelf_animation_.reset(new SlideAnimation(this)); | 108 shelf_animation_.reset(new SlideAnimation(this)); |
| 109 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs); | 109 shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs); |
| 110 shelf_animation_->Show(); | 110 shelf_animation_->Show(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void DownloadShelfView::AddDownloadView(View* view) { | 113 void DownloadShelfView::AddDownloadView(View* view) { |
| 114 shelf_animation_->Show(); |
| 115 |
| 114 DCHECK(view); | 116 DCHECK(view); |
| 115 download_views_.push_back(view); | 117 download_views_.push_back(view); |
| 116 AddChildView(view); | 118 AddChildView(view); |
| 117 if (download_views_.size() > kMaxDownloadViews) | 119 if (download_views_.size() > kMaxDownloadViews) |
| 118 RemoveDownloadView(*download_views_.begin()); | 120 RemoveDownloadView(*download_views_.begin()); |
| 119 | 121 |
| 120 new_item_animation_->Reset(); | 122 new_item_animation_->Reset(); |
| 121 new_item_animation_->Show(); | 123 new_item_animation_->Show(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 void DownloadShelfView::ChangeTabContents(TabContents* old_contents, | 126 void DownloadShelfView::ChangeTabContents(TabContents* old_contents, |
| 125 TabContents* new_contents) { | 127 TabContents* new_contents) { |
| 126 DCHECK(old_contents == tab_contents_); | 128 DCHECK(old_contents == tab_contents_); |
| 127 tab_contents_ = new_contents; | 129 tab_contents_ = new_contents; |
| 128 } | 130 } |
| 129 | 131 |
| 130 void DownloadShelfView::AddDownload(DownloadItem* download) { | 132 void DownloadShelfView::AddDownload(DownloadItem* download) { |
| 131 shelf_animation_->Show(); | |
| 132 | |
| 133 DownloadItemView* view = new DownloadItemView( | 133 DownloadItemView* view = new DownloadItemView( |
| 134 download, this, new DownloadItemModel(download)); | 134 download, this, new DownloadItemModel(download)); |
| 135 AddDownloadView(view); | 135 AddDownloadView(view); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void DownloadShelfView::RemoveDownloadView(View* view) { | 138 void DownloadShelfView::RemoveDownloadView(View* view) { |
| 139 DCHECK(view); | 139 DCHECK(view); |
| 140 std::vector<View*>::iterator i = | 140 std::vector<View*>::iterator i = |
| 141 find(download_views_.begin(), download_views_.end(), view); | 141 find(download_views_.begin(), download_views_.end(), view); |
| 142 DCHECK(i != download_views_.end()); | 142 DCHECK(i != download_views_.end()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 int index; | 262 int index; |
| 263 NavigationController* controller = tab_contents_->controller(); | 263 NavigationController* controller = tab_contents_->controller(); |
| 264 Browser* browser = Browser::GetBrowserForController(controller, &index); | 264 Browser* browser = Browser::GetBrowserForController(controller, &index); |
| 265 DCHECK(browser); | 265 DCHECK(browser); |
| 266 browser->ShowNativeUITab(DownloadTabUI::GetURL()); | 266 browser->ShowNativeUITab(DownloadTabUI::GetURL()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void DownloadShelfView::ButtonPressed(views::BaseButton* button) { | 269 void DownloadShelfView::ButtonPressed(views::BaseButton* button) { |
| 270 shelf_animation_->Hide(); | 270 shelf_animation_->Hide(); |
| 271 } | 271 } |
| OLD | NEW |