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

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

Issue 3127008: Preliminary work on resuming downloads whose connections have expired.
Patch Set: Waiting to send download automation error message until after other downloads are canceled. Created 10 years, 3 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 download_views_.push_back(view); 133 download_views_.push_back(view);
134 AddChildView(view); 134 AddChildView(view);
135 if (download_views_.size() > kMaxDownloadViews) 135 if (download_views_.size() > kMaxDownloadViews)
136 RemoveDownloadView(*download_views_.begin()); 136 RemoveDownloadView(*download_views_.begin());
137 137
138 new_item_animation_->Reset(); 138 new_item_animation_->Reset();
139 new_item_animation_->Show(); 139 new_item_animation_->Show();
140 } 140 }
141 141
142 void DownloadShelfView::AddDownload(BaseDownloadItemModel* download_model) { 142 void DownloadShelfView::AddDownload(BaseDownloadItemModel* download_model) {
143 DownloadItemView* view = new DownloadItemView( 143 DownloadItem* dld = download_model->download();
144 download_model->download(), this, download_model); 144 // If we already have an ID, we must be restarting an interrupted download.
145 // Don't add a new one in this case.
146 for (size_t i = 0; i < download_views_.size(); ++i) {
147 DownloadItem* download = download_views_[i]->download();
148 if (download->id() == dld->id())
149 return;
150 }
151 DownloadItemView* view = new DownloadItemView(dld, this, download_model);
145 AddDownloadView(view); 152 AddDownloadView(view);
146 } 153 }
147 154
148 void DownloadShelfView::MouseMovedOutOfView() { 155 void DownloadShelfView::MouseMovedOutOfView() {
149 Close(); 156 Close();
150 } 157 }
151 158
152 void DownloadShelfView::RemoveDownloadView(View* view) { 159 void DownloadShelfView::RemoveDownloadView(View* view) {
153 DCHECK(view); 160 DCHECK(view);
154 std::vector<DownloadItemView*>::iterator i = 161 std::vector<DownloadItemView*>::iterator i =
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 381 }
375 } 382 }
376 383
377 bool DownloadShelfView::CanAutoClose() { 384 bool DownloadShelfView::CanAutoClose() {
378 for (size_t i = 0; i < download_views_.size(); ++i) { 385 for (size_t i = 0; i < download_views_.size(); ++i) {
379 if (!download_views_[i]->download()->opened()) 386 if (!download_views_[i]->download()->opened())
380 return false; 387 return false;
381 } 388 }
382 return true; 389 return true;
383 } 390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698