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

Unified Diff: chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm

Issue 7006010: Change InfoBar-related notifications to be sourced from a TabContentsWrapper, not a TabContents. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm
===================================================================
--- chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm (revision 87541)
+++ chrome/browser/ui/cocoa/infobars/infobar_container_controller.mm (working copy)
@@ -30,23 +30,32 @@
const NotificationDetails& details) {
switch (type.value) {
case NotificationType::TAB_CONTENTS_INFOBAR_ADDED:
- [controller_ addInfoBar:Details<InfoBarDelegate>(details).ptr()
- animate:YES];
+ [controller_ addInfoBar:Details<InfoBar>(details).ptr()
+ animate:YES
+ deleteImmediately:NO];
break;
- case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED:
+
+ case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: {
+ typedef std::pair<InfoBarDelegate*, bool> RemoveDetails;
+ RemoveDetails* remove_details = Details<RemoveDetails>(details).ptr();
[controller_
- closeInfoBarsForDelegate:Details<InfoBarDelegate>(details).ptr()
- animate:YES];
+ closeInfoBarsForDelegate:remove_details->first
+ animate:(remove_details->second ? YES : NO)];
break;
+ }
+
case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED: {
- typedef std::pair<InfoBarDelegate*, InfoBarDelegate*>
- InfoBarDelegatePair;
- InfoBarDelegatePair* delegates =
- Details<InfoBarDelegatePair>(details).ptr();
- [controller_
- replaceInfoBarsForDelegate:delegates->first with:delegates->second];
+ typedef std::pair<InfoBarDelegate*, InfoBar*> ReplaceDetails;
+ ReplaceDetails* replace_details =
+ Details<ReplaceDetails>(details).ptr();
+ [controller_ closeInfoBarsForDelegate:replace_details->first
+ animate:NO];
+ [controller_ addInfoBar:replace_details->second
+ animate:NO
+ deleteImmediately:NO];
break;
}
+
default:
NOTREACHED(); // we don't ask for anything else!
break;
@@ -127,11 +136,12 @@
currentTabContents_ = contents;
if (currentTabContents_) {
for (size_t i = 0; i < currentTabContents_->infobar_count(); ++i) {
- [self addInfoBar:currentTabContents_->GetInfoBarDelegateAt(i)
- animate:NO];
+ InfoBar* infobar = currentTabContents_->GetInfoBarDelegateAt(i)->
+ CreateInfoBar(currentTabContents_);
+ [self addInfoBar:infobar animate:NO deleteImmediately:YES];
}
- Source<TabContents> source(currentTabContents_->tab_contents());
+ Source<TabContentsWrapper> source(currentTabContents_);
registrar_.Add(infoBarObserver_.get(),
NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source);
registrar_.Add(infoBarObserver_.get(),
@@ -179,8 +189,9 @@
return height;
}
-- (void)addInfoBar:(InfoBarDelegate*)delegate animate:(BOOL)animate {
- scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar(currentTabContents_));
+- (void)addInfoBar:(InfoBar*)infobar
+ animate:(BOOL)animate
+ deleteImmediately:(BOOL)deleteImmediately {
InfoBarController* controller = infobar->controller();
[controller setContainerController:self];
[[controller animatableView] setResizeDelegate:self];
@@ -191,6 +202,11 @@
[controller animateOpen];
else
[controller open];
+
+ if (deleteImmediately)
+ delete infobar;
+ else
+ MessageLoop::current()->DeleteSoon(FROM_HERE, infobar);
}
- (void)closeInfoBarsForDelegate:(InfoBarDelegate*)delegate
@@ -207,12 +223,6 @@
}
}
-- (void)replaceInfoBarsForDelegate:(InfoBarDelegate*)old_delegate
- with:(InfoBarDelegate*)new_delegate {
- [self closeInfoBarsForDelegate:old_delegate animate:NO];
- [self addInfoBar:new_delegate animate:NO];
-}
-
- (void)removeAllInfoBars {
// stopAnimation can remove the infobar from infobarControllers_ if it was in
// the midst of closing, so copy the array so mutations won't cause problems.

Powered by Google App Engine
This is Rietveld 408576698