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

Side by Side Diff: chrome/browser/cocoa/infobar_container_controller.mm

Issue 159776: Rewrites the Mac view resizing logic to have the BrowserWindowController... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/mac_util.h" 6 #include "base/mac_util.h"
7 #import "chrome/browser/cocoa/browser_window_controller.h"
8 #include "chrome/browser/cocoa/infobar.h" 7 #include "chrome/browser/cocoa/infobar.h"
9 #import "chrome/browser/cocoa/infobar_container_controller.h" 8 #import "chrome/browser/cocoa/infobar_container_controller.h"
10 #import "chrome/browser/cocoa/infobar_controller.h" 9 #import "chrome/browser/cocoa/infobar_controller.h"
11 #include "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" 10 #include "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/common/notification_service.h" 12 #include "chrome/common/notification_service.h"
14 #include "skia/ext/skia_utils_mac.h" 13 #include "skia/ext/skia_utils_mac.h"
15 14
16 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED 15 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED
17 // notifications and proxies them back to |controller|. 16 // notifications and proxies them back to |controller|.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // infobars, removes them first and deregisters for any 56 // infobars, removes them first and deregisters for any
58 // notifications. |contents| can be NULL, in which case no infobars 57 // notifications. |contents| can be NULL, in which case no infobars
59 // are shown and no notifications are registered for. 58 // are shown and no notifications are registered for.
60 - (void)changeTabContents:(TabContents*)contents; 59 - (void)changeTabContents:(TabContents*)contents;
61 60
62 @end 61 @end
63 62
64 63
65 @implementation InfoBarContainerController 64 @implementation InfoBarContainerController
66 - (id)initWithTabStripModel:(TabStripModel*)model 65 - (id)initWithTabStripModel:(TabStripModel*)model
67 browserWindowController:(BrowserWindowController*)controller { 66 resizeDelegate:(id<ViewResizer>)resizeDelegate {
68 DCHECK(controller); 67 DCHECK(resizeDelegate);
69 if ((self = [super initWithNibName:@"InfoBarContainer" 68 if ((self = [super initWithNibName:@"InfoBarContainer"
70 bundle:mac_util::MainAppBundle()])) { 69 bundle:mac_util::MainAppBundle()])) {
71 browserController_ = controller; 70 resizeDelegate_ = resizeDelegate;
72 tabObserver_.reset(new TabStripModelObserverBridge(model, self)); 71 tabObserver_.reset(new TabStripModelObserverBridge(model, self));
73 infoBarObserver_.reset(new InfoBarNotificationObserver(self)); 72 infoBarObserver_.reset(new InfoBarNotificationObserver(self));
74 73
75 // NSMutableArray needs an initial capacity, and we rarely ever see 74 // NSMutableArray needs an initial capacity, and we rarely ever see
76 // more than two infobars at a time, so that seems like a good choice. 75 // more than two infobars at a time, so that seems like a good choice.
77 infobarControllers_.reset([[NSMutableArray alloc] initWithCapacity:2]); 76 infobarControllers_.reset([[NSMutableArray alloc] initWithCapacity:2]);
78 } 77 }
79 return self; 78 return self;
80 } 79 }
81 80
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 NSView* view = [controller view]; 177 NSView* view = [controller view];
179 NSRect frame = [view frame]; 178 NSRect frame = [view frame];
180 frame.origin.x = NSMinX(containerBounds); 179 frame.origin.x = NSMinX(containerBounds);
181 frame.size.width = NSWidth(containerBounds); 180 frame.size.width = NSWidth(containerBounds);
182 frame.origin.y = minY; 181 frame.origin.y = minY;
183 minY += frame.size.height; 182 minY += frame.size.height;
184 // TODO(rohitrao, jrg): Replace with an animator. 183 // TODO(rohitrao, jrg): Replace with an animator.
185 [view setFrame:frame]; 184 [view setFrame:frame];
186 } 185 }
187 186
188 [browserController_ infoBarResized:[self desiredHeight]]; 187 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]];
189 } 188 }
190 189
191 @end 190 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/infobar_container_controller.h ('k') | chrome/browser/cocoa/infobar_container_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698