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

Side by Side Diff: chrome/browser/ui/gtk/download/download_shelf_gtk.cc

Issue 16018005: Use DownloadItem::GetState() in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stopping complete_animation_ when download is cancelled Created 7 years, 6 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) 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/gtk/download/download_shelf_gtk.h" 5 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 void DownloadShelfGtk::DoClose(CloseReason reason) { 201 void DownloadShelfGtk::DoClose(CloseReason reason) {
202 // When we are closing, we can vertically overlap the render view. Make sure 202 // When we are closing, we can vertically overlap the render view. Make sure
203 // we are on top. 203 // we are on top.
204 gdk_window_raise(gtk_widget_get_window(shelf_.get())); 204 gdk_window_raise(gtk_widget_get_window(shelf_.get()));
205 slide_widget_->Close(); 205 slide_widget_->Close();
206 browser_->UpdateDownloadShelfVisibility(false); 206 browser_->UpdateDownloadShelfVisibility(false);
207 int num_in_progress = 0; 207 int num_in_progress = 0;
208 for (size_t i = 0; i < download_items_.size(); ++i) { 208 for (size_t i = 0; i < download_items_.size(); ++i) {
209 if (download_items_[i]->download()->IsInProgress()) 209 if (download_items_[i]->download()->GetState() == DownloadItem::IN_PROGRESS)
210 ++num_in_progress; 210 ++num_in_progress;
211 } 211 }
212 download_util::RecordShelfClose( 212 download_util::RecordShelfClose(
213 download_items_.size(), num_in_progress, reason == AUTOMATIC); 213 download_items_.size(), num_in_progress, reason == AUTOMATIC);
214 SetCloseOnMouseOut(false); 214 SetCloseOnMouseOut(false);
215 } 215 }
216 216
217 Browser* DownloadShelfGtk::browser() const { 217 Browser* DownloadShelfGtk::browser() const {
218 return browser_; 218 return browser_;
219 } 219 }
220 220
221 void DownloadShelfGtk::Closed() { 221 void DownloadShelfGtk::Closed() {
222 // Don't remove completed downloads if the shelf is just being auto-hidden 222 // Don't remove completed downloads if the shelf is just being auto-hidden
223 // rather than explicitly closed by the user. 223 // rather than explicitly closed by the user.
224 if (is_hidden()) 224 if (is_hidden())
225 return; 225 return;
226 // When the close animation is complete, remove all completed downloads. 226 // When the close animation is complete, remove all completed downloads.
227 size_t i = 0; 227 size_t i = 0;
228 while (i < download_items_.size()) { 228 while (i < download_items_.size()) {
229 DownloadItem* download = download_items_[i]->download(); 229 DownloadItem* download = download_items_[i]->download();
230 bool is_transfer_done = download->IsComplete() || 230 DownloadItem::DownloadState state = download->GetState();
231 download->IsCancelled() || 231 bool is_transfer_done = state == DownloadItem::COMPLETE ||
232 download->IsInterrupted(); 232 state == DownloadItem::CANCELLED ||
233 state == DownloadItem::INTERRUPTED;
233 if (is_transfer_done && !download->IsDangerous()) { 234 if (is_transfer_done && !download->IsDangerous()) {
234 RemoveDownloadItem(download_items_[i]); 235 RemoveDownloadItem(download_items_[i]);
235 } else { 236 } else {
236 // We set all remaining items as "opened", so that the shelf will auto- 237 // We set all remaining items as "opened", so that the shelf will auto-
237 // close in the future without the user clicking on them. 238 // close in the future without the user clicking on them.
238 download->SetOpened(true); 239 download->SetOpened(true);
239 ++i; 240 ++i;
240 } 241 }
241 } 242 }
242 } 243 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 base::MessageLoop::current()->PostDelayedTask( 398 base::MessageLoop::current()->PostDelayedTask(
398 FROM_HERE, 399 FROM_HERE,
399 base::Bind( 400 base::Bind(
400 &DownloadShelfGtk::Close, weak_factory_.GetWeakPtr(), AUTOMATIC), 401 &DownloadShelfGtk::Close, weak_factory_.GetWeakPtr(), AUTOMATIC),
401 base::TimeDelta::FromMilliseconds(kAutoCloseDelayMs)); 402 base::TimeDelta::FromMilliseconds(kAutoCloseDelayMs));
402 } 403 }
403 404
404 void DownloadShelfGtk::MouseEnteredShelf() { 405 void DownloadShelfGtk::MouseEnteredShelf() {
405 weak_factory_.InvalidateWeakPtrs(); 406 weak_factory_.InvalidateWeakPtrs();
406 } 407 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download/download_item_gtk.cc ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698