OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac_util.h" | 6 #include "base/mac/mac_util.h" |
7 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 7 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
8 #include "chrome/browser/tab_contents/infobar.h" | 8 #include "chrome/browser/tab_contents/infobar.h" |
9 #import "chrome/browser/ui/cocoa/animatable_view.h" | 9 #import "chrome/browser/ui/cocoa/animatable_view.h" |
10 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 10 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 | 151 |
152 - (void)tabDetachedWithContents:(TabContentsWrapper*)contents { | 152 - (void)tabDetachedWithContents:(TabContentsWrapper*)contents { |
153 if (currentTabContents_ == contents) | 153 if (currentTabContents_ == contents) |
154 [self changeTabContents:NULL]; | 154 [self changeTabContents:NULL]; |
155 } | 155 } |
156 | 156 |
157 - (NSUInteger)infobarCount { | 157 - (NSUInteger)infobarCount { |
158 return [infobarControllers_ count] - [closingInfoBars_ count]; | 158 return [infobarControllers_ count] - [closingInfoBars_ count]; |
159 } | 159 } |
160 | 160 |
161 - (CGFloat)antiSpoofHeight { | 161 - (CGFloat)overlappingTipHeight { |
162 return 0; | 162 return [self infobarCount] ? infobars::kTipHeight : 0; |
163 } | 163 } |
164 | 164 |
165 - (void)resizeView:(NSView*)view newHeight:(CGFloat)height { | 165 - (void)resizeView:(NSView*)view newHeight:(CGFloat)height { |
166 NSRect frame = [view frame]; | 166 NSRect frame = [view frame]; |
167 frame.size.height = height; | 167 frame.size.height = height; |
168 [view setFrame:frame]; | 168 [view setFrame:frame]; |
169 [self positionInfoBarsAndRedraw]; | 169 [self positionInfoBarsAndRedraw]; |
170 } | 170 } |
171 | 171 |
172 - (void)setAnimationInProgress:(BOOL)inProgress { | 172 - (void)setAnimationInProgress:(BOOL)inProgress { |
173 if ([resizeDelegate_ respondsToSelector:@selector(setAnimationInProgress:)]) | 173 if ([resizeDelegate_ respondsToSelector:@selector(setAnimationInProgress:)]) |
174 [resizeDelegate_ setAnimationInProgress:inProgress]; | 174 [resizeDelegate_ setAnimationInProgress:inProgress]; |
175 } | 175 } |
176 | 176 |
177 @end | 177 @end |
178 | 178 |
179 @implementation InfoBarContainerController (PrivateMethods) | 179 @implementation InfoBarContainerController (PrivateMethods) |
180 | 180 |
181 - (CGFloat)desiredHeight { | 181 - (CGFloat)desiredHeight { |
182 CGFloat height = 0; | 182 CGFloat height = 0; |
183 | |
183 for (InfoBarController* controller in infobarControllers_.get()) | 184 for (InfoBarController* controller in infobarControllers_.get()) |
rohitrao (ping after 24h)
2011/08/05 14:24:12
Add a comment reminding us that NSHeight(eachInfob
Robert Sesek
2011/08/05 15:10:40
Done.
| |
184 height += NSHeight([[controller view] frame]); | 185 height += NSHeight([[controller view] frame]) - infobars::kTipHeight; |
186 | |
187 // If there's any infobars, add a little extra room for the tip of the first | |
rohitrao (ping after 24h)
2011/08/05 14:24:12
s/there's/there are/
Robert Sesek
2011/08/05 15:10:40
Done.
| |
188 // infobar. | |
189 if (height) | |
190 height += infobars::kTipHeight; | |
191 | |
185 return height; | 192 return height; |
186 } | 193 } |
187 | 194 |
188 - (void)addInfoBar:(InfoBar*)infobar animate:(BOOL)animate { | 195 - (void)addInfoBar:(InfoBar*)infobar animate:(BOOL)animate { |
189 InfoBarController* controller = infobar->controller(); | 196 InfoBarController* controller = infobar->controller(); |
190 [controller setContainerController:self]; | 197 [controller setContainerController:self]; |
191 [[controller animatableView] setResizeDelegate:self]; | 198 [[controller animatableView] setResizeDelegate:self]; |
192 [[self view] addSubview:[controller view]]; | 199 [[self view] addSubview:[controller view]]; |
193 [infobarControllers_ addObject:[controller autorelease]]; | 200 [infobarControllers_ addObject:[controller autorelease]]; |
194 | 201 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 // the others below. | 243 // the others below. |
237 for (InfoBarController* controller in | 244 for (InfoBarController* controller in |
238 [infobarControllers_ reverseObjectEnumerator]) { | 245 [infobarControllers_ reverseObjectEnumerator]) { |
239 NSView* view = [controller view]; | 246 NSView* view = [controller view]; |
240 NSRect frame = [view frame]; | 247 NSRect frame = [view frame]; |
241 frame.origin.x = NSMinX(containerBounds); | 248 frame.origin.x = NSMinX(containerBounds); |
242 frame.origin.y = minY; | 249 frame.origin.y = minY; |
243 frame.size.width = NSWidth(containerBounds); | 250 frame.size.width = NSWidth(containerBounds); |
244 [view setFrame:frame]; | 251 [view setFrame:frame]; |
245 | 252 |
246 minY += NSHeight(frame); | 253 minY += NSHeight(frame) - infobars::kTipHeight; |
247 } | 254 } |
248 | 255 |
249 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; | 256 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; |
250 } | 257 } |
251 | 258 |
252 @end | 259 @end |
OLD | NEW |