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

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

Issue 11305008: Remove TabContents from TabStripModelObserverBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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/bundle_locations.h" 6 #include "base/mac/bundle_locations.h"
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
9 #include "chrome/browser/infobars/infobar.h" 9 #include "chrome/browser/infobars/infobar.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h" 10 #include "chrome/browser/infobars/infobar_tab_helper.h"
11 #import "chrome/browser/ui/cocoa/animatable_view.h" 11 #import "chrome/browser/ui/cocoa/animatable_view.h"
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 13 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
14 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 14 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
15 #import "chrome/browser/ui/cocoa/view_id_util.h" 15 #import "chrome/browser/ui/cocoa/view_id_util.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
18 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
19 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
20 #include "skia/ext/skia_utils_mac.h" 19 #include "skia/ext/skia_utils_mac.h"
21 20
22 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED 21 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED
23 // notifications and proxies them back to |controller|. 22 // notifications and proxies them back to |controller|.
24 class InfoBarNotificationObserver : public content::NotificationObserver { 23 class InfoBarNotificationObserver : public content::NotificationObserver {
25 public: 24 public:
26 InfoBarNotificationObserver(InfoBarContainerController* controller) 25 InfoBarNotificationObserver(InfoBarContainerController* controller)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 [self positionInfoBarsAndRedraw]; 128 [self positionInfoBarsAndRedraw];
130 } 129 }
131 130
132 - (BrowserWindowController*)browserWindowController { 131 - (BrowserWindowController*)browserWindowController {
133 id controller = [[[self view] window] windowController]; 132 id controller = [[[self view] window] windowController];
134 if (![controller isKindOfClass:[BrowserWindowController class]]) 133 if (![controller isKindOfClass:[BrowserWindowController class]])
135 return nil; 134 return nil;
136 return controller; 135 return controller;
137 } 136 }
138 137
139 - (void)changeTabContents:(TabContents*)contents { 138 - (void)changeWebContents:(content::WebContents*)contents {
140 registrar_.RemoveAll(); 139 registrar_.RemoveAll();
141 [self removeAllInfoBars]; 140 [self removeAllInfoBars];
142 141
143 currentTabContents_ = contents; 142 currentWebContents_ = contents;
144 if (currentTabContents_) { 143 if (currentWebContents_) {
145 InfoBarTabHelper* infobarTabHelper = 144 InfoBarTabHelper* infobarTabHelper =
146 InfoBarTabHelper::FromWebContents(currentTabContents_->web_contents()); 145 InfoBarTabHelper::FromWebContents(currentWebContents_);
147 for (size_t i = 0; i < infobarTabHelper->GetInfoBarCount(); ++i) { 146 for (size_t i = 0; i < infobarTabHelper->GetInfoBarCount(); ++i) {
148 InfoBar* infobar = infobarTabHelper-> 147 InfoBar* infobar = infobarTabHelper->
149 GetInfoBarDelegateAt(i)->CreateInfoBar(infobarTabHelper); 148 GetInfoBarDelegateAt(i)->CreateInfoBar(infobarTabHelper);
150 [self addInfoBar:infobar animate:NO]; 149 [self addInfoBar:infobar animate:NO];
151 } 150 }
152 151
153 content::Source<InfoBarTabHelper> source(infobarTabHelper); 152 content::Source<InfoBarTabHelper> source(infobarTabHelper);
154 registrar_.Add(infoBarObserver_.get(), 153 registrar_.Add(infoBarObserver_.get(),
155 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source); 154 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source);
156 registrar_.Add(infoBarObserver_.get(), 155 registrar_.Add(infoBarObserver_.get(),
157 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source); 156 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source);
158 registrar_.Add(infoBarObserver_.get(), 157 registrar_.Add(infoBarObserver_.get(),
159 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, source); 158 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, source);
160 } 159 }
161 160
162 [self positionInfoBarsAndRedraw]; 161 [self positionInfoBarsAndRedraw];
163 } 162 }
164 163
165 - (void)tabDetachedWithContents:(TabContents*)contents { 164 - (void)tabDetachedWithContents:(content::WebContents*)contents {
166 if (currentTabContents_ == contents) 165 if (currentWebContents_ == contents)
167 [self changeTabContents:NULL]; 166 [self changeWebContents:NULL];
168 } 167 }
169 168
170 - (NSUInteger)infobarCount { 169 - (NSUInteger)infobarCount {
171 return [infobarControllers_ count] - [closingInfoBars_ count]; 170 return [infobarControllers_ count] - [closingInfoBars_ count];
172 } 171 }
173 172
174 - (CGFloat)overlappingTipHeight { 173 - (CGFloat)overlappingTipHeight {
175 return [self infobarCount] ? infobars::kTipHeight : 0; 174 return [self infobarCount] ? infobars::kTipHeight : 0;
176 } 175 }
177 176
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 frame.size.width = NSWidth(containerBounds); 268 frame.size.width = NSWidth(containerBounds);
270 [view setFrame:frame]; 269 [view setFrame:frame];
271 270
272 minY += NSHeight(frame) - infobars::kTipHeight; 271 minY += NSHeight(frame) - infobars::kTipHeight;
273 } 272 }
274 273
275 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; 274 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]];
276 } 275 }
277 276
278 @end 277 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698