| 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/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/download/download_util.h" | 10 #include "chrome/browser/download/download_util.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 [[[itemController view] animator] setFrame:frame]; | 285 [[[itemController view] animator] setFrame:frame]; |
| 286 currentX += frame.size.width + kDownloadItemPadding; | 286 currentX += frame.size.width + kDownloadItemPadding; |
| 287 skipFirst = NO; | 287 skipFirst = NO; |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 - (void)layoutItems { | 291 - (void)layoutItems { |
| 292 [self layoutItems:NO]; | 292 [self layoutItems:NO]; |
| 293 } | 293 } |
| 294 | 294 |
| 295 - (void)addDownloadItem:(DownloadItemModel*)model { | 295 - (void)addDownloadItem:(DownloadItem*)downloadItem { |
| 296 DCHECK([NSThread isMainThread]); | 296 DCHECK([NSThread isMainThread]); |
| 297 [self cancelAutoCloseAndRemoveTrackingArea]; | 297 [self cancelAutoCloseAndRemoveTrackingArea]; |
| 298 | 298 |
| 299 // Insert new item at the left. | 299 // Insert new item at the left. |
| 300 scoped_nsobject<DownloadItemController> controller( | 300 scoped_nsobject<DownloadItemController> controller( |
| 301 [[DownloadItemController alloc] initWithModel:model | 301 [[DownloadItemController alloc] initWithDownload:downloadItem |
| 302 shelf:self | 302 shelf:self |
| 303 navigator:navigator_]); | 303 navigator:navigator_]); |
| 304 | 304 |
| 305 // Adding at index 0 in NSMutableArrays is O(1). | 305 // Adding at index 0 in NSMutableArrays is O(1). |
| 306 [downloadItemControllers_ insertObject:controller.get() atIndex:0]; | 306 [downloadItemControllers_ insertObject:controller.get() atIndex:0]; |
| 307 | 307 |
| 308 [itemContainerView_ addSubview:[controller view]]; | 308 [itemContainerView_ addSubview:[controller view]]; |
| 309 | 309 |
| 310 // The controller is in charge of removing itself as an observer in its | 310 // The controller is in charge of removing itself as an observer in its |
| 311 // dealloc. | 311 // dealloc. |
| 312 [[NSNotificationCenter defaultCenter] | 312 [[NSNotificationCenter defaultCenter] |
| 313 addObserver:controller | 313 addObserver:controller |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 460 } |
| 461 | 461 |
| 462 // Set the tracking off to create a new tracking area for the control. | 462 // Set the tracking off to create a new tracking area for the control. |
| 463 // When changing the bounds/frame on a HoverButton, the tracking isn't updated | 463 // When changing the bounds/frame on a HoverButton, the tracking isn't updated |
| 464 // correctly, it needs to be turned off and back on. | 464 // correctly, it needs to be turned off and back on. |
| 465 [hoverCloseButton_ setTrackingEnabled:NO]; | 465 [hoverCloseButton_ setTrackingEnabled:NO]; |
| 466 [hoverCloseButton_ setFrame:bounds]; | 466 [hoverCloseButton_ setFrame:bounds]; |
| 467 [hoverCloseButton_ setTrackingEnabled:YES]; | 467 [hoverCloseButton_ setTrackingEnabled:YES]; |
| 468 } | 468 } |
| 469 @end | 469 @end |
| OLD | NEW |