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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_container_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 #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/infobars/infobar_tab_helper.h"
7 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 8 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
8 #include "chrome/browser/tab_contents/infobar.h" 9 #include "chrome/browser/tab_contents/infobar.h"
9 #import "chrome/browser/ui/cocoa/animatable_view.h" 10 #import "chrome/browser/ui/cocoa/animatable_view.h"
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
11 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 12 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
12 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 13 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
13 #import "chrome/browser/ui/cocoa/view_id_util.h" 14 #import "chrome/browser/ui/cocoa/view_id_util.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
16 #include "content/common/notification_details.h" 17 #include "content/common/notification_details.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return nil; 133 return nil;
133 return controller; 134 return controller;
134 } 135 }
135 136
136 - (void)changeTabContents:(TabContentsWrapper*)contents { 137 - (void)changeTabContents:(TabContentsWrapper*)contents {
137 registrar_.RemoveAll(); 138 registrar_.RemoveAll();
138 [self removeAllInfoBars]; 139 [self removeAllInfoBars];
139 140
140 currentTabContents_ = contents; 141 currentTabContents_ = contents;
141 if (currentTabContents_) { 142 if (currentTabContents_) {
142 for (size_t i = 0; i < currentTabContents_->infobar_count(); ++i) { 143 for (size_t i = 0;
143 InfoBar* infobar = currentTabContents_->GetInfoBarDelegateAt(i)-> 144 i < currentTabContents_->infobar_tab_helper()->infobar_count();
Peter Kasting 2011/08/31 18:47:32 Nit: Factor this infobar_tab_helper() out to a tem
144 CreateInfoBar(currentTabContents_); 145 ++i) {
146 InfoBar* infobar = currentTabContents_->infobar_tab_helper()->
147 GetInfoBarDelegateAt(i)->CreateInfoBar(currentTabContents_);
145 [self addInfoBar:infobar animate:NO]; 148 [self addInfoBar:infobar animate:NO];
146 } 149 }
147 150
148 Source<TabContentsWrapper> source(currentTabContents_); 151 Source<TabContentsWrapper> source(currentTabContents_);
149 registrar_.Add(infoBarObserver_.get(), 152 registrar_.Add(infoBarObserver_.get(),
150 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); 153 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source);
151 registrar_.Add(infoBarObserver_.get(), 154 registrar_.Add(infoBarObserver_.get(),
152 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source); 155 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source);
153 registrar_.Add(infoBarObserver_.get(), 156 registrar_.Add(infoBarObserver_.get(),
154 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, source); 157 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, source);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 frame.size.width = NSWidth(containerBounds); 263 frame.size.width = NSWidth(containerBounds);
261 [view setFrame:frame]; 264 [view setFrame:frame];
262 265
263 minY += NSHeight(frame) - infobars::kTipHeight; 266 minY += NSHeight(frame) - infobars::kTipHeight;
264 } 267 }
265 268
266 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; 269 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]];
267 } 270 }
268 271
269 @end 272 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698