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

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

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

Powered by Google App Engine
This is Rietveld 408576698