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

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

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

Powered by Google App Engine
This is Rietveld 408576698