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

Unified Diff: chrome/browser/tab_contents/infobar_container.cc

Issue 7046080: When replacing an infobar, maintain the old infobar's position. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/infobar_container.cc
===================================================================
--- chrome/browser/tab_contents/infobar_container.cc (revision 88583)
+++ chrome/browser/tab_contents/infobar_container.cc (working copy)
@@ -56,7 +56,7 @@
// OnInfoBarAnimated() for each infobar.
AddInfoBar(
tab_contents_->GetInfoBarDelegateAt(i)->CreateInfoBar(tab_contents_),
- false, NO_CALLBACK);
+ i, false, NO_CALLBACK);
}
}
@@ -124,8 +124,8 @@
switch (type.value) {
case NotificationType::TAB_CONTENTS_INFOBAR_ADDED:
AddInfoBar(
- Details<InfoBarDelegate>(details)->CreateInfoBar(tab_contents_), true,
- WANT_CALLBACK);
+ Details<InfoBarDelegate>(details)->CreateInfoBar(tab_contents_),
+ infobars_.size(), true, WANT_CALLBACK);
break;
case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: {
@@ -138,9 +138,8 @@
case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED: {
typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> ReplaceDetails;
ReplaceDetails* replace_details = Details<ReplaceDetails>(details).ptr();
- RemoveInfoBar(replace_details->first, false);
- AddInfoBar(replace_details->second->CreateInfoBar(tab_contents_), false,
- WANT_CALLBACK);
+ AddInfoBar(replace_details->second->CreateInfoBar(tab_contents_),
+ RemoveInfoBar(replace_details->first, false), false, WANT_CALLBACK);
break;
}
@@ -150,8 +149,8 @@
}
}
-void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate,
- bool use_animation) {
+size_t InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate,
+ bool use_animation) {
// Search for the infobar associated with |delegate|. We cannot search for
// |delegate| in |tab_contents_|, because an InfoBar remains alive until its
// close animation completes, while the delegate is removed from the tab
@@ -159,23 +158,28 @@
for (InfoBars::iterator i(infobars_.begin()); i != infobars_.end(); ++i) {
InfoBar* infobar = *i;
if (infobar->delegate() == delegate) {
+ size_t position = i - infobars_.begin();
// We merely need hide the infobar; it will call back to RemoveInfoBar()
// itself once it's hidden.
infobar->Hide(use_animation);
UpdateInfoBarArrowTargetHeights();
- break;
+ return position;
}
}
+ NOTREACHED();
+ return infobars_.size();
}
void InfoBarContainer::AddInfoBar(InfoBar* infobar,
+ size_t position,
bool animate,
CallbackStatus callback_status) {
DCHECK(std::find(infobars_.begin(), infobars_.end(), infobar) ==
infobars_.end());
- infobars_.push_back(infobar);
+ DCHECK_LE(position, infobars_.size());
+ infobars_.insert(infobars_.begin() + position, infobar);
UpdateInfoBarArrowTargetHeights();
- PlatformSpecificAddInfoBar(infobar);
+ PlatformSpecificAddInfoBar(infobar, position);
if (callback_status == WANT_CALLBACK)
infobar->set_container(this);
infobar->Show(animate);
« no previous file with comments | « chrome/browser/tab_contents/infobar_container.h ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698