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

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

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 9 years, 3 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) 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/logging.h" // for NOTREACHED() 7 #include "base/logging.h" // for NOTREACHED()
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/infobars/infobar_tab_helper.h"
10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
11 #include "chrome/browser/tab_contents/link_infobar_delegate.h" 12 #include "chrome/browser/tab_contents/link_infobar_delegate.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #import "chrome/browser/ui/cocoa/animatable_view.h" 14 #import "chrome/browser/ui/cocoa/animatable_view.h"
14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
15 #include "chrome/browser/ui/cocoa/event_utils.h" 16 #include "chrome/browser/ui/cocoa/event_utils.h"
16 #include "chrome/browser/ui/cocoa/infobars/infobar.h" 17 #include "chrome/browser/ui/cocoa/infobars/infobar.h"
17 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 18 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
18 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 19 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
19 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" 20 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 110
110 @synthesize containerController = containerController_; 111 @synthesize containerController = containerController_;
111 @synthesize delegate = delegate_; 112 @synthesize delegate = delegate_;
112 113
113 - (id)initWithDelegate:(InfoBarDelegate*)delegate 114 - (id)initWithDelegate:(InfoBarDelegate*)delegate
114 owner:(TabContentsWrapper*)owner { 115 owner:(TabContentsWrapper*)owner {
115 DCHECK(delegate); 116 DCHECK(delegate);
116 if ((self = [super initWithNibName:@"InfoBar" 117 if ((self = [super initWithNibName:@"InfoBar"
117 bundle:base::mac::MainAppBundle()])) { 118 bundle:base::mac::MainAppBundle()])) {
118 delegate_ = delegate; 119 delegate_ = delegate;
119 owner_ = owner; 120 owner_ = owner;
Peter Kasting 2011/08/31 18:47:32 Another |owner_| that should probably become an In
120 } 121 }
121 return self; 122 return self;
122 } 123 }
123 124
124 // All infobars have an icon, so we set up the icon in the base class 125 // All infobars have an icon, so we set up the icon in the base class
125 // awakeFromNib. 126 // awakeFromNib.
126 - (void)awakeFromNib { 127 - (void)awakeFromNib {
127 DCHECK(delegate_); 128 DCHECK(delegate_);
128 if (delegate_->GetIcon()) { 129 if (delegate_->GetIcon()) {
129 [image_ setImage:*(delegate_->GetIcon())]; 130 [image_ setImage:*(delegate_->GetIcon())];
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 [label_.get() setHorizontallyResizable:NO]; 275 [label_.get() setHorizontallyResizable:NO];
275 [label_.get() setVerticallyResizable:NO]; 276 [label_.get() setVerticallyResizable:NO];
276 } 277 }
277 278
278 - (void)removeSelf { 279 - (void)removeSelf {
279 // TODO(rohitrao): This method can be called even if the infobar has already 280 // TODO(rohitrao): This method can be called even if the infobar has already
280 // been removed and |delegate_| is NULL. Is there a way to rewrite the code 281 // been removed and |delegate_| is NULL. Is there a way to rewrite the code
281 // so that inner event loops don't cause us to try and remove the infobar 282 // so that inner event loops don't cause us to try and remove the infobar
282 // twice? http://crbug.com/54253 283 // twice? http://crbug.com/54253
283 if (owner_) 284 if (owner_)
284 owner_->RemoveInfoBar(delegate_); 285 owner_->infobar_tab_helper()->RemoveInfoBar(delegate_);
285 owner_ = NULL; 286 owner_ = NULL;
286 } 287 }
287 288
288 - (void)cleanUpAfterAnimation:(BOOL)finished { 289 - (void)cleanUpAfterAnimation:(BOOL)finished {
289 // Don't need to do any cleanup if the bar was animating open. 290 // Don't need to do any cleanup if the bar was animating open.
290 if (!infoBarClosing_) 291 if (!infoBarClosing_)
291 return; 292 return;
292 293
293 // Notify the delegate that the infobar was closed. The delegate will delete 294 // Notify the delegate that the infobar was closed. The delegate will delete
294 // itself as a result of InfoBarClosed(), so we null out its pointer. 295 // itself as a result of InfoBarClosed(), so we null out its pointer.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 LinkInfoBarController* controller = 562 LinkInfoBarController* controller =
562 [[LinkInfoBarController alloc] initWithDelegate:this owner:owner]; 563 [[LinkInfoBarController alloc] initWithDelegate:this owner:owner];
563 return new InfoBar(controller, this); 564 return new InfoBar(controller, this);
564 } 565 }
565 566
566 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { 567 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) {
567 ConfirmInfoBarController* controller = 568 ConfirmInfoBarController* controller =
568 [[ConfirmInfoBarController alloc] initWithDelegate:this owner:owner]; 569 [[ConfirmInfoBarController alloc] initWithDelegate:this owner:owner];
569 return new InfoBar(controller, this); 570 return new InfoBar(controller, this);
570 } 571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698