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

Side by Side Diff: chrome/browser/ui/cocoa/download/download_shelf_controller.mm

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 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 5 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/browser/download/download_util.h" 10 #include "chrome/browser/download/download_util.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 isUserAction:(BOOL)isUserAction { 232 isUserAction:(BOOL)isUserAction {
233 [self cancelAutoClose]; 233 [self cancelAutoClose];
234 shouldCloseOnMouseExit_ = NO; 234 shouldCloseOnMouseExit_ = NO;
235 235
236 if ([self isVisible] == show) 236 if ([self isVisible] == show)
237 return; 237 return;
238 238
239 if (!show) { 239 if (!show) {
240 int numInProgress = 0; 240 int numInProgress = 0;
241 for (NSUInteger i = 0; i < [downloadItemControllers_ count]; ++i) { 241 for (NSUInteger i = 0; i < [downloadItemControllers_ count]; ++i) {
242 if ([[downloadItemControllers_ objectAtIndex:i]download]->IsInProgress()) 242 DownloadItem* item = [[downloadItemControllers_ objectAtIndex:i]download];
243 if (item->GetState() == DownloadItem::IN_PROGRESS)
243 ++numInProgress; 244 ++numInProgress;
244 } 245 }
245 download_util::RecordShelfClose( 246 download_util::RecordShelfClose(
246 [downloadItemControllers_ count], numInProgress, !isUserAction); 247 [downloadItemControllers_ count], numInProgress, !isUserAction);
247 } 248 }
248 249
249 // Animate the shelf out, but not in. 250 // Animate the shelf out, but not in.
250 // TODO(rohitrao): We do not animate on the way in because Cocoa is already 251 // TODO(rohitrao): We do not animate on the way in because Cocoa is already
251 // doing a lot of work to set up the download arrow animation. I've chosen to 252 // doing a lot of work to set up the download arrow animation. I've chosen to
252 // do no animation over janky animation. Find a way to make animating in 253 // do no animation over janky animation. Find a way to make animating in
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 - (void)closed { 365 - (void)closed {
365 // Don't remove completed downloads if the shelf is just being auto-hidden 366 // Don't remove completed downloads if the shelf is just being auto-hidden
366 // rather than explicitly closed by the user. 367 // rather than explicitly closed by the user.
367 if (bridge_->is_hidden()) 368 if (bridge_->is_hidden())
368 return; 369 return;
369 NSUInteger i = 0; 370 NSUInteger i = 0;
370 while (i < [downloadItemControllers_ count]) { 371 while (i < [downloadItemControllers_ count]) {
371 DownloadItemController* itemController = 372 DownloadItemController* itemController =
372 [downloadItemControllers_ objectAtIndex:i]; 373 [downloadItemControllers_ objectAtIndex:i];
373 DownloadItem* download = [itemController download]; 374 DownloadItem* download = [itemController download];
374 bool isTransferDone = download->IsComplete() || 375 DownloadItem::DownloadState state = download->GetState();
375 download->IsCancelled() || 376 bool isTransferDone = state == DownloadItem::COMPLETE ||
376 download->IsInterrupted(); 377 state == DownloadItem::CANCELLED ||
378 state == DownloadItem::INTERRUPTED;
377 if (isTransferDone && !download->IsDangerous()) { 379 if (isTransferDone && !download->IsDangerous()) {
378 [self removeDownload:itemController 380 [self removeDownload:itemController
379 isShelfClosing:YES]; 381 isShelfClosing:YES];
380 } else { 382 } else {
381 // Treat the item as opened when we close. This way if we get shown again 383 // Treat the item as opened when we close. This way if we get shown again
382 // the user need not open this item for the shelf to auto-close. 384 // the user need not open this item for the shelf to auto-close.
383 download->SetOpened(true); 385 download->SetOpened(true);
384 ++i; 386 ++i;
385 } 387 }
386 } 388 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 502 }
501 503
502 // Set the tracking off to create a new tracking area for the control. 504 // Set the tracking off to create a new tracking area for the control.
503 // When changing the bounds/frame on a HoverButton, the tracking isn't updated 505 // When changing the bounds/frame on a HoverButton, the tracking isn't updated
504 // correctly, it needs to be turned off and back on. 506 // correctly, it needs to be turned off and back on.
505 [hoverCloseButton_ setTrackingEnabled:NO]; 507 [hoverCloseButton_ setTrackingEnabled:NO];
506 [hoverCloseButton_ setFrame:bounds]; 508 [hoverCloseButton_ setFrame:bounds];
507 [hoverCloseButton_ setTrackingEnabled:YES]; 509 [hoverCloseButton_ setTrackingEnabled:YES];
508 } 510 }
509 @end 511 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698