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

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

Issue 10421021: Make DownloadProtectionService not use BrowserList::GetLastActive() to load a link. Instead pass th… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
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/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
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_shelf_controller.h ('k') | chrome/browser/ui/gtk/download/download_item_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698