| 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 #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/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/download/download_stats.h" | 9 #include "chrome/browser/download/download_stats.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 - (void)addDownloadItem:(DownloadItem*)downloadItem { | 303 - (void)addDownloadItem:(DownloadItem*)downloadItem { |
| 304 DCHECK([NSThread isMainThread]); | 304 DCHECK([NSThread isMainThread]); |
| 305 base::scoped_nsobject<DownloadItemController> controller( | 305 base::scoped_nsobject<DownloadItemController> controller( |
| 306 [[DownloadItemController alloc] initWithDownload:downloadItem | 306 [[DownloadItemController alloc] initWithDownload:downloadItem |
| 307 shelf:self | 307 shelf:self |
| 308 navigator:navigator_]); | 308 navigator:navigator_]); |
| 309 [self add:controller.get()]; | 309 [self add:controller.get()]; |
| 310 } | 310 } |
| 311 | 311 |
| 312 - (void)removeDownloadItem:(DownloadItem*)downloadItem { |
| 313 for (NSUInteger i = 0; i < [downloadItemControllers_ count]; ++i) { |
| 314 DownloadItemController* itemController = |
| 315 [downloadItemControllers_ objectAtIndex:i]; |
| 316 if ([itemController download] == downloadItem) { |
| 317 [self remove:itemController]; |
| 318 return; |
| 319 } |
| 320 } |
| 321 } |
| 322 |
| 312 - (void)add:(DownloadItemController*)controller { | 323 - (void)add:(DownloadItemController*)controller { |
| 313 DCHECK([NSThread isMainThread]); | 324 DCHECK([NSThread isMainThread]); |
| 314 [self cancelAutoClose]; | 325 [self cancelAutoClose]; |
| 315 shouldCloseOnMouseExit_ = NO; | 326 shouldCloseOnMouseExit_ = NO; |
| 316 | 327 |
| 317 // Insert new item at the left. | 328 // Insert new item at the left. |
| 318 // Adding at index 0 in NSMutableArrays is O(1). | 329 // Adding at index 0 in NSMutableArrays is O(1). |
| 319 [downloadItemControllers_ insertObject:controller atIndex:0]; | 330 [downloadItemControllers_ insertObject:controller atIndex:0]; |
| 320 | 331 |
| 321 [itemContainerView_ addSubview:[controller view]]; | 332 [itemContainerView_ addSubview:[controller view]]; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 } | 515 } |
| 505 | 516 |
| 506 // Set the tracking off to create a new tracking area for the control. | 517 // Set the tracking off to create a new tracking area for the control. |
| 507 // When changing the bounds/frame on a HoverButton, the tracking isn't updated | 518 // When changing the bounds/frame on a HoverButton, the tracking isn't updated |
| 508 // correctly, it needs to be turned off and back on. | 519 // correctly, it needs to be turned off and back on. |
| 509 [hoverCloseButton_ setTrackingEnabled:NO]; | 520 [hoverCloseButton_ setTrackingEnabled:NO]; |
| 510 [hoverCloseButton_ setFrame:bounds]; | 521 [hoverCloseButton_ setFrame:bounds]; |
| 511 [hoverCloseButton_ setTrackingEnabled:YES]; | 522 [hoverCloseButton_ setTrackingEnabled:YES]; |
| 512 } | 523 } |
| 513 @end | 524 @end |
| OLD | NEW |