| 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 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar.h" | 11 #include "chrome/browser/infobars/infobar.h" |
| 11 #include "chrome/browser/infobars/infobar_container.h" | 12 #include "chrome/browser/infobars/infobar_container.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 14 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" | 15 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
| 15 #import "chrome/browser/ui/cocoa/infobars/infobar_container_cocoa.h" | 16 #import "chrome/browser/ui/cocoa/infobars/infobar_container_cocoa.h" |
| 16 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" | 17 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" |
| 17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 18 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 18 #import "chrome/browser/ui/cocoa/view_id_util.h" | 19 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 93 |
| 93 NSView* relativeView = nil; | 94 NSView* relativeView = nil; |
| 94 if (position > 0) | 95 if (position > 0) |
| 95 relativeView = [[infobarControllers_ objectAtIndex:position - 1] view]; | 96 relativeView = [[infobarControllers_ objectAtIndex:position - 1] view]; |
| 96 [[self view] addSubview:[controller view] | 97 [[self view] addSubview:[controller view] |
| 97 positioned:NSWindowAbove | 98 positioned:NSWindowAbove |
| 98 relativeTo:relativeView]; | 99 relativeTo:relativeView]; |
| 99 } | 100 } |
| 100 | 101 |
| 101 - (void)removeInfoBar:(InfoBarCocoa*)infobar { | 102 - (void)removeInfoBar:(InfoBarCocoa*)infobar { |
| 102 [infobar->controller() infobarWillHide]; | 103 InfoBarController* controller = infobar->controller(); |
| 103 [self removeController:infobar->controller()]; | 104 [controller infobarWillClose]; |
| 105 infobar->set_controller(nil); |
| 106 [self removeController:controller]; |
| 107 base::MessageLoop::current()->DeleteSoon(FROM_HERE, infobar); |
| 104 } | 108 } |
| 105 | 109 |
| 106 - (void)positionInfoBarsAndRedraw:(BOOL)isAnimating { | 110 - (void)positionInfoBarsAndRedraw:(BOOL)isAnimating { |
| 107 if (isAnimating_ != isAnimating) { | 111 if (isAnimating_ != isAnimating) { |
| 108 isAnimating_ = isAnimating; | 112 isAnimating_ = isAnimating; |
| 109 if ([resizeDelegate_ respondsToSelector:@selector(setAnimationInProgress:)]) | 113 if ([resizeDelegate_ respondsToSelector:@selector(setAnimationInProgress:)]) |
| 110 [resizeDelegate_ setAnimationInProgress:isAnimating_]; | 114 [resizeDelegate_ setAnimationInProgress:isAnimating_]; |
| 111 } | 115 } |
| 112 | 116 |
| 113 NSRect containerBounds = [[self view] bounds]; | 117 NSRect containerBounds = [[self view] bounds]; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 160 |
| 157 // This code can be executed while InfoBarController is still on the stack, so | 161 // This code can be executed while InfoBarController is still on the stack, so |
| 158 // we retain and autorelease the controller to prevent it from being | 162 // we retain and autorelease the controller to prevent it from being |
| 159 // dealloc'ed too early. | 163 // dealloc'ed too early. |
| 160 [[controller retain] autorelease]; | 164 [[controller retain] autorelease]; |
| 161 [[controller view] removeFromSuperview]; | 165 [[controller view] removeFromSuperview]; |
| 162 [infobarControllers_ removeObject:controller]; | 166 [infobarControllers_ removeObject:controller]; |
| 163 } | 167 } |
| 164 | 168 |
| 165 @end | 169 @end |
| OLD | NEW |