summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/infobar_container_controller.h5
-rw-r--r--chrome/browser/cocoa/infobar_container_controller.mm20
2 files changed, 24 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/infobar_container_controller.h b/chrome/browser/cocoa/infobar_container_controller.h
index cfd7157..22077ac 100644
--- a/chrome/browser/cocoa/infobar_container_controller.h
+++ b/chrome/browser/cocoa/infobar_container_controller.h
@@ -64,6 +64,11 @@ class TabStripModelObserverBridge;
// call positionInfoBarsAndRedraw after calling this method.
- (void)removeInfoBarsForDelegate:(InfoBarDelegate*)delegate;
+// Replaces all info bars for the delegate with a new info bar.
+// This simply calls removeInfoBarsForDelegate: and then addInfoBar:.
+- (void)replaceInfoBarsForDelegate:(InfoBarDelegate*)old_delegate
+ with:(InfoBarDelegate*)new_delegate;
+
// Positions the infobar views in the container view and notifies
// |browser_controller_| that it needs to resize the container view.
- (void)positionInfoBarsAndRedraw;
diff --git a/chrome/browser/cocoa/infobar_container_controller.mm b/chrome/browser/cocoa/infobar_container_controller.mm
index 4acc324..832a014 100644
--- a/chrome/browser/cocoa/infobar_container_controller.mm
+++ b/chrome/browser/cocoa/infobar_container_controller.mm
@@ -33,6 +33,15 @@ class InfoBarNotificationObserver : public NotificationObserver {
[controller_
removeInfoBarsForDelegate:Details<InfoBarDelegate>(details).ptr()];
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];
+ break;
+ }
default:
NOTREACHED(); // we don't ask for anything else!
break;
@@ -130,6 +139,8 @@ class InfoBarNotificationObserver : public NotificationObserver {
NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source);
registrar_.Add(infoBarObserver_.get(),
NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source);
+ registrar_.Add(infoBarObserver_.get(),
+ NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, source);
}
[self positionInfoBarsAndRedraw];
@@ -145,7 +156,7 @@ class InfoBarNotificationObserver : public NotificationObserver {
- (void)removeInfoBarsForDelegate:(InfoBarDelegate*)delegate {
for (InfoBarController* controller in
- [NSArray arrayWithArray:infobarControllers_.get()]) {
+ [NSArray arrayWithArray:infobarControllers_.get()]) {
if ([controller delegate] == delegate) {
// This code can be executed while -[InfoBarController closeInfoBar] is
// still on the stack, so we retain and autorelease the controller to
@@ -157,6 +168,13 @@ class InfoBarNotificationObserver : public NotificationObserver {
}
}
+- (void)replaceInfoBarsForDelegate:(InfoBarDelegate*)old_delegate
+ with:(InfoBarDelegate*)new_delegate {
+ // TODO(rohitrao): This should avoid animation when we add it.
+ [self removeInfoBarsForDelegate:old_delegate];
+ [self addInfoBar:new_delegate];
+}
+
- (void)removeAllInfoBars {
for (InfoBarController* controller in infobarControllers_.get()) {
[[controller view] removeFromSuperview];