summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 16:26:17 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 16:26:17 +0000
commit0de1fb9715db68c0a8b6a8b19de1f59ea445bb79 (patch)
treed30a4a09df249860108b7636c45e6185b4832f13
parent849c665ada183ae516869c4e71cb60e8bb6310f8 (diff)
downloadchromium_src-0de1fb9715db68c0a8b6a8b19de1f59ea445bb79.zip
chromium_src-0de1fb9715db68c0a8b6a8b19de1f59ea445bb79.tar.gz
chromium_src-0de1fb9715db68c0a8b6a8b19de1f59ea445bb79.tar.bz2
Add support for replace infobar. The lack of this was a top mac crasher.
BUG=19728 TEST=install two themes without dismissing info bar. then dismiss the info bar. It shouldn't crash. Review URL: http://codereview.chromium.org/174349 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24234 0039d316-1c4b-4281-b951-d872f2087c98
-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];