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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // setting the rect to NSZeroRect does not work: it confuses Cocoa's view | 105 // setting the rect to NSZeroRect does not work: it confuses Cocoa's view |
106 // layout logic. If the shelf's width is too small, cocoa makes the download | 106 // layout logic. If the shelf's width is too small, cocoa makes the download |
107 // item container view wider than the browser window). | 107 // item container view wider than the browser window). |
108 NSRect frame = [[self view] frame]; | 108 NSRect frame = [[self view] frame]; |
109 frame.size.height = 0; | 109 frame.size.height = 0; |
110 [[self view] setFrame:frame]; | 110 [[self view] setFrame:frame]; |
111 | 111 |
112 downloadItemControllers_.reset([[NSMutableArray alloc] init]); | 112 downloadItemControllers_.reset([[NSMutableArray alloc] init]); |
113 | 113 |
114 bridge_.reset(new DownloadShelfMac(browser, self)); | 114 bridge_.reset(new DownloadShelfMac(browser, self)); |
| 115 navigator_ = browser; |
115 } | 116 } |
116 return self; | 117 return self; |
117 } | 118 } |
118 | 119 |
119 - (void)awakeFromNib { | 120 - (void)awakeFromNib { |
120 DCHECK(hoverCloseButton_); | 121 DCHECK(hoverCloseButton_); |
121 | 122 |
122 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; | 123 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; |
123 [[self animatableView] setResizeDelegate:resizeDelegate_]; | 124 [[self animatableView] setResizeDelegate:resizeDelegate_]; |
124 [[self view] setPostsFrameChangedNotifications:YES]; | 125 [[self view] setPostsFrameChangedNotifications:YES]; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 - (void)layoutItems { | 290 - (void)layoutItems { |
290 [self layoutItems:NO]; | 291 [self layoutItems:NO]; |
291 } | 292 } |
292 | 293 |
293 - (void)addDownloadItem:(BaseDownloadItemModel*)model { | 294 - (void)addDownloadItem:(BaseDownloadItemModel*)model { |
294 DCHECK([NSThread isMainThread]); | 295 DCHECK([NSThread isMainThread]); |
295 [self cancelAutoCloseAndRemoveTrackingArea]; | 296 [self cancelAutoCloseAndRemoveTrackingArea]; |
296 | 297 |
297 // Insert new item at the left. | 298 // Insert new item at the left. |
298 scoped_nsobject<DownloadItemController> controller( | 299 scoped_nsobject<DownloadItemController> controller( |
299 [[DownloadItemController alloc] initWithModel:model shelf:self]); | 300 [[DownloadItemController alloc] initWithModel:model |
| 301 shelf:self |
| 302 navigator:navigator_]); |
300 | 303 |
301 // Adding at index 0 in NSMutableArrays is O(1). | 304 // Adding at index 0 in NSMutableArrays is O(1). |
302 [downloadItemControllers_ insertObject:controller.get() atIndex:0]; | 305 [downloadItemControllers_ insertObject:controller.get() atIndex:0]; |
303 | 306 |
304 [itemContainerView_ addSubview:[controller view]]; | 307 [itemContainerView_ addSubview:[controller view]]; |
305 | 308 |
306 // The controller is in charge of removing itself as an observer in its | 309 // The controller is in charge of removing itself as an observer in its |
307 // dealloc. | 310 // dealloc. |
308 [[NSNotificationCenter defaultCenter] | 311 [[NSNotificationCenter defaultCenter] |
309 addObserver:controller | 312 addObserver:controller |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 459 } |
457 | 460 |
458 // Set the tracking off to create a new tracking area for the control. | 461 // Set the tracking off to create a new tracking area for the control. |
459 // When changing the bounds/frame on a HoverButton, the tracking isn't updated | 462 // When changing the bounds/frame on a HoverButton, the tracking isn't updated |
460 // correctly, it needs to be turned off and back on. | 463 // correctly, it needs to be turned off and back on. |
461 [hoverCloseButton_ setTrackingEnabled:NO]; | 464 [hoverCloseButton_ setTrackingEnabled:NO]; |
462 [hoverCloseButton_ setFrame:bounds]; | 465 [hoverCloseButton_ setFrame:bounds]; |
463 [hoverCloseButton_ setTrackingEnabled:YES]; | 466 [hoverCloseButton_ setTrackingEnabled:YES]; |
464 } | 467 } |
465 @end | 468 @end |
OLD | NEW |